:root {
  /* paleta Vanguard Vision: preto, branco e ciano */
  --bg: #080808;
  --surface: #111111;
  --surface-2: #181818;
  --border: #242424;
  --text: #ffffff;
  --muted: #94a3b8;
  --primary: #00e5ff;
  --primary-hover: #5cf0ff;
  --primary-soft: rgba(0, 229, 255, .12);
  --on-primary: #051014;
  --ok: #00e5ff;
  --ok-soft: rgba(0, 229, 255, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --err: #ff4d5e;
  --err-soft: rgba(255, 77, 94, .12);
  --radius: 14px;
  --shadow: none;
  --sidebar: 240px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  -webkit-font-smoothing: antialiased;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg);
}
h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.right { text-align: right; }
.error-text { color: var(--err); font-size: 13px; margin: 0; min-height: 0; }
p { margin: 0; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 12px;
}
.brand { display: flex; flex-direction: column; gap: 4px; padding: 4px 10px 24px; }
.brand img { width: 150px; height: auto; filter: drop-shadow(0 0 12px rgba(0, 229, 255, .35)); }
.brand span { font-size: 11px; letter-spacing: .38em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.login-box .brand { align-items: center; padding: 0 0 8px; }
.login-box .brand img { width: 220px; }
.account-switch { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.account-switch select { text-transform: none; letter-spacing: 0; font-size: 13px; padding: 7px 10px; }
.howto { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; color: var(--muted); }
.howto b { color: var(--text); font-weight: 600; }
.conn-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.conn-head h2 { margin-right: auto; }
.logo { font-weight: 800; font-size: 19px; padding: 0 10px 20px; letter-spacing: -.02em; }
.logo span { color: var(--primary); margin-left: 4px; font-weight: 700; text-shadow: 0 0 16px rgba(0, 229, 255, .45); }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); cursor: pointer; font-weight: 500; user-select: none;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); box-shadow: inset 2px 0 0 var(--primary); }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.account { font-size: 12.5px; color: var(--muted); word-break: break-word; }
.account b { color: var(--text); display: block; font-size: 13px; }

