/* ==========================================================================
   HÓRUS · Design system
   Identidade Bradus: roxo #784EDE, Poppins (no lugar da Nexa), números em
   Space Grotesk. Tudo deriva dos tokens abaixo: nenhuma cor, raio ou espaço
   solto nos componentes. Ordem: tokens → base → layout → componentes → telas.
   ========================================================================== */

/* -------------------------------------------------------------- 1. Tokens */
:root {
  /* cor · superfícies (claro) */
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f4f1fc;          /* trilhos, cabeçalho de tabela, campos */
  --surface-3: #ebe6f8;          /* hover sobre surface-2 */
  --line: #e6e1f1;
  --line-strong: #d3cbe6;
  --text: #1b1630;
  --muted: #6a6584;
  --faint: #9a95ad;

  /* cor · marca */
  --brand: #784ede;
  --brand-ink: #5f34c4;          /* roxo para texto/links sobre fundo claro */
  --brand-weak: rgba(120, 78, 222, .11);
  --brand-line: rgba(120, 78, 222, .35);
  --on-brand: #ffffff;

  /* cor · semântica (status). Não usar como cor de canal ou de série. */
  --good: #0f8a5f;   --good-weak: rgba(15, 138, 95, .10);
  --warn: #b26a00;   --warn-weak: rgba(178, 106, 0, .11);
  --bad:  #cf3650;   --bad-weak:  rgba(207, 54, 80, .10);
  --on-bad: #ffffff;

  /* faixa-assinatura (escura nos dois temas) */
  --hero-ink: #ffffff;
  --hero-muted: rgba(205, 190, 246, .86);
  --hero-good: #7ee6a8;
  --hero-bad: #ffb0b8;
  --hero-chip: rgba(255, 255, 255, .09);
  --hero-chip-line: rgba(255, 255, 255, .13);
  --hero-track: rgba(255, 255, 255, .13);

  /* tipografia */
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", "Poppins", -apple-system, sans-serif;
  --t-2xs: 10.5px;  /* rótulos de eixo, legendas mínimas */
  --t-xs: 11.5px;   /* rótulos de métrica */
  --t-sm: 12.5px;   /* texto secundário, botões pequenos */
  --t-base: 14px;   /* corpo, tabelas */
  --t-md: 15px;     /* títulos de painel */
  --t-lg: 18px;     /* valores de métrica */
  --t-xl: 22px;     /* valores de destaque */
  --t-2xl: 26px;    /* manchete da faixa */
  --t-hero: clamp(34px, 5vw, 52px);

  /* espaço (escala de 4) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* raio: o tamanho acompanha a hierarquia (controle < card < faixa) */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-pill: 999px;

  /* sombra */
  --sh-1: 0 1px 2px rgba(40, 24, 90, .06), 0 1px 3px rgba(40, 24, 90, .06);
  --sh-2: 0 8px 24px rgba(40, 24, 90, .12);
  --sh-3: 0 20px 48px rgba(20, 10, 40, .30);

  /* foco, movimento, camadas */
  --ring: 0 0 0 3px rgba(120, 78, 222, .35);
  --ease: cubic-bezier(.3, 0, .1, 1);
  --dur: .16s;
  --z-top: 10; --z-menu: 20; --z-overlay: 100;

  color-scheme: light;
}

/* cor · escuro (segue o sistema; o botão de tema vence pelos blocos [data-theme]) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0b16; --surface: #17131f; --surface-2: #1e1929; --surface-3: #262035;
    --line: #2b2541; --line-strong: #3a3256; --text: #ece9f6; --muted: #9d97b2; --faint: #6f6987;
    --brand: #9b7ff0; --brand-ink: #b8a2f6; --brand-weak: rgba(155, 127, 240, .16); --brand-line: rgba(155, 127, 240, .42);
    --good: #4fd69c; --good-weak: rgba(79, 214, 156, .12);
    --warn: #f2b54a; --warn-weak: rgba(242, 181, 74, .12);
    --bad:  #ff7d8f; --bad-weak:  rgba(255, 125, 143, .12); --on-bad: #2a0912;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .5); --sh-2: 0 10px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0b16; --surface: #17131f; --surface-2: #1e1929; --surface-3: #262035;
  --line: #2b2541; --line-strong: #3a3256; --text: #ece9f6; --muted: #9d97b2; --faint: #6f6987;
  --brand: #9b7ff0; --brand-ink: #b8a2f6; --brand-weak: rgba(155, 127, 240, .16); --brand-line: rgba(155, 127, 240, .42);
  --good: #4fd69c; --good-weak: rgba(79, 214, 156, .12);
  --warn: #f2b54a; --warn-weak: rgba(242, 181, 74, .12);
  --bad:  #ff7d8f; --bad-weak:  rgba(255, 125, 143, .12); --on-bad: #2a0912;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .5); --sh-2: 0 10px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* --------------------------------------------------------------- 2. Base */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--t-base)/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { text-wrap: balance; }
