/* Tema escuro "noturno": preto quase puro, brilho quente nas bordas, acentos prateados.
   Verde e violeta ficam só para dados (gráficos e resultados). Tema claro opcional. */
:root {
  color-scheme: dark;
  --bg: #050505;
  --bg-glow:
    radial-gradient(900px 700px at -8% 105%, rgba(150, 52, 22, .22), transparent 60%),
    radial-gradient(800px 600px at 108% -5%, rgba(120, 36, 30, .16), transparent 60%),
    radial-gradient(600px 400px at 60% 120%, rgba(90, 40, 20, .10), transparent 70%);
  --surface: #0b0b0c;
  --surface-2: #111113;
  --surface-3: #18181b;
  --line: #1f1f23;
  --line-soft: #161619;
  --grid: #18181b;
  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --text-3: #6b6b74;
  --accent: #f4f4f5;            /* prata/branco: botões e seleção */
  --accent-strong: #ffffff;
  --accent-ink: #09090b;
  --accent-soft: rgba(255, 255, 255, .06);
  --series-1: #12a46f;          /* faturamento (validado p/ daltonismo) */
  --series-2: #8b7cf6;          /* gasto */
  --pos: #12a46f;
  --neg: #e5484d;
  --good: #22c55e; --good-ink: #4ade80; --good-bg: rgba(34, 197, 94, .10);
  --warn: #f5b13d; --warn-ink: #f5c26b; --warn-bg: rgba(245, 177, 61, .10);
  --bad: #e5484d; --bad-ink: #f87171; --bad-bg: rgba(229, 72, 77, .10);
  --shadow: 0 1px 0 rgba(255,255,255,.035) inset, 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
  --rail-w: 76px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f5;
  --bg-glow: radial-gradient(900px 700px at -8% 105%, rgba(200, 120, 80, .10), transparent 60%),
             radial-gradient(800px 600px at 108% -5%, rgba(200, 120, 100, .08), transparent 60%);
  --surface: #ffffff; --surface-2: #f6f6f7; --surface-3: #ededef;
  --line: #e4e4e7; --line-soft: #efeff1; --grid: #efeff1;
  --text: #09090b; --text-2: #52525b; --text-3: #7c7c85;
  --accent: #09090b; --accent-strong: #000; --accent-ink: #ffffff; --accent-soft: rgba(0,0,0,.05);
  --series-1: #0f8a5f; --series-2: #6d5ce0; --pos: #0f8a5f; --neg: #d93d42;
  --good-ink: #15803d; --good-bg: #dcfce7; --warn-ink: #92400e; --warn-bg: #fef3c7; --bad: #d93d42; --bad-ink: #b91c1c; --bad-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); display: inline-flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--text-2); }

/* ---------- marca (morcego geométrico próprio) ---------- */
.brand-mark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; color: #0a0a0a; text-decoration: none;
  background: linear-gradient(160deg, #ffffff, #d4d4d8); box-shadow: 0 0 0 1px rgba(255,255,255,.1) inset, 0 8px 24px rgba(0,0,0,.5); }
.brand-mark svg { width: 30px; height: auto; }
.brand-mark.sm { width: 34px; height: 34px; border-radius: 10px; }
.brand-mark.sm svg { width: 23px; }
:root[data-theme="light"] .brand-mark { background: linear-gradient(160deg, #18181b, #000); }
:root[data-theme="light"] .brand-mark { color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--text-3); }

/* ---------- layout: trilho de ícones + conteúdo ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }
.shell > div { min-width: 0; }
.rail {
  position: sticky; top: 0; height: 100vh; padding: 14px 0; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
}
.rail .brand-mark { margin-bottom: 18px; }
.rail hr { width: 34px; border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.navlink {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px;
  color: var(--text-3); text-decoration: none; transition: background .15s, color .15s;
}
.navlink svg { width: 20px; height: 20px; }
.navlink:hover { color: var(--text); background: var(--surface-2); }
.navlink.active { color: var(--text); background: var(--surface-3); box-shadow: 0 0 0 1px var(--line) inset; }
.navlink.active::before { content: ''; position: absolute; left: -16px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--text); }
.navlink::after { /* dica com o nome ao passar o mouse */
  content: attr(data-tip); position: absolute; left: 54px; top: 50%; transform: translateY(-50%) translateX(-4px);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line); padding: 5px 9px; border-radius: 8px;
  font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; z-index: 30;
}
.navlink:hover::after { opacity: 1; transform: translateY(-50%); }
.rail .grow { flex: 1; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 22px 30px 18px; border-bottom: 1px solid var(--line-soft); }
.topbar .titlebox { flex: 1; min-width: 0; }
.topbar h1 { font-size: 28px; font-weight: 600; letter-spacing: -.035em; margin: 0; }
.topbar .subtitle { color: var(--text-3); font-size: 13px; margin: 3px 0 0; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-mobile-brand { display: none; }
.theme-toggle { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.theme-toggle button { width: 34px; height: 30px; border: 0; border-radius: 9px; background: none; color: var(--text-3); display: grid; place-items: center; cursor: pointer; }
.theme-toggle button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.theme-toggle svg { width: 16px; height: 16px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); border-radius: 12px; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.icon-btn svg { width: 17px; height: 17px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line); cursor: pointer; }
.user-menu { position: relative; }
.user-menu .menu { position: absolute; right: 0; top: 48px; min-width: 210px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px; box-shadow: 0 16px 40px rgba(0,0,0,.5); z-index: 40; }
.user-menu .menu .who { padding: 6px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-menu .menu button { width: 100%; text-align: left; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.user-menu .menu button:hover { background: var(--surface-3); color: var(--text); }
.user-menu .menu svg { width: 15px; height: 15px; }
main { padding: 18px 30px 48px; min-width: 0; max-width: 1560px; width: 100%; }

.tabbar {
  display: none; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
  background: color-mix(in srgb, var(--surface-2) 82%, transparent); backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 12px 34px rgba(0,0,0,.5);
  padding: 6px; grid-template-columns: repeat(5, 1fr);
}
.tabbar button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 500; color: var(--text-3); padding: 7px 0 5px; border-radius: 14px; cursor: pointer; min-height: 50px; }
.tabbar button.active { color: var(--text); background: var(--surface-3); }
.tabbar svg { width: 21px; height: 21px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .tabbar { display: grid; }
  .topbar { position: sticky; top: 0; z-index: 15; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); }
  .top-mobile-brand { display: flex; }
  .topbar h1 { font-size: 18px; letter-spacing: -.02em; }
  .topbar .subtitle, .top-actions .theme-toggle, .top-actions .refresh-label { display: none; }
  .icon-btn, .avatar { width: 38px; height: 38px; }
  main { padding: 12px 14px 112px; }
}

/* ---------- barra de seção: "• Desempenho no período" + filtros ---------- */
.section-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.section-bar .eyebrow { flex: 1; min-width: 200px; }
.section-bar .sync-note { color: var(--text-3); font-size: 11px; letter-spacing: normal; text-transform: none; font-weight: 500; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; }
.select-pill { position: relative; display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); height: 40px; overflow: hidden; }
.select-pill .ico { width: 40px; height: 100%; display: grid; place-items: center; color: var(--text-2); border-right: 1px solid var(--line); flex: none; }
.select-pill .ico svg { width: 16px; height: 16px; }
.select-pill select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; height: 100%; padding: 0 36px 0 14px; cursor: pointer; min-width: 150px; font-weight: 500; }
.select-pill::after { content: ''; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select-pill select:focus { outline: none; }
.select-pill:focus-within { border-color: var(--text-3); }
.select-pill select option { background: var(--surface-2); color: var(--text); }
.input, select.input { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-height: 40px; }
.input:focus { outline: 1px solid var(--text-3); outline-offset: -1px; }
@media (max-width: 900px) {
  .section-bar { gap: 8px; }
  .section-bar .eyebrow { min-width: 100%; }
  .section-bar .filters { width: 100%; }
  .select-pill { flex: 1; min-width: 0; }
  .select-pill select { min-width: 0; width: 100%; }
}

/* chips (Vendas, Diagnóstico) */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; cursor: pointer; white-space: nowrap; color: var(--text-2); font-weight: 500; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 100%, #fff 1.2%), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.card h2 { font-size: 16px; font-weight: 600; margin: 0 0 2px; letter-spacing: -.015em; }
.card .sub { color: var(--text-3); font-size: 12px; margin: 0 0 14px; }
.grid { display: grid; gap: 14px; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 14px; }
.grid.two { grid-template-columns: 1.6fr 1fr; margin-bottom: 14px; }
.grid.halves { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
@media (max-width: 1100px) { .grid.two, .grid.halves { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .grid.kpis { grid-template-columns: 1fr 1fr; gap: 10px; } .card { padding: 15px; } }

/* visão geral: coluna da esquerda (lucro + conquista) e direita (KPIs + evolução) */
.overview { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 14px; margin-bottom: 14px; align-items: stretch; }
.overview .left { display: grid; gap: 14px; grid-template-rows: auto 1fr; }
.overview .right { display: grid; gap: 14px; grid-template-rows: auto 1fr; min-width: 0; }
.overview .right .grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
@media (max-width: 1250px) { .overview { grid-template-columns: 1fr; } .overview .left { grid-template-columns: 1fr 1fr; grid-template-rows: none; } }
@media (max-width: 900px) { .overview .left { grid-template-columns: 1fr; } .overview .right .grid.kpis { grid-template-columns: 1fr 1fr; } }

/* card de lucro (equivalente ao "Saldo") */
.profit-card .head { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 500; }
.profit-card .head .ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--line); color: var(--text-2); }
.profit-card .head .ico svg { width: 16px; height: 16px; }
.profit-card .head .tag { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--good-ink); background: var(--good-bg); border: 1px solid color-mix(in srgb, var(--good) 25%, transparent); padding: 2px 8px; border-radius: 99px; display: inline-flex; gap: 5px; align-items: center; }
.profit-card .head .tag svg { width: 11px; height: 11px; }
.profit-card .value { font-size: 44px; font-weight: 600; letter-spacing: -.04em; line-height: 1.05; margin: 20px 0 6px; }
.profit-card .value.neg { color: var(--bad-ink); }
.goal { margin-top: 18px; }
.goal .row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-3); gap: 8px; }
.goal .row b { color: var(--text); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 10.5px; display: inline-flex; gap: 6px; align-items: center; }
.goal .row b svg { width: 13px; height: 13px; }
.goal .bar { height: 6px; border-radius: 99px; background: var(--surface-3); margin: 9px 0; overflow: hidden; }
.goal .bar div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #a1a1aa, #fafafa); min-width: 4px; transition: width .6s ease; }
.goal .bar div.done { background: linear-gradient(90deg, #16a34a, #4ade80); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.quick a { text-decoration: none; display: grid; justify-items: center; gap: 8px; padding: 16px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 500; transition: border-color .15s, color .15s, background .15s; }
.quick a:hover { color: var(--text); border-color: var(--text-3); background: var(--surface-3); }
.quick a .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--line); }
.quick a svg { width: 15px; height: 15px; }

