:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1d2129;
  --muted: #6b7280;
  --primary: #2451e6;
  --primary-dark: #1c40bb;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: #101728;
  color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 18px; text-decoration: none; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: #c6cbd8; text-decoration: none; padding: 6px 8px; border-radius: 6px; }
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.userbox { display: flex; align-items: center; gap: 12px; color: #c6cbd8; }

.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Cabeçalho de página */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions form { display: inline; }

/* Botões */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover { background: #eef0f4; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(0.92); }
.btn-danger { color: var(--red); border-color: #f3c1c1; }
.btn-danger:hover { background: #fdeaea; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.active { outline: 2px solid var(--primary); }

/* Tabela */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #fafbfc; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { display: inline; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #e5e7eb; font-size: 12px; }
.badge-green { background: #dcfce7; color: #166534; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 40px 0; text-align: center; }

/* Formulários */
label { display: block; margin-bottom: 12px; font-size: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
#html-editor { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters input[type="search"] { max-width: 320px; margin-top: 0; }
.filters select { width: auto; margin-top: 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card legend { font-weight: 600; padding: 0 6px; }
fieldset.card { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 12px; align-items: end; }
.grid-span { grid-column: 1 / -1; }

/* Alertas */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-error { background: #fdeaea; color: #991b1b; border: 1px solid #f3c1c1; }
.alert-info { background: #e8efff; color: #1e3a8a; border: 1px solid #c3d4fb; }

/* Editor: duas colunas */
.editor-layout { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(400px, 1.2fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .editor-layout { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.tab { border: none; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.tab.active { background: var(--primary); color: #fff; }
.hidden { display: none; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: auto; margin: 0; }

/* Identidades visuais */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
input[type="color"] { width: 100%; height: 38px; margin-top: 4px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type="text"], .inline-form input[type="file"], .inline-form select { width: auto; margin-top: 0; flex: 1; min-width: 180px; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.15); vertical-align: middle; margin-right: 4px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 12px; }
.asset-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: #fafbfc; }
.asset-thumb { height: 90px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 0 0 / 16px 16px; border-radius: 6px; overflow: hidden; }
.asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-meta { display: flex; align-items: center; gap: 6px; margin: 8px 0 6px; }
.asset-actions { display: flex; gap: 6px; align-items: center; }
.asset-url { flex: 1; font-size: 11px; padding: 4px 6px; margin: 0; font-family: ui-monospace, monospace; }
.tipo-select { width: auto; margin: 0; padding: 2px 4px; font-size: 12px; }
.html-badge { font-family: ui-monospace, monospace; font-size: 24px; color: var(--muted); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 8px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: #f0f4ff; }
.dropzone p { margin: 0; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 23, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-help { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.modal-help summary { cursor: pointer; font-size: 13px; color: var(--primary); user-select: none; }
.modal-steps { font-size: 13px; padding-left: 20px; margin: 10px 0 0; }
.modal-steps li { margin-bottom: 8px; }
.modal-steps ul { padding-left: 16px; margin: 6px 0; }
.modal-steps code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 440px; max-width: calc(100vw - 32px); }
.modal h3 { margin-top: 0; }
.modal .check-label { margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Preview */
.preview-card { position: sticky; top: 16px; }
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.preview-frame-wrap { background: #e9ebef; border-radius: var(--radius); padding: 12px; display: flex; justify-content: center; }
.preview-frame-wrap iframe {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  transition: width 0.2s ease;
}
.preview-frame-wrap.mobile iframe { width: 375px; }
.preview-frame-wrap.fullpage iframe { height: calc(100vh - 220px); }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #101728; }
.login-card { background: #fff; padding: 32px; border-radius: 12px; width: 360px; }
.login-card h1 { margin: 0 0 4px; }
.login-card .muted { margin-top: 0; }