::selection { background: var(--brand-weak); }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
button { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
svg { flex-shrink: 0; }

/* números: sempre em Space Grotesk tabular, pra alinhar e comparar */
.num, td.num, .m-value, .lucro-val, .vchip .n, .hz .vl, .ls .v, .rx-v, .rm-v, .sc-rev .v,
.ml-v, .ml-p, .fn-nm b, .fn-pc, .fn-cu, .kpi .value, .dl-val {
  font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}

.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.na { color: var(--faint); }

/* ------------------------------------------------------------- 3. Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: 0 0 236px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; padding: var(--s-5) var(--s-3);
  background: var(--surface); border-right: 1px solid var(--line);
}
.side-logo { padding: var(--s-1) var(--s-2) 0; }
.side-logo .logo { height: 26px; width: auto; display: block; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; } :root[data-theme="dark"] .logo-dark { display: block; }
:root[data-theme="light"] .logo-light { display: block; } :root[data-theme="light"] .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.side-product { font-weight: 700; font-size: var(--t-md); padding: var(--s-3) var(--s-2) var(--s-4); line-height: 1.1; }
.side-product span { display: block; margin-top: 3px; font-size: var(--t-2xs); font-weight: 500; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.side-nav { display: flex; flex-direction: column; gap: var(--s-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 10px var(--s-3);
  border: 0; border-radius: var(--r-md); background: transparent; color: var(--muted);
  font-weight: 600; font-size: var(--t-base); text-align: left; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item .ico { display: inline-flex; }
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--brand); color: var(--on-brand); box-shadow: 0 6px 16px -8px var(--brand); }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-4) var(--s-2) var(--s-1); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-top); display: flex; align-items: center; gap: var(--s-4);
  min-height: 54px; padding: 0 var(--s-6);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: var(--s-2); min-width: 0; font-size: var(--t-base); color: var(--muted); }
.crumb-btn { border: 0; background: none; padding: 2px 0; color: var(--brand-ink); cursor: pointer; font-size: inherit; white-space: nowrap; }
.crumb-btn:hover { text-decoration: underline; }
.crumbs > span:last-child { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-sep { color: var(--faint); }
#app { flex: 1; width: 100%; max-width: 1240px; padding: var(--s-5) var(--s-6) var(--s-10); }
.foot { padding: 0 var(--s-6) var(--s-6); color: var(--faint); font-size: var(--t-sm); }

/* celular: menu vira barra superior só com ícones (o nome continua para leitor de tela) */
@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; z-index: var(--z-menu); width: auto; flex: none; height: auto;
    flex-direction: row; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-4);
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side-logo { padding: 0; margin-right: auto; }
  .side-logo .logo { height: 20px; }
  .side-product, .side-foot .badge { display: none; }
  .side-nav { flex-direction: row; gap: 2px; }
  .nav-item { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .nav-item .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .side-foot { margin: 0; padding: 0; }
  .topbar { position: static; padding: 0 var(--s-4); min-height: 44px; }
  #app { padding: var(--s-4) var(--s-4) var(--s-8); }
  .foot { padding: 0 var(--s-4) var(--s-5); }
}

/* --------------------------------------------------------- 4. Componentes */

