/* Painel Ortofoz — tokens de cor validados (dataviz reference palette) */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --card: #ffffff;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6; /* azul  — Google / série principal */
  --series-2: #eb6834; /* laranja — Meta */
  --ramp-250: #86b6ef; --ramp-350: #5598e7; --ramp-450: #2a78d6; --ramp-550: #1c5cab;
  --good-text: #006300;
  --bad-text: #b42318;
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b;
  --accent: #184f95;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 2px 8px rgba(11, 11, 11, 0.04);
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --card: #1a1a19;
    --text-1: #f0efec; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5; --series-2: #d95926;
    --ramp-250: #184f95; --ramp-350: #256abf; --ramp-450: #3987e5; --ramp-550: #86b6ef;
    --good-text: #0ca30c; --bad-text: #e66767;
    --accent: #86b6ef;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --card: #1a1a19;
  --text-1: #f0efec; --text-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5; --series-2: #d95926;
  --ramp-250: #184f95; --ramp-350: #256abf; --ramp-450: #3987e5; --ramp-550: #86b6ef;
  --good-text: #0ca30c; --bad-text: #e66767;
  --accent: #86b6ef;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text-1); }
body { font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--series-1); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.login-card h1 { font-size: 22px; margin: 22px 0 4px; }
.login-card p.sub { color: var(--text-2); margin: 0 0 22px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 550; font-size: 13px; color: var(--text-2); }
.field input { height: 42px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); padding: 0 12px; outline: none; }
.field input:focus { border-color: var(--series-1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--series-1) 20%, transparent); }
.btn { height: 42px; border-radius: 10px; border: 0; background: var(--text-1); color: var(--page); font-weight: 600; cursor: pointer; padding: 0 16px; }
.btn.full { width: 100%; margin-top: 6px; }
.btn.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); height: 34px; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.alert.error { color: var(--bad-text); border-color: color-mix(in srgb, var(--critical) 35%, transparent); background: color-mix(in srgb, var(--critical) 7%, transparent); }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner, main { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.topbar-inner { height: 60px; display: flex; align-items: center; gap: 16px; }
.topbar .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: pulse 2s infinite; }
.live strong { color: var(--text-1); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.user { color: var(--text-2); font-size: 13px; }

main { padding-top: 22px; padding-bottom: 48px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 550; }
.seg button[aria-pressed="true"] { background: var(--text-1); color: var(--page); }
.meta-line { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); }
.chip svg { width: 13px; height: 13px; }
.chip.ok svg { color: var(--good); }
.chip.off svg { color: var(--muted); }
.chip.err svg { color: var(--critical); }

.banner { border: 1px solid var(--border); background: var(--card); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; color: var(--text-2); display: flex; gap: 10px; align-items: flex-start; }
.banner strong { color: var(--text-1); }
.banner svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--warning); }

.grid { display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; font-weight: 620; margin: 0; }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 14px; }
.loading .card, .loading .hero { opacity: 0.55; transition: opacity .2s; }

/* Hero */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0; padding: 0; overflow: hidden; }
.hero > div { padding: 24px 26px; }
.hero .right { border-left: 1px solid var(--border); display: grid; gap: 18px; align-content: center; }
.label { color: var(--text-2); font-size: 13px; font-weight: 550; }
.hero-value { font-size: 52px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; margin: 6px 0 8px; }
.hero-foot { color: var(--text-2); }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--bad-text); }
.delta.flat { color: var(--muted); font-weight: 500; }
.split-row .big { font-size: 26px; font-weight: 650; margin-top: 2px; }
.explain { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.segbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; gap: 2px; margin-top: 10px; background: var(--grid); }
.segbar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--text-1); font-weight: 600; }

/* KPI tiles */
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { padding: 16px 18px; }
.tile .value { font-size: 26px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -0.01em; }
.tile .hint { color: var(--muted); font-size: 12px; }

.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .two, .hero { grid-template-columns: 1fr; } .hero .right { border-left: 0; border-top: 1px solid var(--border); } .chips { margin-left: 0; } }
@media (max-width: 560px) { .topbar-inner, main { padding: 0 14px; } .hero-value { font-size: 40px; } .user { display: none; } }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit { fill: transparent; cursor: default; }
.chart .band-hover { fill: var(--text-1); opacity: 0; }
.chart g.col:hover .band-hover, .chart g.col:focus .band-hover { opacity: 0.05; }
.chart g.col:focus { outline: none; }
.chart .bar-label { fill: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .row-name { fill: var(--text-1); font-size: 12.5px; }
.chart .row-note { fill: var(--muted); font-size: 11.5px; }
.chart g.row:hover .bar, .chart g.row:focus .bar { filter: brightness(1.08); }
.empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12); font-size: 12.5px; min-width: 150px; opacity: 0; transition: opacity .08s; }
.tooltip.show { opacity: 1; }
.tooltip .tt-title { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .tt-row strong { font-variant-numeric: tabular-nums; }
.tooltip .key { width: 12px; height: 2px; border-radius: 2px; display: inline-block; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 550; font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 10px 6px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.status svg { width: 14px; height: 14px; }
.status.good svg { color: var(--good); } .status.warn svg { color: var(--warning); } .status.bad svg { color: var(--critical); }
.camp-name { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

.foot { color: var(--muted); font-size: 12px; margin-top: 22px; display: grid; gap: 4px; }
.foot details { cursor: pointer; }
.mt { margin-top: 16px; }
#t-products .camp-name { max-width: 230px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
#t-products td:first-child { min-width: 160px; }
.brand-suffix { color: var(--text-2); font-weight: 500; }
@media (max-width: 560px) {
  .brand-suffix, .live-label { display: none; }
  .live { padding: 5px 10px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 14px; }
  .tile .value { font-size: 21px; }
  .card { padding: 16px; }
  .split-row .big { font-size: 22px; }
}