main { margin-left: var(--sidebar); flex: 1; padding: 28px 32px 120px; max-width: 1400px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controles ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.head-actions select, .head-actions input { width: auto; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.field-label { font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
.inline-check { flex-direction: row; align-items: center; gap: 8px; margin-top: 12px; font-weight: 400; }
.inline-check input { width: auto; }

.btn {
  font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px; cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow);
  border-radius: 999px; transition: background .15s, border-color .15s, color .15s;
}
.btn:not(.primary):hover { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; box-shadow: 0 0 18px rgba(0, 229, 255, .25); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--err); }
.btn.dashed { border-style: dashed; background: transparent; box-shadow: none; color: var(--muted); }
.btn.dashed:hover { color: var(--primary); border-color: var(--primary); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--err); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.segmented button { font: inherit; font-size: 13px; border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.segmented button.selected { background: var(--primary); color: var(--on-primary); font-weight: 600; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.choice-grid button {
  font: inherit; text-align: left; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.choice-grid button small { color: var(--muted); font-size: 12px; }
.choice-grid button:hover { border-color: var(--primary); }
.choice-grid button.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head.pad { padding: 16px 20px 0; }
.card-head > .btn { margin-left: auto; }
details.card > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 16px; }
.step { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 12.5px; display: grid; place-items: center; flex: none; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 4px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.grid-2 > .card { margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

.sub-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--surface); }
.sub-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sub-card-head input { font-weight: 600; max-width: 320px; }
.sub-card-head .icon-btn { margin-left: auto; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { color: var(--text); font-size: 21px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
th { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--muted); padding: 40px; white-space: normal; }
.col-toggle { width: 36px; padding-right: 0; }
.name-cell { white-space: normal; min-width: 240px; max-width: 420px; }
.name-cell small { display: block; color: var(--muted); font-size: 12px; }
.tree-table tr.level-1 td { background: var(--surface-2); }
.tree-table tr.level-1 .name-cell { padding-left: 30px; }
.tree-table tr.level-2 td { background: var(--bg); }
.tree-table tr.level-2 .name-cell { padding-left: 52px; }
.expander { background: none; border: 0; color: var(--muted); cursor: pointer; width: 24px; height: 24px; border-radius: 6px; transition: transform .15s; }
.expander:hover { background: var(--surface-2); }
.expander.open { transform: rotate(90deg); }
.row-click { cursor: pointer; }
.thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--surface-2); display: inline-block; vertical-align: middle; margin-right: 10px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.error { background: var(--err-soft); color: var(--err); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 20px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { background: var(--on-primary); }
.switch input:checked + span::before { transform: translateX(14px); }
.switch input:disabled + span { opacity: .5; cursor: wait; }
.status-cell { display: flex; align-items: center; gap: 8px; }

.budget-edit { display: inline-flex; align-items: center; gap: 4px; }
.budget-edit input { width: 90px; padding: 4px 8px; text-align: right; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

/* ---------- criação ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft); color: var(--primary); padding: 3px 4px 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.suggest { position: relative; }
.suggest-list { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.6); max-height: 240px; overflow: auto; }
.suggest-list button { display: flex; justify-content: space-between; width: 100%; text-align: left; font: inherit; background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--text); }
.suggest-list button:hover { background: var(--surface-2); }
.suggest-list small { color: var(--muted); }

.ad-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; }
.media-drop {
  border: 1.5px dashed var(--border); border-radius: 10px; min-height: 200px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center; cursor: pointer; padding: 12px;
  color: var(--muted); font-size: 13px; overflow: hidden; position: relative; background: var(--surface-2);
}
.media-drop:hover, .media-drop.drag { border-color: var(--primary); color: var(--primary); }
.media-drop img, .media-drop video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-drop .media-status { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 2; }
.media-drop .media-status .badge { background: var(--surface); box-shadow: var(--shadow); }

.dropzone {
  border: 1.5px dashed var(--border); border-radius: 10px; padding: 28px; display: flex; flex-direction: column;
  align-items: center; gap: 4px; cursor: pointer; margin: 14px 0 10px; font-weight: 400; background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); }
.row-actions { display: flex; gap: 8px; }

.action-bar {
  position: fixed; left: var(--sidebar); right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 32px; flex-wrap: wrap;
}
.summary { color: var(--muted); font-size: 13px; }
.summary b { color: var(--text); }

/* resultado */
.result-card { border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 16px; }
.result-card.ok { border-color: var(--ok); }
.result-card.error { border-color: var(--err); }
.result-card h3 { margin: 0 0 10px; font-size: 15px; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 4px 0 4px 8px; padding-left: 14px; border-left: 1px solid var(--border); }
.tree li { padding: 3px 0; }
.tree .c { font-weight: 600; }
.tree .d { color: var(--muted); }
.tree .money { color: var(--ok); margin-left: 8px; font-size: 12.5px; }
.errors { margin: 0 0 10px; padding-left: 18px; color: var(--err); }

/* templates */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cards .card { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.cards .card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }

details.log summary { cursor: pointer; color: var(--primary); }
details.log pre { max-width: 640px; max-height: 320px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; white-space: pre-wrap; font-size: 12px; }

/* login */
.login { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.login-box { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 0 60px rgba(0, 229, 255, .08); }
.login-box .logo { padding: 0; font-size: 24px; }

/* toast */
.toast {
  position: fixed; bottom: 84px; right: 24px; z-index: 200; max-width: 420px;
  background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: 10px;
  opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; font-weight: 500;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--err); color: #fff; }
.toast.ok { background: var(--primary); color: var(--on-primary); }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  :root { --sidebar: 0px; }
  .sidebar { position: static; width: auto; flex-direction: row; align-items: center; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; gap: 12px; }
  .app { flex-direction: column; }
  .brand { padding: 0; }
  .brand img { width: 110px; }
  .brand span, .sidebar-foot .nav-item { display: none; }
  .account-switch { font-size: 0; gap: 0; }
  nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; }
  .account { display: none; }
  main { margin-left: 0; padding: 20px 16px 120px; }
  .grid-2, .grid-3, .grid-4, .ad-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .action-bar { left: 0; padding: 12px 16px; }
}