/* 4.1 Botões. .period-btn é o botão padrão (secundário); .area-btn/.dlg-ok o primário */
.period-btn, .act-btn, .area-btn, .dlg-ok, .theme-toggle, .idle-item {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: var(--t-sm); font-weight: 500; line-height: 1.2;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; touch-action: manipulation;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.period-btn:hover, .act-btn:hover, .idle-item:hover, .theme-toggle:hover { border-color: var(--brand-line); color: var(--brand-ink); }
.period-btn.on, .area-btn, .dlg-ok { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.period-btn.on:hover, .area-btn:hover, .dlg-ok:hover { filter: brightness(1.08); color: var(--on-brand); }
.dlg-ok.danger, .dlg-ok.danger:hover { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.period-btn:disabled { opacity: .45; cursor: not-allowed; }
.period-btn:disabled:hover { border-color: var(--line); color: var(--text); }
.act-btn { padding: 4px 9px; font-size: var(--t-xs); border-radius: var(--r-xs); }
.theme-toggle { width: 34px; height: 34px; padding: 0; border-radius: var(--r-md); background: var(--surface-2); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.refresh-btn { margin-left: auto; border-color: var(--brand-line); color: var(--brand-ink); font-weight: 600; }
.refresh-btn:hover { background: var(--brand-weak); }
.refresh-btn.spinning { opacity: .7; pointer-events: none; }
button.drill {
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
  color: var(--brand-ink); font-weight: 500; font-size: inherit; line-height: 1.35;
}
button.drill:hover { text-decoration: underline; }

/* 4.2 Selos (status) e etiquetas (categoria) */
.pill, .badge, .src {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: var(--t-2xs); font-weight: 600; line-height: 1.5;
  padding: 1px 8px; border-radius: var(--r-pill); border: 1px solid var(--line); color: var(--muted);
}
.pill.active, .badge.live, .src.live { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: var(--good-weak); }
.pill.paused, .pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-weak); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-weak); }
.badge { text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
.type-tag, .obj-pill {
  display: inline-block; font-size: var(--t-2xs); font-weight: 600; color: var(--brand-ink);
  background: var(--brand-weak); border-radius: var(--r-pill); padding: 1px 9px;
}
.type-tag { align-self: flex-start; margin-bottom: var(--s-3); }
.lock-chip {
  font-size: var(--t-xs); font-weight: 600; color: var(--warn); background: var(--warn-weak);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: var(--r-pill); padding: 4px 10px;
}

/* 4.3 Campos */
.fld { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm); color: var(--muted); margin-bottom: var(--s-3); }
.fld input, .type-sel select, .period-btns input[type="date"] {
  font: inherit; font-size: var(--t-base); color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 11px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.fld input:focus, .type-sel select:focus, .period-btns input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.type-sel { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); color: var(--muted); }
.type-sel select { font-weight: 600; cursor: pointer; }
.fld-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.toggle, .chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--muted);
  padding: 6px 11px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.toggle.on, .chip.on { border-color: var(--brand-line); color: var(--brand-ink); background: var(--brand-weak); }
.toggle input, .chip input { accent-color: var(--brand); }

/* 4.4 Barra de período */
.controls { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin: 0 0 var(--s-4); }
.cta-period { flex: 1; min-width: 0; }
.ctrl-right { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.period-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period-btns .custom[hidden] { display: none; }
.period-btns .custom { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--faint); margin-left: var(--s-1); }
.period-btns input[type="date"] { font-size: var(--t-sm); padding: 6px 8px; min-width: 0; }
.dt-err { flex-basis: 100%; font-size: var(--t-sm); }
.dt-err:empty { display: none; }

/* 4.5 Superfícies: card (clicável), painel (seção), tabela */
.card {
  display: flex; flex-direction: column; align-items: stretch; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5); box-shadow: var(--sh-1); cursor: pointer;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { border-color: var(--brand-line); box-shadow: var(--sh-2); transform: translateY(-1px); }
.card .name { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); font-weight: 600; font-size: var(--t-md); }
.card .name .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3) var(--s-4); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-3); }
.metric .m-label { font-size: var(--t-xs); color: var(--muted); }
.metric .m-value { font-size: var(--t-lg); font-weight: 600; }
.metric .m-value.good { color: var(--good); } .metric .m-value.bad { color: var(--bad); } .metric .m-value.na { color: var(--faint); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-5); box-shadow: var(--sh-1); margin-top: var(--s-4); min-width: 0;
}
.panel h3 { margin: 0 0 var(--s-4); font-size: var(--t-md); font-weight: 600; }
.panel h3 .muted { font-weight: 400; font-size: var(--t-sm); }
.panel .chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.panel .vchip { display: inline-flex; gap: 6px; font-size: var(--t-sm); padding: 5px 11px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface-2); }
.panel .vchip .k { color: var(--muted); }
.panel .vchip .n { font-weight: 600; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: var(--t-base); white-space: nowrap; vertical-align: middle; }
th { font-size: var(--t-xs); font-weight: 600; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--dur) var(--ease); }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.num, th.num { text-align: right; min-width: 76px; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-1); background: var(--surface); }
.panel .tbl-wrap { box-shadow: none; }
.col-name, thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); border-right: 1px solid var(--line); }
thead th:first-child { z-index: 2; background: var(--surface-2); }
.col-name { white-space: normal; min-width: 200px; max-width: 340px; }
td .sub, .name-meta .sub { font-size: var(--t-xs); color: var(--muted); }
.name-meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-top: 4px; }
td.res { font-size: var(--t-sm); }
td.res b { font-family: var(--display); font-weight: 600; font-size: var(--t-base); }
.acts { display: inline-flex; gap: 6px; justify-content: flex-end; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; vertical-align: 1px; }