/* card de conquista com a placa metálica */
.trophy { position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 420px; }
.trophy .stage { flex: 1; position: relative; display: grid; place-items: center; padding: 18px 0; }
.trophy .stage::before { content: ''; position: absolute; width: 260px; height: 320px; background: radial-gradient(closest-side, rgba(220, 200, 170, .16), transparent); filter: blur(4px); }
.plaque { position: relative; width: 170px; aspect-ratio: 3 / 4; border-radius: 6px; padding: 9px;
  background: linear-gradient(145deg, #3a3a3d, #0d0d0e 40%, #2b2b2e 70%, #111);
  box-shadow: 0 30px 60px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.08) inset;
  transform: perspective(700px) rotateY(-8deg); }
.plaque .face { position: relative; height: 100%; border-radius: 3px; display: grid; justify-items: center; align-content: center; gap: 10px; overflow: hidden;
  background: linear-gradient(120deg, #f4f4f5 0%, #c9c9cf 25%, #fafafa 45%, #a7a7ae 65%, #e7e7ea 85%, #bdbdc3 100%); color: #18181b; }
.plaque .face::after { content: ''; position: absolute; inset: -40%; background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.55) 50%, transparent 60%); animation: shine 6s ease-in-out infinite; }
@keyframes shine { 0%, 70% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }
.plaque .face svg { width: 92px; filter: drop-shadow(0 2px 1px rgba(255,255,255,.6)) drop-shadow(0 -1px 0 rgba(0,0,0,.25)); }
.plaque .amount { font-weight: 800; font-size: 17px; letter-spacing: -.02em; color: #27272a; text-shadow: 0 1px 0 rgba(255,255,255,.7); }
.plaque .tier { font-size: 8.5px; letter-spacing: .18em; text-transform: uppercase; color: #52525b; }
.plaque.done .face { background: linear-gradient(120deg, #fde68a 0%, #d4a63a 25%, #fff3c4 45%, #b8862b 65%, #f6dd8c 85%, #c99a3a 100%); }
.trophy .progress-foot { border-top: 1px solid var(--line); padding-top: 14px; }
.trophy .progress-foot .row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); }
.trophy .progress-foot .row.vals { color: var(--text); font-size: 12px; font-weight: 600; margin-top: 4px; }
.trophy .progress-foot .bar { height: 5px; border-radius: 99px; background: var(--surface-3); margin-top: 10px; overflow: hidden; }
.trophy .progress-foot .bar div { height: 100%; background: linear-gradient(90deg, #a1a1aa, #fff); border-radius: 99px; min-width: 4px; }
@media (max-width: 900px) { .trophy { min-height: 0; } .plaque { width: 140px; } }

/* KPIs minimalistas: rótulo à esquerda, ícone à direita, número grande */
.tile { position: relative; overflow: hidden; display: flex; flex-direction: column; }
.tile .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.tile .ico { color: var(--text-3); display: grid; place-items: center; }
.tile .ico svg { width: 16px; height: 16px; }
.tile .value { font-size: 30px; font-weight: 600; letter-spacing: -.035em; margin-top: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .delta { font-size: 12px; margin-top: 4px; color: var(--text-3); }
.tile .spark { height: 30px; margin-top: 10px; }
.delta .up-good, .delta .down-good { color: var(--good-ink); font-weight: 600; }
.delta .up-bad, .delta .down-bad { color: var(--bad-ink); font-weight: 600; }
@media (max-width: 520px) { .tile .value { font-size: 21px; margin-top: 14px; } .tile .spark { height: 24px; } .tile .label { font-size: 12px; } }

/* evolução */
.evo-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.evo-head h2 { flex: 1; margin: 0; }
.evo-total { display: flex; align-items: baseline; gap: 12px; margin: 18px 0 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.evo-total .eyebrow { font-size: 10px; }
.evo-total .v { font-size: 28px; font-weight: 600; letter-spacing: -.03em; }
.empty-state { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 50px 16px; color: var(--text-3); }
.empty-state .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); }
.empty-state .ico svg { width: 22px; height: auto; }
.empty-state b { color: var(--text); font-weight: 600; font-size: 15px; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
th { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; position: sticky; top: 0; background: var(--surface); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sorted { color: var(--text); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--surface-2); }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
tbody tr:hover td.sticky-col { background: var(--surface-2); }
.name-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.name-cell.narrow { max-width: 220px; }
.name-cell .parent { display: block; font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.linkish { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; font-weight: 600; text-align: left; }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }
.pos-ink { color: var(--good-ink); } .neg-ink { color: var(--bad-ink); }
@media (max-width: 900px) { .name-cell { max-width: 170px; } .table-wrap { margin: 0 -15px; padding: 0 15px; } }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-bg); color: var(--good-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }

/* switch liga/desliga (verde = ativo na Meta) */
.switch { position: relative; width: 40px; height: 23px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--line); border-radius: 99px; cursor: pointer; transition: background .15s; }
.switch span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fafafa; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch input:checked + span { background: #16a34a; border-color: #16a34a; }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }
.switch input:focus-visible + span { outline: 2px solid var(--text-3); outline-offset: 2px; }

/* ---------- botões ---------- */
.btn { border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 8px 16px; cursor: pointer; min-height: 40px;
  font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(.92); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn svg { width: 15px; height: 15px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { filter: none; border-color: var(--text-3); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: 4px 11px; min-height: 32px; font-size: 13px; border-radius: 10px; }
.budget-btn { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 8px; padding: 3px 9px; cursor: pointer; font-variant-numeric: tabular-nums; color: var(--text); }
.budget-btn:hover:not(:disabled) { border-color: var(--text-2); }
.budget-btn:disabled { cursor: default; border-color: transparent; background: none; }
.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 7px 13px; border-radius: 9px; cursor: pointer; color: var(--text-3); font-weight: 500; font-size: 13px; }
.segmented button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
@media (max-width: 900px) { .segmented { max-width: 100%; overflow-x: auto; } .segmented button { white-space: nowrap; } }

.crumbs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; color: var(--text-3); }
.crumbs button { background: none; border: 0; color: var(--text); cursor: pointer; padding: 0; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- campanhas no celular ---------- */
.camp-cards { display: none; }
@media (max-width: 700px) { .camp-table { display: none; } .camp-cards { display: grid; gap: 10px; } }
.camp-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; padding: 13px; background: var(--surface-2); }
.camp-card .head { display: flex; align-items: flex-start; gap: 10px; }
.camp-card .title { flex: 1; min-width: 0; }
.camp-card .title .linkish, .camp-card .title .nm { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camp-card .title .parent { display: block; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camp-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.camp-card .stat { min-width: 0; }
.camp-card .stat .k { font-size: 11px; color: var(--text-3); }
.camp-card .stat .v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camp-card .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--text-3); }
.camp-card .foot .grow { flex: 1; }
.mobile-only { display: none; }
@media (max-width: 700px) { .mobile-only { display: inline-block; } }

/* ---------- formulários ---------- */
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.form-row .input { flex: 1; min-width: 180px; }
label.field { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 12px; }
code.block { display: block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 6px 0 12px; }
pre.json { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.tabs-row { margin-bottom: 14px; flex-wrap: wrap; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
.auth-brand { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line);
  background: radial-gradient(800px 600px at 0% 100%, rgba(150,52,22,.28), transparent 60%), radial-gradient(700px 500px at 100% 0%, rgba(120,36,30,.18), transparent 60%), #060606; }
.auth-brand .watermark { position: absolute; right: -120px; bottom: 40px; width: 720px; opacity: .06; pointer-events: none; }
.auth-brand .watermark path { fill: #fff; }
.auth-brand > *:not(.watermark) { position: relative; z-index: 1; }
.auth-brand h2 { font-size: 42px; line-height: 1.06; letter-spacing: -.04em; margin: 0 0 16px; max-width: 540px; color: #fafafa; font-weight: 600; }
.auth-brand h2 em { font-style: normal; color: #a1a1aa; }
.auth-brand p { color: #a1a1aa; max-width: 470px; margin: 0; font-size: 15px; }
.auth-features { display: grid; gap: 12px; margin-top: 30px; }
.auth-features div { display: flex; gap: 10px; align-items: center; color: #d4d4d8; }
.auth-features svg { width: 17px; height: 17px; color: #fafafa; flex: none; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form .card { width: 100%; max-width: 410px; padding: 32px; }
.auth-form h1 { font-size: 24px; letter-spacing: -.03em; margin: 0 0 4px; font-weight: 600; }
.auth-form .input { width: 100%; min-height: 46px; }
.auth-form .btn { width: 100%; margin-top: 8px; min-height: 48px; font-size: 15px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: calc(26px + env(safe-area-inset-top)) 22px 26px; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-brand h2 { font-size: 28px; }
  .auth-brand .watermark { width: 420px; right: -110px; bottom: -20px; }
  .auth-features { display: none; }
  .auth-form { align-items: start; padding: 22px 14px 40px; }
  .auth-form .card { padding: 22px; }
}
.error { color: var(--bad-ink); font-size: 13px; min-height: 18px; }

/* ---------- gráficos ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--text-3); stroke-width: 1; opacity: .5; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .endlabel { fill: var(--text-2); font-size: 12px; font-weight: 500; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.hatch { background-image: repeating-linear-gradient(45deg, var(--neg) 0 2px, transparent 2px 4px) !important; border: 1px solid var(--neg); }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: color-mix(in srgb, var(--surface-3) 94%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.45); min-width: 150px; }
.tooltip .t { color: var(--text-3); margin-bottom: 5px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip .row span:first-child { color: var(--text-2); font-weight: 400; }
.tooltip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.funnel { display: grid; gap: 13px; }
.funnel .step { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 13px; }
.funnel .bar { grid-column: 1 / -1; height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.funnel .bar div { height: 100%; background: var(--series-1); border-radius: 99px; min-width: 3px; }
.funnel .rate { color: var(--text-3); font-size: 12px; margin-left: 4px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface-2); border-radius: 18px; padding: 22px; width: 100%; max-width: 440px; border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.modal h3 { margin: 0 0 8px; font-size: 17px; font-weight: 600; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
@media (max-width: 600px) {
  .modal-bg { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
  .modal .actions .btn { flex: 1; min-height: 48px; }
}
.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; }
@media (max-width: 900px) { .toast-wrap { bottom: calc(92px + env(safe-area-inset-bottom)); left: 16px; } }
.toast { background: var(--surface-3); color: var(--text); border: 1px solid var(--line); border-left: 3px solid var(--good); padding: 11px 14px; border-radius: 12px; font-size: 13px; box-shadow: 0 10px 28px rgba(0,0,0,.45); }
.toast.err { border-left-color: var(--bad); }

.empty { text-align: center; padding: 30px 12px; color: var(--text-3); }
.skeleton { color: var(--text-3); padding: 48px 0; text-align: center; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); border-radius: 12px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px; }
.notice a { color: inherit; }
@media (prefers-reduced-motion: reduce) { *, *::after { transition: none !important; animation: none !important; } }

/* ajustes finos */
.delta { font-size: 12px; color: var(--text-3); }
.profit-card .delta { margin-top: 2px; }
:root[data-theme="light"] .goal .bar div,
:root[data-theme="light"] .trophy .progress-foot .bar div { background: linear-gradient(90deg, #52525b, #09090b); }
:root[data-theme="light"] .goal .bar div.done { background: linear-gradient(90deg, #15803d, #22c55e); }

/* seleção estilo Gerenciador de Anúncios */
.pick { width: 17px; height: 17px; accent-color: #16a34a; cursor: pointer; margin: 0; vertical-align: middle; }
tbody tr.selected td { background: color-mix(in srgb, var(--surface-2) 70%, rgba(34,197,94,.08)); }
.level-tabs .count { font-size: 11px; font-weight: 600; opacity: .75; margin-left: 2px; }
.sel-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.sel-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 320px; padding: 4px 6px 4px 10px; border-radius: 99px;
  background: var(--surface-3); border: 1px solid var(--line); font-size: 12px; font-weight: 500; }
.sel-chip svg { width: 13px; height: 13px; color: var(--text-3); flex: none; }
.sel-chip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-chip button { border: 0; background: var(--surface-2); color: var(--text-2); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; line-height: 1; flex: none; }
.sel-chip button:hover { color: var(--text); }
.camp-card .head .pick { margin-top: 2px; }

/* conferência do dia */
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .grid-4 { grid-template-columns: 1fr; } }

/* =====================================================================
   Tema "Gotham" (escuro): noite fria, luar prateado, brasa carmesim.
   Só o tema escuro muda; o claro continua igual. Verde/violeta seguem só nos dados.
   ===================================================================== */
:root:not([data-theme="light"]) {
  --bg: #020203;
  --bg-glow:
    radial-gradient(700px 520px at 92% -8%, rgba(150, 165, 195, .09), transparent 62%),   /* luar */
    radial-gradient(900px 640px at -10% 110%, rgba(120, 8, 18, .22), transparent 60%),    /* brasa */
    radial-gradient(1200px 800px at 50% 50%, transparent 55%, rgba(0, 0, 0, .55) 100%);   /* vinheta */
  --surface: #08080a;
  --surface-2: #0d0d10;
  --surface-3: #141418;
  --line: #1b1b21;
  --line-soft: #121216;
  --grid: #141418;
  --text: #ececf1;
  --text-2: #9b9ba8;
  --text-3: #62626e;
  --accent: #d6d8df;
  --accent-strong: #f2f3f6;
  --accent-ink: #050506;
  --accent-soft: rgba(214, 216, 223, .06);
  --blood: #b3121b;
  --blood-glow: rgba(179, 18, 27, .35);
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 18px 40px rgba(0,0,0,.6);
}

/* morcego gigante, quase invisível, ao fundo */
:root:not([data-theme="light"]) body::after {
  content: ''; position: fixed; right: -6vw; bottom: -4vh; width: 62vw; max-width: 980px; aspect-ratio: 100 / 46;
  pointer-events: none; z-index: 0; opacity: .035;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 6 100 46'%3E%3Cpath fill='%23ffffff' d='M50 20 L54 13 L57.5 22 L97 10 L88 29 L78 25 L72 36 L62 31 L56 40 L50 49 L44 40 L38 31 L28 36 L22 25 L12 29 L3 10 L42.5 22 L46 13 Z'/%3E%3C/svg%3E");
}
:root:not([data-theme="light"]) #root { position: relative; z-index: 1; }

/* marca: morcego prateado sobre preto, com brasa por trás */
:root:not([data-theme="light"]) .brand-mark {
  background: radial-gradient(circle at 50% 120%, rgba(179, 18, 27, .45), transparent 65%), linear-gradient(160deg, #16161a, #050506);
  color: #e4e6ec; box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset, 0 0 22px rgba(179, 18, 27, .25), 0 10px 28px rgba(0,0,0,.7);
}

/* títulos com serifa clássica, em versalete prateado */
:root:not([data-theme="light"]) .topbar h1 {
  font-family: Cinzel, "Trajan Pro", Georgia, serif; font-weight: 700; letter-spacing: .04em; font-size: 26px;
  background: linear-gradient(180deg, #f5f6f9 20%, #8f93a0); -webkit-background-clip: text; background-clip: text; color: transparent;
}
@media (max-width: 900px) { :root:not([data-theme="light"]) .topbar h1 { font-size: 17px; letter-spacing: .03em; } }
:root:not([data-theme="light"]) .topbar { border-bottom-color: transparent;
  background: linear-gradient(90deg, transparent, rgba(179, 18, 27, .25), transparent) bottom / 100% 1px no-repeat; }
@media (max-width: 900px) { :root:not([data-theme="light"]) .topbar { background-color: color-mix(in srgb, var(--bg) 85%, transparent); } }

/* trilho: item ativo com risco carmesim */
:root:not([data-theme="light"]) .rail { background: color-mix(in srgb, #050506 80%, transparent); }
:root:not([data-theme="light"]) .navlink.active::before { background: var(--blood); box-shadow: 0 0 12px var(--blood-glow); }
:root:not([data-theme="light"]) .navlink.active { color: #fff; }
:root:not([data-theme="light"]) .tabbar button.active { box-shadow: 0 -2px 0 var(--blood) inset; }

/* cartões: aço escuro com fio de luar no topo */
:root:not([data-theme="light"]) .card {
  background:
    linear-gradient(90deg, transparent, rgba(200, 210, 230, .10), transparent) top / 100% 1px no-repeat,
    linear-gradient(180deg, #0b0b0e, #070709);
}

/* botões: prata fosca; foco e seleção com brasa */
:root:not([data-theme="light"]) .btn:not(.ghost):not(.danger) { background: linear-gradient(180deg, #e9eaef, #b9bcc6); color: #050506; }
:root:not([data-theme="light"]) .chip.active { background: linear-gradient(180deg, #e9eaef, #b9bcc6); border-color: transparent; }
:root:not([data-theme="light"]) :focus-visible { outline: 1px solid var(--blood); outline-offset: 2px; }
:root:not([data-theme="light"]) .input:focus, :root:not([data-theme="light"]) .select-pill:focus-within { border-color: rgba(179, 18, 27, .6); outline: none; }
:root:not([data-theme="light"]) ::selection { background: rgba(179, 18, 27, .45); color: #fff; }
:root:not([data-theme="light"]) .eyebrow::before { background: var(--blood); box-shadow: 0 0 8px var(--blood-glow); }

/* rolagem discreta */
:root:not([data-theme="light"]) { scrollbar-color: #26262d transparent; }

/* login: lua cheia atrás do morcego */
:root:not([data-theme="light"]) .auth-brand {
  background:
    radial-gradient(260px 260px at 78% 30%, rgba(220, 225, 235, .10), rgba(220, 225, 235, .03) 55%, transparent 70%),
    radial-gradient(700px 500px at 0% 100%, rgba(120, 8, 18, .25), transparent 60%), #030304;
}
:root:not([data-theme="light"]) .auth-brand h2 { font-family: Cinzel, Georgia, serif; letter-spacing: .01em; }
/* a tela de login já tem o próprio morcego */
:root:not([data-theme="light"]) body:has(.auth)::after { display: none; }