/* 4.6 Títulos de seção */
h2 { margin: var(--s-8) 0 var(--s-3); font-size: var(--t-md); font-weight: 600; color: var(--text); }
h2 .muted { font-weight: 400; font-size: var(--t-sm); }

/* 4.7 Diálogo, aviso, alerta */
.dlg {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--sh-3); overscroll-behavior: contain;
}
.dlg::backdrop { background: rgba(10, 6, 20, .55); backdrop-filter: blur(2px); }
.dlg form { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); }
.dlg-t { margin: 0; font-size: var(--t-lg); font-weight: 600; }
.dlg-b p { margin: 0 0 4px; }
.dlg-hint { margin: -4px 0 0; min-height: 1.4em; font-size: var(--t-sm); color: var(--muted); }
.dlg-a { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-1); }
.dlg-a .period-btn, .dlg-a .dlg-ok { padding: 9px 16px; font-size: var(--t-base); }
#toasts { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-overlay); display: flex; flex-direction: column; gap: var(--s-2); max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: var(--r-md);
  box-shadow: var(--sh-2); padding: var(--s-3) var(--s-4); font-size: var(--t-sm);
}
.toast.ok { border-left-color: var(--good); } .toast.err { border-left-color: var(--bad); }

/* 4.8 Carregamento */
.loading { color: var(--muted); padding: var(--s-10) 0; text-align: center; }
.sk { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; }
.sk-hero { height: 210px; margin-bottom: var(--s-6); border-radius: var(--r-xl); }
.sk-hero.sm { height: 150px; }
.sk-card { height: 150px; }
.sk-table { height: 280px; border-radius: var(--r-md); }
@media (prefers-reduced-motion: no-preference) { .sk { animation: skMove 1.4s linear infinite; } }
@keyframes skMove { to { background-position: -200% 0; } }

/* 4.9 Sparkline e donut (SVG) */
.spark { display: block; width: 100%; height: 40px; }
.donut-wrap { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: var(--s-2); font-size: var(--t-sm); min-width: 150px; }
.dl-row { display: flex; align-items: center; gap: var(--s-2); }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; }
.dl-name { color: var(--muted); }
.dl-val { margin-left: auto; font-weight: 600; }

/* ------------------------------------------------------- 5. Padrões de tela */

/* 5.1 Faixa-veredito: a assinatura do HÓRUS (escura nos dois temas) */
.veredito {
  position: relative; overflow: hidden; isolation: isolate; color: var(--hero-ink);
  border-radius: var(--r-xl); padding: var(--s-8) var(--s-8) 28px; margin: 0 0 var(--s-6);
  border: 1px solid rgba(255, 255, 255, .07);
  background:
    radial-gradient(130% 150% at 90% -10%, rgba(168, 133, 242, .46), transparent 52%),
    radial-gradient(90% 130% at -5% 110%, rgba(72, 38, 143, .6), transparent 60%),
    linear-gradient(118deg, #2a1550 0%, #1c0f38 58%, #150a2a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 18px 44px rgba(20, 10, 40, .28);
}
.veredito .eyebrow { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-bottom: var(--s-4);
  font-size: var(--t-xs); font-weight: 600; letter-spacing: .08em; color: var(--hero-muted); }
.veredito .eyebrow .pt { width: 6px; height: 6px; border-radius: 50%; background: #9a76ec; box-shadow: 0 0 10px 1px rgba(154, 118, 236, .9); }
.veredito .eyebrow .src { color: var(--hero-muted); border-color: var(--hero-chip-line); background: var(--hero-chip); letter-spacing: 0; }
.veredito-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-5) 44px; align-items: end; }
.veredito .headline { font-size: var(--t-2xl); font-weight: 600; line-height: 1.12; letter-spacing: -.02em; margin-bottom: var(--s-4); max-width: 24ch; }
.veredito .headline b { color: #cdbcf7; font-weight: 700; }
.veredito .lucro-rot { font-size: var(--t-xs); font-weight: 600; letter-spacing: .06em; color: var(--hero-muted); }
.veredito .lucro-val { font-size: var(--t-hero); font-weight: 600; line-height: 1; margin-top: 6px; color: var(--hero-ink); }
.veredito .chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-5); }
.veredito .vchip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--hero-chip); border: 1px solid var(--hero-chip-line); font-size: var(--t-sm); font-weight: 600; color: rgba(255, 255, 255, .92); }
.veredito .vchip .k { color: var(--hero-muted); font-weight: 500; }
.veredito .vchip.up, .veredito .vchip.up .k { color: var(--hero-good); }
.veredito .vchip.down, .veredito .vchip.down .k { color: var(--hero-bad); }
.veredito.sub { padding: var(--s-6) 28px; margin-bottom: var(--s-5); }
.veredito.sub .headline { font-size: 21px; margin-bottom: var(--s-3); }
.veredito.sub .lucro-val { font-size: clamp(30px, 4vw, 40px); }

/* barras horizontais da faixa (investimento por conta / campanha) */
.veredito .hz-bars { display: flex; flex-direction: column; gap: 9px; width: 290px; max-width: 44vw; }
.veredito .hz { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px var(--s-2); align-items: center; }
.veredito .hz .nm { font-size: var(--t-xs); font-weight: 600; color: rgba(255, 255, 255, .86); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.veredito .hz .vl { font-size: var(--t-xs); font-weight: 600; color: rgba(255, 255, 255, .64); }
.veredito .hz .track { grid-column: 1 / -1; height: 6px; border-radius: 5px; background: var(--hero-track); overflow: hidden; }
.veredito .hz .track > span { display: block; height: 100%; border-radius: 5px; }
.veredito .cap { margin-top: var(--s-3); text-align: right; font-size: var(--t-2xs); font-weight: 600; letter-spacing: .06em; color: var(--hero-muted); }

@media (prefers-reduced-motion: no-preference) {
  .veredito { animation: horusIn .4s var(--ease); }
  .veredito .hz .track > span, .veredito .mix-bar i { transform-origin: left; animation: grow .9s var(--ease) .15s both; }
}
@keyframes horusIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes grow { from { transform: scaleX(0); } }
@media (max-width: 860px) {
  .veredito { padding: var(--s-6) var(--s-5); }
  .veredito-grid { grid-template-columns: 1fr; align-items: start; }
  .veredito .hz-bars { width: 100%; max-width: 100%; }
  .veredito .cap { text-align: left; }
  .veredito .headline { font-size: 22px; }
}

/* 5.2 Tira de resumo (conjuntos / anúncios) */
.lvl-stats { display: flex; flex-wrap: wrap; overflow: hidden; margin: 0 0 var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-1); }
.lvl-stats .ls { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 2px; padding: var(--s-3) var(--s-4); border-right: 1px solid var(--line); }
.lvl-stats .ls:last-child { border-right: none; }
.lvl-stats .ls .l { font-size: var(--t-xs); color: var(--muted); }
.lvl-stats .ls .v { font-size: var(--t-lg); font-weight: 600; }
.lvl-stats .ls .v.good { color: var(--good); } .lvl-stats .ls .v.bad { color: var(--bad); }

/* 5.3 Cabeçalho da conta + funil (barra = taxa de passagem da etapa) */
.acct-head { display: flex; flex-direction: column; gap: var(--s-4); margin: 0 0 var(--s-2); padding: var(--s-5);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.funnel-title { font-size: var(--t-md); font-weight: 600; }
.fn-head { margin: 0 0 var(--s-3); font-size: var(--t-base); }
.funnel { display: flex; flex-direction: column; }
.fn-step { display: grid; grid-template-columns: minmax(130px, 1.1fr) minmax(0, 2.4fr) 96px; gap: var(--s-4); align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line); }
.fn-step:first-child { border-top: none; }
.fn-nm b { display: block; font-size: var(--t-lg); font-weight: 600; line-height: 1.2; }
.fn-nm span { font-size: var(--t-xs); color: var(--muted); }
.fn-mid { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.fn-tr { position: relative; flex: 1; height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.fn-tr i { position: absolute; inset: 0 auto 0 0; border-radius: var(--r-pill); background: var(--brand); }
.fn-pc { font-weight: 600; font-size: var(--t-base); min-width: 52px; text-align: right; }
.fn-note { font-size: var(--t-sm); }
.fn-cu { text-align: right; font-size: var(--t-base); }
.fn-cu span { display: block; font-family: var(--font); font-size: var(--t-2xs); color: var(--faint); }
.fn-step.worst .fn-tr i { background: var(--bad); }
.fn-step.worst .fn-pc { color: var(--bad); }
@media (max-width: 620px) { .fn-step { grid-template-columns: 1fr 72px; } .fn-mid { grid-column: 1 / -1; grid-row: 2; } }

/* menu de métricas */
.metric-menu { position: relative; }
.metric-menu > summary { list-style: none; cursor: pointer; padding: 6px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-size: var(--t-sm); user-select: none; }
.metric-menu > summary::-webkit-details-marker { display: none; }
.metric-menu[open] > summary { border-color: var(--brand-line); color: var(--brand-ink); }
.metric-menu .chips { position: absolute; right: 0; z-index: var(--z-menu); margin-top: var(--s-2); width: 300px; padding: var(--s-3);
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-2); }

/* contas sem veiculação (recolhido) */
.idle { margin-top: var(--s-4); }
.idle > summary { cursor: pointer; color: var(--muted); font-size: var(--t-sm); padding: var(--s-2) 0; }
.idle-list { display: flex; flex-wrap: wrap; gap: var(--s-2); padding-top: var(--s-2); }
.idle-item { gap: var(--s-2); color: var(--muted); }

/* criativo (nível de anúncio) */
.ad-cell { display: flex; align-items: center; gap: 10px; }
.ad-thumb-btn { border: 0; padding: 0; background: none; border-radius: var(--r-sm); cursor: zoom-in; }
.ad-thumb { width: 46px; height: 46px; flex: 0 0 auto; display: block; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); }
.ad-thumb.ph { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); cursor: zoom-in; }
.ad-thumb-btn:hover .ad-thumb, .ad-thumb.ph:hover { border-color: var(--brand); }
.ad-name { font-weight: 500; }

/* lightbox (prévia do anúncio) */
.lightbox { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; align-items: center; justify-content: center;
  padding: var(--s-6); background: rgba(10, 6, 20, .82); backdrop-filter: blur(3px); overscroll-behavior: contain; }
.lightbox img, .lightbox video { max-width: 90vw; max-height: 88vh; border-radius: var(--r-md); box-shadow: var(--sh-3); background: #000; }
.lightbox .lb-empty { color: #fff; }
.lightbox .lb-close { position: absolute; top: var(--s-4); right: var(--s-5); z-index: 2; width: 40px; height: 40px; border: 0; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 18px; cursor: pointer; }
.lightbox .lb-close:hover { background: rgba(255, 255, 255, .22); }
.lightbox .lb-card { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); }
.lightbox .lb-frame { overflow: hidden; border-radius: var(--r-md); background: #000; box-shadow: var(--sh-3); }
.lightbox .lb-frame iframe { display: block; border: 0; }
.lightbox .lb-open { color: #fff; background: var(--brand); padding: 10px 18px; border-radius: var(--r-md); text-decoration: none; font-weight: 600; }

/* 5.4 Delivery: mix de canais (próprio x marketplace) */
.deliv-hero { grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); align-items: center; }
.mix { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mix-groups { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--t-sm); color: var(--hero-muted); }
.mix-groups b { font-family: var(--display); font-size: var(--t-xl); font-weight: 600; color: var(--hero-ink); margin-right: 4px; }
.mix-groups .mk { text-align: right; }
.mix-bar { display: flex; gap: 2px; height: 14px; border-radius: var(--r-pill); overflow: hidden; background: var(--hero-track); }
.mix-bar i { display: block; min-width: 3px; }
.mix-bar.thin { height: 8px; background: var(--surface-2); }
.mix-legend { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s-1); }
.ml-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 38px; gap: var(--s-2); align-items: center; font-size: var(--t-sm); }
.ml-row i { width: 10px; height: 10px; border-radius: 3px; }
.ml-n { color: rgba(255, 255, 255, .86); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-v { color: var(--hero-ink); font-weight: 600; }
.ml-p { color: var(--hero-muted); text-align: right; }
@media (max-width: 860px) { .deliv-hero { grid-template-columns: 1fr; } }

/* vitrine de lojas */
/* colunas fixas por largura: 6 lojas fecham 3×2 ou 2×3, sem card sozinho na linha */
.store-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: var(--s-3); }
@media (max-width: 1100px) { .store-grid { grid-template-columns: repeat(min(var(--cols, 3), 2), minmax(0, 1fr)); } }
@media (max-width: 620px) { .store-grid { grid-template-columns: 1fr; } }
.store-card {
  display: flex; flex-direction: column; gap: 10px; width: 100%; min-width: 0; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5);
  box-shadow: var(--sh-1); color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.store-card:hover { border-color: var(--brand-line); box-shadow: var(--sh-2); transform: translateY(-1px); }
.sc-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.sc-name { font-weight: 600; font-size: var(--t-md); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-rev { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.sc-rev .v { font-size: var(--t-xl); font-weight: 600; line-height: 1.1; white-space: nowrap; }
.sc-rev .share { white-space: nowrap; flex-shrink: 0; }
.sc-rev .share { font-size: var(--t-xs); font-weight: 600; color: var(--brand-ink); background: var(--brand-weak); border-radius: var(--r-pill); padding: 1px 8px; }
.sc-sub { font-size: var(--t-sm); color: var(--muted); }
.sc-mix { display: flex; flex-direction: column; gap: 5px; }
.sc-mixcap { display: flex; justify-content: space-between; font-size: var(--t-xs); color: var(--muted); }
.sc-spark { display: block; min-height: 40px; margin-top: auto; }
.sc-note { font-size: var(--t-xs); line-height: 40px; }

/* matriz loja x canal */
.mtx th .dot { vertical-align: 0; }
.mtx td.num { font-weight: 600; min-width: 92px; }
.mtx td.na { font-weight: 400; }

/* tela da loja: tabela de canais */
.ch-tbl .ch { display: inline-flex; align-items: center; font-weight: 500; }
.ch-tbl .grp { margin-left: var(--s-2); font-size: var(--t-2xs); color: var(--faint); }
.cw-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s-4); }
.cw-grid > .panel { margin-top: var(--s-4); }
@media (max-width: 860px) { .cw-grid { grid-template-columns: 1fr; } }
.rev { display: flex; gap: 10px; padding: var(--s-2) 0; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.rev:last-child { border-bottom: none; }
.rev-stars { color: var(--warn); white-space: nowrap; }

/* 5.5 Gráfico de barras por dia */
.gc-wrap { position: relative; width: 100%; }
.gc { display: block; width: 100%; height: auto; overflow: visible; }
.gc-grid { stroke: var(--line); stroke-width: 1; }
.gc-ylab { fill: var(--faint); font: 500 10px var(--display); }
.gc-xlab { fill: var(--faint); font: 500 10px var(--font); }
.gc-bar { transition: opacity var(--dur) var(--ease); }
.gc-hit:hover + .gc-bar, .gc-bar:hover { opacity: .78; }
.gc-tip { position: absolute; z-index: 5; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: var(--t-xs); line-height: 1.35; padding: 6px 9px; border-radius: var(--r-sm); box-shadow: var(--sh-2); }
.gc-cap { font-size: var(--t-sm); margin-bottom: 6px; }

/* KPIs simples (tela de integrações e legado) */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4) var(--s-5); box-shadow: var(--sh-1); }
.kpi .label { font-size: var(--t-xs); color: var(--muted); }
.kpi .value { font-size: var(--t-xl); font-weight: 600; margin-top: 6px; }
@media (max-width: 720px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 5.6 Relatório do cliente */
.report-controls { align-items: flex-start; }
.rep-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-5); padding: var(--s-1) 2px var(--s-4); border-bottom: 2px solid var(--line); }
.rep-head .logo { height: 30px; margin-bottom: var(--s-3); }
.rep-title { font-family: var(--display); font-size: var(--t-2xl); font-weight: 700; }
.rep-sub { color: var(--muted); font-size: var(--t-md); margin-top: 2px; }
.rep-meta { text-align: right; font-size: var(--t-sm); }
.rep-exec { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin: var(--s-4) 0 var(--s-1); }
.rx { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5); box-shadow: var(--sh-1); }
.rx.accent { background: linear-gradient(135deg, #5f34c4 0%, #2a1550 100%); border-color: transparent; color: #fff; }
.rx.accent .rx-l, .rx.accent .rx-s { color: rgba(255, 255, 255, .82); }
.rx-l { font-size: var(--t-xs); color: var(--muted); }
.rx-v { font-size: var(--t-2xl); font-weight: 700; margin: 6px 0 2px; }
.rx-s { font-size: var(--t-xs); color: var(--muted); }
.rep-grid5 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); }
.rmini { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); }
.rm-l { font-size: var(--t-xs); color: var(--muted); }
.rm-v { font-size: var(--t-lg); font-weight: 600; margin-top: 4px; }
.rep-read ul { margin: 0 0 10px; padding-left: 18px; }
.rep-read li { margin-bottom: var(--s-2); }
.rep-foot-note { font-size: var(--t-xs); line-height: 1.5; border-top: 1px solid var(--line); padding-top: 10px; }
.rep-foot { text-align: center; color: var(--muted); font-size: var(--t-xs); padding: var(--s-5) 0 var(--s-1); }
@media (max-width: 720px) { .rep-exec, .rep-grid5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f4f2fb; --text: #1b1630; --muted: #5b5870; --line: #e2ddef; --sh-1: none; color-scheme: light; }
  .sidebar, .topbar, .foot, .controls, #crumbs { display: none !important; }
  #app { max-width: none; padding: 0; }
  .panel, .rx, .rep-exec, .rep-head { break-inside: avoid; box-shadow: none; }
  .logo-dark { display: none !important; } .logo-light { display: block !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------------------------------------------- 6. Fase 2: comparação e meta */

/* seta de variação contra o período anterior */
.delta { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; vertical-align: middle;
  font-family: var(--display); font-size: var(--t-2xs); font-weight: 600; line-height: 1.5;
  padding: 0 6px; border-radius: var(--r-pill); white-space: nowrap; }
.delta.up { color: var(--good); background: var(--good-weak); }
.delta.dn { color: var(--bad); background: var(--bad-weak); }
.delta.flat { color: var(--muted); background: var(--surface-2); }
.metric .delta { margin: 2px 0 0; }
.veredito .delta { font-size: var(--t-xs); }
.veredito .delta.up { color: var(--hero-good); background: rgba(126, 230, 168, .14); }
.veredito .delta.dn { color: var(--hero-bad); background: rgba(255, 176, 184, .14); }
.veredito .delta.flat { color: var(--hero-muted); background: var(--hero-chip); }
.veredito .lucro-val .delta { font-size: var(--t-sm); padding: 2px 9px; vertical-align: 10px; }
.veredito .eyebrow .cmp { font-weight: 500; letter-spacing: 0; opacity: .8; }

/* tarja de saúde no card (lado esquerdo) */
.card.h-good { box-shadow: inset 3px 0 0 var(--good), var(--sh-1); }
.card.h-warn { box-shadow: inset 3px 0 0 var(--warn), var(--sh-1); }
.card.h-bad  { box-shadow: inset 3px 0 0 var(--bad), var(--sh-1); }
.card.h-good:hover { box-shadow: inset 3px 0 0 var(--good), var(--sh-2); }
.card.h-warn:hover { box-shadow: inset 3px 0 0 var(--warn), var(--sh-2); }
.card.h-bad:hover  { box-shadow: inset 3px 0 0 var(--bad), var(--sh-2); }
.metric .m-value.warn, td.num.warn, .lvl-stats .ls .v.warn { color: var(--warn); }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s-3); }
.card .tags .type-tag { margin: 0; }
.tgt-tag { font-size: var(--t-2xs); font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 0 8px; line-height: 1.6; }

/* fila "Precisa de atenção" */
.attn { margin: 0 0 var(--s-2); padding: var(--s-4) var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.attn h3 { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); font-size: var(--t-md); font-weight: 600; }
.attn h3 .n { font-family: var(--display); font-size: var(--t-xs); color: var(--on-bad); background: var(--bad); border-radius: var(--r-pill); padding: 0 8px; line-height: 1.6; }
.attn.calm { padding: var(--s-3) var(--s-5); }
.attn.calm p { margin: 0; font-size: var(--t-sm); color: var(--muted); }
.attn-list { display: flex; flex-direction: column; }
.attn-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; width: 100%; text-align: left;
  padding: 10px var(--s-2); border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; border-radius: var(--r-sm); }
.attn-row:first-child { border-top: 0; }
.attn-row:hover { background: var(--surface-2); }
.attn-row .sev { width: 10px; height: 10px; border-radius: 50%; }
.sev.bad { background: var(--bad); } .sev.warn { background: var(--warn); } .sev.info { background: var(--brand); }
.at-txt { display: flex; flex-direction: column; min-width: 0; font-size: var(--t-sm); color: var(--muted); }
.at-txt b { color: var(--text); font-size: var(--t-base); font-weight: 600; }
.at-go { font-size: var(--t-sm); font-weight: 600; color: var(--brand-ink); }

/* campos da conta: tipo + meta */
.acct-fields { display: flex; align-items: center; gap: var(--s-3) var(--s-6); flex-wrap: wrap; }
.tgt-form { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.tgt-form input { width: 96px; font: inherit; font-size: var(--t-base); font-family: var(--display); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; }
.tgt-form input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.tgt-hint { font-size: var(--t-xs); }
