:root {
  --ink: #182019;
  --ink-2: #4c574f;
  --ink-3: #7a837c;
  --paper: #f3f1eb;
  --surface: #fbfaf6;
  --surface-2: #f0eee7;
  --line: #dcd9cf;
  --line-dark: #c8c5bc;
  --nav: #121a15;
  --nav-soft: #1d2821;
  --green: #287251;
  --green-soft: #e1f1e8;
  --blue: #315f9c;
  --blue-soft: #e8eef8;
  --amber: #a2641d;
  --amber-soft: #f7ead4;
  --red: #a5433e;
  --red-soft: #f5e2df;
  --shadow: 0 1px 2px rgba(25, 32, 26, .06), 0 16px 44px rgba(25, 32, 26, .05);
  --radius: 16px;
  --sidebar: 246px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(24, 32, 25, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 32, 25, .025) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Aptos", "Trebuchet MS", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
a { color: inherit; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  overflow: hidden;
  color: #e9eee9;
  background:
    radial-gradient(circle at 10% 2%, rgba(88, 155, 115, .18), transparent 28%),
    var(--nav);
  border-right: 1px solid rgba(255, 255, 255, .08);
  transition: transform .25s ease;
}
.sidebar::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .05; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; min-height: 78px; padding: 17px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #d9f2e3; background: linear-gradient(145deg, #397c59, #224c37); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 8px 18px rgba(0,0,0,.2); }
.brand-mark svg { width: 22px; height: 22px; }
.brand-text strong { display: block; font-family: "Bahnschrift", "Aptos Display", sans-serif; font-size: 14px; letter-spacing: .025em; line-height: 1.2; }
.brand-text span { color: #91a097; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.nav-scroll { position: relative; z-index: 1; flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-label { margin: 17px 10px 7px; color: #77877d; font-family: "Bahnschrift", sans-serif; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; margin: 3px 0; padding: 10px 11px; color: #aebbb2; background: transparent; border: 0; border-radius: 10px; text-align: left; transition: color .18s ease, background .18s ease, transform .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); transform: translateX(2px); }
.nav-item.active { color: #f4fbf6; background: linear-gradient(90deg, rgba(69, 132, 91, .32), rgba(69,132,91,.12)); box-shadow: inset 2px 0 #77c495; }
.nav-item .icon { width: 17px; color: #829589; }
.nav-item.active .icon { color: #aee2c1; }
.nav-item span { flex: 1; }
.nav-count { flex: initial !important; min-width: 22px; padding: 1px 6px; border-radius: 20px; color: #facbc4; background: rgba(194, 78, 67, .18); font-size: 11px; text-align: center; }
.sidebar-footer { position: relative; z-index: 1; padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.account-mini { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 10px; background: rgba(255,255,255,.035); }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #152119; background: #b9d4c3; font-weight: 800; }
.account-mini div { min-width: 0; }
.account-mini strong, .account-mini span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-mini strong { font-size: 12px; }
.account-mini span { color: #7f9085; font-size: 10px; }

.main { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; min-height: 78px; padding: 13px 26px; background: rgba(243, 241, 235, .88); border-bottom: 1px solid rgba(200,197,188,.72); backdrop-filter: blur(18px); }
.mobile-menu { display: none !important; margin-right: 9px; }
.topbar-title { min-width: 180px; margin-right: auto; }
.topbar-title strong { display: block; font-family: "Bahnschrift", "Aptos Display", sans-serif; font-size: 15px; line-height: 1.2; }
.topbar-title span { color: var(--ink-3); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-separator { width: 1px; height: 30px; margin: 0 2px; background: var(--line); }
.btn, .icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 13px; background: var(--surface); border: 1px solid var(--line-dark); border-radius: 10px; font-weight: 700; font-size: 12px; white-space: nowrap; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.btn:hover, .icon-btn:hover { transform: translateY(-1px); border-color: #adb2aa; box-shadow: 0 6px 16px rgba(22,31,24,.08); }
.btn.primary { color: #fff; background: var(--ink); border-color: var(--ink); }
.btn.primary:hover { background: #243329; }
.btn.soft { color: var(--green); background: var(--green-soft); border-color: transparent; }
.btn.danger-soft { color: var(--red); background: var(--red-soft); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 31px; padding: 0 9px; font-size: 11px; }
.icon-btn { width: 38px; padding: 0; }
.executive-btn.active { color: #fff; background: var(--green); border-color: var(--green); }
.date-trigger { min-width: 200px; justify-content: flex-start; }
.date-trigger .date-copy { text-align: left; }
.date-trigger strong, .date-trigger span { display: block; line-height: 1.2; }
.date-trigger span { margin-top: 3px; color: var(--ink-3); font-size: 10px; font-weight: 500; }
.date-trigger .icon:last-child { width: 13px; margin-left: auto; }
.refresh-btn.loading .icon { animation: rotate .7s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

.content { max-width: 1640px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 5px; color: var(--green); font-family: "Bahnschrift", sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.page-head h1 { margin: 0; font-family: "Bahnschrift", "Aptos Display", sans-serif; font-size: clamp(26px, 3vw, 36px); font-weight: 650; letter-spacing: -.035em; line-height: 1.05; }
.page-head p { max-width: 650px; margin: 7px 0 0; color: var(--ink-2); }
.page-context { display: flex; align-items: center; gap: 8px; }
.source-pill, .status-pill, .badge { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .025em; }
.source-pill { color: #7b5d26; background: #f7ecd6; border: 1px solid #ead6ad; }
.source-pill::before, .status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.active, .status-pill.ativo, .badge.positive { color: var(--green); background: var(--green-soft); }
.status-pill.paused, .status-pill.pausado, .badge.warning { color: var(--amber); background: var(--amber-soft); }
.status-pill.ended, .status-pill.encerrado, .badge.neutral { color: #68716b; background: #e8e8e3; }
.badge.danger { color: var(--red); background: var(--red-soft); }
.badge.good { color: var(--blue); background: var(--blue-soft); }
.badge { border-radius: 7px; }
.card { background: rgba(251,250,246,.94); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 19px 20px 14px; }
.card-head h2, .card-head h3 { margin: 0; font-family: "Bahnschrift", "Aptos Display", sans-serif; font-weight: 600; letter-spacing: -.012em; }
.card-head h2 { font-size: 17px; }
.card-head h3 { font-size: 14px; }
.card-head p { margin: 4px 0 0; color: var(--ink-3); font-size: 11px; }
.card-head-actions { display: flex; align-items: center; gap: 7px; }
.text-link { display: inline-flex; align-items: center; gap: 4px; padding: 0; color: var(--green); background: none; border: 0; font-size: 11px; font-weight: 800; }
.text-link .icon { width: 13px; }
.card-body { padding: 0 20px 20px; }
.muted { color: var(--ink-3); }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: .9em; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card { position: relative; min-height: 148px; padding: 17px; overflow: hidden; }
.kpi-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--tone, var(--green)); opacity: .9; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; color: var(--ink-2); font-size: 11px; font-weight: 800; }
.kpi-info { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: var(--ink-3); background: var(--surface-2); }
.kpi-info .icon { width: 11px; }
.kpi-value { margin-top: 13px; font-family: "Bahnschrift", "Aptos Display", sans-serif; font-size: 29px; font-weight: 650; letter-spacing: -.035em; line-height: 1; }
.kpi-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 13px; }
.trend { display: inline-flex; align-items: center; gap: 2px; padding: 4px 6px; border-radius: 6px; font-size: 10px; font-weight: 800; }
.trend.positive { color: var(--green); background: var(--green-soft); }
.trend.negative { color: var(--red); background: var(--red-soft); }
.trend.neutral { color: var(--ink-3); background: var(--surface-2); }
.trend .icon { width: 11px; height: 11px; stroke-width: 2.5; }
.kpi-compare { display: block; margin-top: 5px; color: var(--ink-3); font-size: 9px; }
.secondary-strip { display: grid; grid-template-columns: repeat(5, 1fr); margin-bottom: 16px; overflow: hidden; }
.secondary-metric { position: relative; padding: 13px 17px; }
.secondary-metric + .secondary-metric { border-left: 1px solid var(--line); }
.secondary-metric span, .secondary-metric strong, .secondary-metric small { display: block; }
.secondary-metric span { color: var(--ink-3); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.secondary-metric strong { margin-top: 5px; font-family: "Bahnschrift", sans-serif; font-size: 17px; }
.secondary-metric small { position: absolute; top: 14px; right: 14px; font-size: 9px; font-weight: 800; }
.is-positive { color: var(--green); }
.is-negative { color: var(--red); }
.sparkline { width: 72px; height: 26px; overflow: visible; }
.sparkline-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline-line.positive { stroke: var(--green); }
.sparkline-line.negative { stroke: var(--red); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .68fr); gap: 16px; margin-bottom: 16px; }
.grid-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-main > *, .grid-halves > *, .comparison-grid > * { min-width: 0; }
.chart-card { min-height: 380px; }
.chart-controls { display: flex; gap: 6px; }
.compact-select, .field select, .field input, .search-input { min-height: 34px; padding: 0 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; outline: none; }
.compact-select:focus, .field input:focus, .field select:focus, .search-input:focus { border-color: #6f9f80; box-shadow: 0 0 0 3px rgba(60,125,84,.1); }
.line-chart, .scatter-chart { display: block; width: 100%; overflow: visible; }
.chart-grid { stroke: #dfddd5; stroke-width: 1; stroke-dasharray: 2 5; }
.chart-label, .axis-label { fill: #7d867f; font-family: "Aptos", sans-serif; font-size: 10px; }
.axis-label { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.chart-line { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart-line-primary { stroke: var(--green); }
.chart-line-secondary { stroke: var(--amber); stroke-dasharray: 5 5; }
.chart-hit { fill: transparent; }
.chart-dot { fill: var(--surface); stroke: var(--green); stroke-width: 2; opacity: 0; transition: opacity .15s ease; }
.chart-point:hover .chart-dot { opacity: 1; }
.chart-legend { display: flex; gap: 14px; margin-top: -2px; color: var(--ink-3); font-size: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 18px; height: 2px; background: var(--green); }
.legend-line.secondary { height: 1px; background: repeating-linear-gradient(90deg, var(--amber) 0 4px, transparent 4px 7px); }

.attention-card { color: #edf4ef; background: linear-gradient(155deg, #16221a, #21342a); border-color: #26382d; box-shadow: 0 18px 50px rgba(14,26,18,.18); }
.attention-card .card-head p { color: #94a99b; }
.attention-summary { padding: 0 20px 17px; color: #afc0b5; font-size: 12px; }
.attention-summary strong { color: #fff; }
.attention-list { display: grid; gap: 7px; padding: 0 12px 12px; }
.attention-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px; color: #dce7df; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.06); border-radius: 10px; text-align: left; }
.attention-item:hover { background: rgba(255,255,255,.075); }
.attention-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(194,131,46,.1); }
.attention-item.danger .attention-dot { background: #e06a5c; box-shadow: 0 0 0 4px rgba(224,106,92,.11); }
.attention-item.positive .attention-dot { background: #67bf86; box-shadow: 0 0 0 4px rgba(103,191,134,.1); }
.attention-copy { min-width: 0; flex: 1; }
.attention-copy strong, .attention-copy span { display: block; }
.attention-copy strong { font-size: 11px; }
.attention-copy span { margin-top: 2px; overflow: hidden; color: #84998c; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.attention-item .icon { width: 13px; color: #708579; }

.funnel { padding: 4px 0 2px; }
.funnel-stage { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 62px; margin: 0 auto 6px; padding: 10px 18px; color: #eff6f1; background: var(--ink); clip-path: polygon(0 0,100% 0,94% 100%,6% 100%); }
.funnel-stage span { padding-left: 8%; color: rgba(255,255,255,.7); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.funnel-stage strong { padding-right: 8%; font-family: "Bahnschrift", sans-serif; font-size: 20px; }
.funnel-rate { display: flex; align-items: center; justify-content: center; gap: 8px; margin: -1px 0 5px; color: var(--ink-3); font-size: 9px; }
.funnel-metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 15px; border-top: 1px solid var(--line); }
.funnel-metric { padding: 13px 8px 0; text-align: center; }
.funnel-metric + .funnel-metric { border-left: 1px solid var(--line); }
.funnel-metric span, .funnel-metric strong { display: block; }
.funnel-metric span { color: var(--ink-3); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.funnel-metric strong { margin-top: 4px; font-family: "Bahnschrift", sans-serif; font-size: 16px; }

.table-card { overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 0 18px 14px; }
.search-wrap { position: relative; flex: 1; max-width: 340px; }
.search-wrap .icon { position: absolute; top: 50%; left: 11px; width: 15px; color: var(--ink-3); transform: translateY(-50%); }
.search-input { width: 100%; padding-left: 34px; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; padding: 10px 13px; color: var(--ink-3); background: #f3f1eb; border-bottom: 1px solid var(--line); font-size: 9px; font-weight: 800; letter-spacing: .07em; text-align: right; text-transform: uppercase; }
th:first-child, th.left { text-align: left; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
td { padding: 13px; border-bottom: 1px solid #e7e4dc; font-size: 11px; text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s ease; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: #f3f5f0; }
td:first-child, td.left { text-align: left; }
.campaign-cell { display: flex; align-items: center; gap: 10px; min-width: 235px; }
.campaign-color { width: 7px; height: 28px; border-radius: 10px; }
.campaign-name strong, .campaign-name span { display: block; }
.campaign-name strong { max-width: 240px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.campaign-name span { margin-top: 2px; color: var(--ink-3); font-size: 9px; }
.ad-name-cell { display: flex; align-items: center; gap: 10px; min-width: 230px; text-align: left; }
.creative-thumb { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 48px; color: rgba(255,255,255,.92); border-radius: 7px; font-family: "Bahnschrift", sans-serif; font-size: 10px; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.metric-strong { font-family: "Bahnschrift", sans-serif; font-size: 12px; font-weight: 650; }
.score-cell { display: inline-flex; align-items: center; gap: 7px; }
.score-ring { --score-color: var(--green); position: relative; display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: conic-gradient(var(--score-color) calc(var(--score) * 1%), #e1e0da 0); }
.score-ring::after { content: ""; position: absolute; width: 23px; height: 23px; border-radius: 50%; background: var(--surface); }
.score-ring span { position: relative; z-index: 1; font-family: "Bahnschrift", sans-serif; font-size: 9px; font-weight: 700; }
.score-ring.warning { --score-color: var(--amber); }
.score-ring.danger { --score-color: var(--red); }
.score-ring.good { --score-color: var(--blue); }

.ranking-list { display: grid; gap: 1px; }
.ranking-row { display: grid; grid-template-columns: 28px minmax(120px, 1fr) 120px 68px 18px; align-items: center; gap: 10px; padding: 11px 20px; border-top: 1px solid var(--line); }
.ranking-row:first-child { border-top: 0; }
.ranking-index { color: var(--ink-3); font-family: "Bahnschrift", sans-serif; font-size: 11px; }
.ranking-name strong, .ranking-name span { display: block; }
.ranking-name strong { font-size: 11px; }
.ranking-name span { color: var(--ink-3); font-size: 9px; }
.mini-bar { height: 5px; overflow: hidden; background: #e4e3dd; border-radius: 10px; }
.mini-bar span { display: block; height: 100%; background: var(--green); border-radius: inherit; }

.distribution-chart { display: grid; grid-template-columns: 175px 1fr; align-items: center; gap: 28px; padding: 2px 8px 3px; }
.distribution-donut { display: grid; place-items: center; width: 156px; height: 156px; border-radius: 50%; }
.distribution-donut::before { content: ""; position: absolute; width: 106px; height: 106px; border-radius: 50%; background: var(--surface); }
.distribution-donut div { position: relative; z-index: 1; text-align: center; }
.distribution-donut strong, .distribution-donut span { display: block; }
.distribution-donut strong { font-family: "Bahnschrift", sans-serif; font-size: 18px; }
.distribution-donut span { margin-top: 3px; color: var(--ink-3); font-size: 9px; }
.distribution-stack { display: grid; gap: 18px; }
.stack-head { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--ink-2); font-size: 10px; }
.stacked-bar { display: flex; height: 12px; overflow: hidden; border-radius: 4px; }
.stacked-bar span { min-width: 2px; transition: width .3s ease; }
.distribution-note { display: flex; align-items: flex-start; gap: 8px; padding: 10px; color: #72561f; background: var(--amber-soft); border-radius: 9px; font-size: 10px; }
.distribution-note .icon { flex: 0 0 auto; width: 14px; }

.insight-list { display: grid; gap: 8px; }
.insight-row { display: grid; grid-template-columns: 74px 1fr; gap: 12px; padding: 12px; background: var(--surface-2); border-radius: 10px; }
.insight-row span { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.insight-row p { margin: 0; font-size: 11px; }
.alert-list { display: grid; gap: 7px; }
.alert-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; }
.alert-icon { display: grid; flex: 0 0 auto; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--amber); background: var(--amber-soft); }
.alert-row.danger .alert-icon { color: var(--red); background: var(--red-soft); }
.alert-row.positive .alert-icon { color: var(--green); background: var(--green-soft); }
.alert-icon .icon { width: 14px; }
.alert-copy { min-width: 0; flex: 1; }
.alert-copy strong, .alert-copy span { display: block; }
.alert-copy strong { font-size: 11px; }
.alert-copy span { margin-top: 3px; color: var(--ink-3); font-size: 9px; }
.rules-list { display: grid; gap: 8px; }
.rules-list > div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 11px; background: var(--surface-2); border-radius: 9px; }
.rules-list strong { font-size: 10px; }
.rules-list span { color: var(--ink-2); font-size: 10px; }

.creative-grid { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 14px; }
.creative-card { overflow: hidden; }
.creative-preview { position: relative; display: flex; min-height: 200px; align-items: flex-end; padding: 17px; overflow: hidden; color: #fff; background: linear-gradient(145deg, var(--preview-a), var(--preview-b)); }
.creative-preview::before { content: ""; position: absolute; width: 170px; height: 170px; top: -45px; right: -45px; border: 1px solid rgba(255,255,255,.23); border-radius: 50%; box-shadow: 0 0 0 23px rgba(255,255,255,.05), 0 0 0 50px rgba(255,255,255,.03); }
.creative-preview::after { content: "META / PERFORMANCE"; position: absolute; top: 15px; left: 17px; color: rgba(255,255,255,.72); font-family: "Bahnschrift", sans-serif; font-size: 8px; letter-spacing: .15em; }
.creative-type { position: absolute; top: 12px; right: 12px; padding: 4px 7px; color: rgba(255,255,255,.87); background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; backdrop-filter: blur(7px); }
.creative-hook { position: relative; z-index: 1; max-width: 82%; margin: 0; font-family: "Bahnschrift", sans-serif; font-size: 21px; font-weight: 650; letter-spacing: -.03em; line-height: 1.03; }
.creative-body { padding: 15px; }
.creative-title { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.creative-title h3 { margin: 0; font-family: "Bahnschrift", sans-serif; font-size: 13px; font-weight: 600; }
.creative-title p { margin: 3px 0 0; color: var(--ink-3); font-size: 9px; }
.creative-score { font-family: "Bahnschrift", sans-serif; font-size: 19px; font-weight: 650; }
.creative-score small { color: var(--ink-3); font-size: 9px; }
.creative-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.creative-metric span, .creative-metric strong { display: block; }
.creative-metric span { color: var(--ink-3); font-size: 8px; text-transform: uppercase; }
.creative-metric strong { margin-top: 3px; font-size: 11px; }

.comparison-selector { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 9px; }
.check-card { display: flex; align-items: center; gap: 10px; padding: 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check-card:has(input:checked) { border-color: #75a78a; box-shadow: inset 0 0 0 1px #75a78a; background: #f3f8f4; }
.check-card input { accent-color: var(--green); }
.check-card span { display: block; }
.check-card strong { font-size: 10px; }
.check-card small { display: block; color: var(--ink-3); font-size: 8px; }
.comparison-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; margin-top: 16px; }
.comparison-bars { display: grid; gap: 16px; padding: 4px 0; }
.bar-row { display: grid; grid-template-columns: 25px 1fr; gap: 10px; align-items: center; }
.bar-rank { color: var(--ink-3); font-family: "Bahnschrift", sans-serif; font-size: 10px; }
.bar-content { min-width: 0; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: 10px; }
.bar-head strong { font-family: "Bahnschrift", sans-serif; }
.bar-track { height: 8px; overflow: hidden; background: #e5e3dd; border-radius: 3px; }
.bar-track span { display: block; min-width: 2px; height: 100%; border-radius: inherit; }
.auto-conclusion { display: flex; align-items: flex-start; gap: 12px; padding: 17px; color: #204e38; background: var(--green-soft); border: 1px solid #c7e2d2; border-radius: 12px; }
.auto-conclusion .icon { flex: 0 0 auto; margin-top: 1px; }
.auto-conclusion strong, .auto-conclusion span { display: block; }
.auto-conclusion strong { margin-bottom: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.auto-conclusion span { font-size: 12px; }

.detail-hero { position: relative; margin-bottom: 16px; padding: 22px; overflow: hidden; color: #edf5ef; background: linear-gradient(145deg, #152219, #2b4938); border: 1px solid #2c4435; border-radius: 18px; box-shadow: 0 20px 60px rgba(14,27,18,.18); }
.detail-hero::after { content: ""; position: absolute; width: 330px; height: 330px; right: -130px; top: -180px; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; box-shadow: 0 0 0 44px rgba(255,255,255,.025), 0 0 0 95px rgba(255,255,255,.018); }
.detail-back { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 20px; padding: 0; color: #9bb0a1; background: none; border: 0; font-size: 10px; }
.detail-back .icon { width: 12px; transform: rotate(180deg); }
.detail-top { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.detail-top h1 { margin: 4px 0 7px; font-family: "Bahnschrift", sans-serif; font-size: 30px; letter-spacing: -.035em; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 13px; color: #9cb0a2; font-size: 10px; }
.detail-score { text-align: right; }
.detail-score strong { display: block; font-family: "Bahnschrift", sans-serif; font-size: 42px; line-height: 1; }
.detail-score span { color: #9cb0a2; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.detail-kpis { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-bottom: 16px; }
.detail-kpi { padding: 14px; }
.detail-kpi span, .detail-kpi strong { display: block; }
.detail-kpi span { color: var(--ink-3); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.detail-kpi strong { margin-top: 6px; font-family: "Bahnschrift", sans-serif; font-size: 18px; }
.detail-kpi .trend { display: inline-flex; margin-top: 7px; }
.diagnosis-grid { display: grid; grid-template-columns: 130px 1fr 1fr; gap: 18px; align-items: stretch; }
.diagnosis-score { display: grid; place-items: center; padding: 20px; color: #fff; background: var(--ink); border-radius: 12px; text-align: center; }
.diagnosis-score strong { font-family: "Bahnschrift", sans-serif; font-size: 24px; }
.diagnosis-score span { color: #9eb0a2; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.diagnosis-column h4 { margin: 0 0 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.diagnosis-column ul { margin: 0; padding: 0; list-style: none; }
.diagnosis-column li { display: flex; gap: 7px; margin: 7px 0; color: var(--ink-2); font-size: 11px; }
.diagnosis-column li::before { content: ""; flex: 0 0 auto; width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--green); }
.diagnosis-column.caution li::before { background: var(--amber); }
.suggestion { margin-top: 14px; padding: 12px; color: #355844; background: var(--green-soft); border-radius: 9px; font-size: 11px; }

.history-timeline { position: relative; display: grid; gap: 15px; padding-left: 20px; }
.history-timeline::before { content: ""; position: absolute; left: 4px; top: 7px; bottom: 7px; width: 1px; background: var(--line-dark); }
.history-item { position: relative; display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 16px; padding: 15px; background: var(--surface-2); border-radius: 11px; }
.history-item::before { content: ""; position: absolute; left: -20px; width: 9px; height: 9px; background: var(--green); border: 3px solid var(--paper); border-radius: 50%; }
.history-date strong, .history-date span { display: block; }
.history-date span { color: var(--ink-3); font-size: 9px; }
.history-metrics { display: flex; gap: 22px; }
.history-metric span, .history-metric strong { display: block; }
.history-metric span { color: var(--ink-3); font-size: 8px; text-transform: uppercase; }
.history-metric strong { margin-top: 3px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.field { display: grid; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--ink-2); font-size: 10px; font-weight: 800; }
.field input, .field select { width: 100%; min-height: 40px; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 11px; top: 50%; color: var(--ink-3); transform: translateY(-50%); }
.input-prefix input { padding-left: 33px; }
.settings-note { display: flex; gap: 9px; margin-top: 13px; padding: 10px; color: var(--ink-2); background: var(--surface-2); border-radius: 9px; font-size: 10px; }
.settings-note .icon { flex: 0 0 auto; width: 14px; }
.progress-list { display: grid; gap: 17px; }
.goal-row { display: grid; gap: 6px; }
.goal-head { display: flex; justify-content: space-between; gap: 10px; font-size: 10px; }
.goal-head strong { font-family: "Bahnschrift", sans-serif; }
.progress { height: 8px; overflow: hidden; background: #e3e1da; border-radius: 8px; }
.progress span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.progress.warning span { background: var(--amber); }
.projection-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.projection-item { padding: 13px; background: var(--surface-2); border-radius: 10px; }
.projection-item span, .projection-item strong { display: block; }
.projection-item span { color: var(--ink-3); font-size: 8px; text-transform: uppercase; }
.projection-item strong { margin-top: 5px; font-family: "Bahnschrift", sans-serif; font-size: 16px; }

.empty-state { padding: 60px 20px; text-align: center; }
.empty-state .icon { width: 32px; height: 32px; color: var(--ink-3); }
.empty-state h3 { margin: 10px 0 4px; }
.empty-state p { max-width: 420px; margin: 0 auto 15px; color: var(--ink-3); font-size: 11px; }
.pagination-note { padding: 11px 15px; color: var(--ink-3); background: #f5f3ed; border-top: 1px solid var(--line); font-size: 9px; text-align: right; }

.popover { position: fixed; z-index: 80; width: 330px; padding: 12px; background: var(--surface); border: 1px solid var(--line-dark); border-radius: 13px; box-shadow: 0 20px 70px rgba(18,30,21,.2); animation: reveal .16s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(-5px); } }
.popover-title { display: flex; justify-content: space-between; align-items: center; padding: 3px 3px 9px; font-weight: 800; font-size: 11px; }
.range-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.range-option { padding: 9px; background: transparent; border: 1px solid transparent; border-radius: 8px; text-align: left; font-size: 10px; }
.range-option:hover { background: var(--surface-2); }
.range-option.active { color: var(--green); background: var(--green-soft); border-color: #c8e3d2; font-weight: 800; }
.popover-divider { height: 1px; margin: 11px 0; background: var(--line); }
.custom-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.popover .field input, .popover .field select { min-height: 35px; font-size: 10px; }
.popover-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }
.popover-backdrop { position: fixed; inset: 0; z-index: 70; background: transparent; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 9px; min-width: 260px; max-width: 380px; padding: 12px; color: #e8f0ea; background: #18251d; border: 1px solid #2b4233; border-radius: 11px; box-shadow: 0 15px 40px rgba(0,0,0,.2); animation: toastIn .25s ease; font-size: 11px; }
.toast .icon { color: #82c99d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.sidebar-overlay { display: none; }

.executive-mode .sidebar { transform: translateX(-100%); }
.executive-mode .main { margin-left: 0; }
.executive-mode .content { max-width: 1320px; }
.executive-mode .topbar-title strong::after { content: " · Modo Executivo"; color: var(--green); }
.executive-hero { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; margin-bottom: 16px; }
.executive-summary { padding: 24px; color: #eef5f0; background: linear-gradient(145deg, #152119, #2c4939); border-color: #2d4637; }
.executive-summary .eyebrow { color: #8fd0a8; }
.executive-summary h2 { max-width: 680px; margin: 10px 0; font-family: "Bahnschrift", sans-serif; font-size: 26px; letter-spacing: -.03em; }
.executive-summary p { max-width: 690px; color: #a3b7a9; }
.overall-score { display: grid; place-items: center; min-height: 220px; text-align: center; }
.overall-score strong { display: block; font-family: "Bahnschrift", sans-serif; font-size: 72px; line-height: 1; }
.overall-score span { color: var(--ink-3); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }

@media (max-width: 1280px) {
  :root { --sidebar: 220px; }
  .content { padding: 22px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .creative-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-kpis { grid-template-columns: repeat(4, 1fr); }
  .topbar-title { display: none; }
  .top-actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(11,18,13,.45); backdrop-filter: blur(2px); }
  .main, .executive-mode .main { margin-left: 0; }
  .mobile-menu { display: inline-flex !important; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px; }
  .grid-main, .grid-halves, .comparison-grid, .executive-hero { grid-template-columns: 1fr; }
  .creative-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-kpis { grid-template-columns: repeat(3, 1fr); }
  .comparison-selector { grid-template-columns: repeat(2, 1fr); }
  .secondary-strip { grid-template-columns: repeat(3, 1fr); }
  .secondary-metric:nth-child(4) { border-left: 0; border-top: 1px solid var(--line); }
  .secondary-metric:nth-child(5) { border-top: 1px solid var(--line); }
  .hide-tablet { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 13px; }
  .topbar { min-height: 64px; }
  .top-actions .executive-btn, .top-actions .refresh-btn span, .toolbar-separator { display: none; }
  .date-trigger { min-width: 0; max-width: 175px; }
  .date-trigger .date-copy span { display: none; }
  .content { padding: 14px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head h1 { font-size: 27px; }
  .card-head { flex-wrap: wrap; }
  .chart-controls { width: 100%; }
  .chart-controls .compact-select { min-width: 0; flex: 1; }
  .page-context { width: 100%; justify-content: space-between; }
  .kpi-grid { gap: 9px; }
  .kpi-card { min-height: 130px; padding: 14px; }
  .alert-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 24px; }
  .sparkline { display: none; }
  .creative-grid, .comparison-selector, .form-grid, .projection-grid { grid-template-columns: 1fr; }
  .secondary-strip { grid-template-columns: repeat(2, 1fr); }
  .secondary-metric:nth-child(n) { border-top: 0; }
  .secondary-metric:nth-child(odd) { border-left: 0; }
  .secondary-metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .distribution-chart { grid-template-columns: 1fr; justify-items: center; }
  .distribution-stack { width: 100%; }
  .ranking-row { grid-template-columns: 24px 1fr 50px 15px; }
  .ranking-row .mini-bar { display: none; }
  .detail-top { align-items: flex-start; flex-direction: column; }
  .detail-score { text-align: left; }
  .detail-kpis { grid-template-columns: repeat(2, 1fr); }
  .diagnosis-grid { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 1fr; gap: 9px; }
  .history-metrics { flex-wrap: wrap; }
  .popover { left: 10px !important; right: 10px; width: auto; }
  .page-actions .btn span { display: none; }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .page-actions, .table-toolbar, .text-link, .btn { display: none !important; }
  .main { margin: 0; }
  .content { max-width: none; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ==========================================================================
   DESIGN SYSTEM v3 — "BI desk"
   --------------------------------------------------------------------------
   Substitui as camadas "editorial v2" + "legibility pass".
   Princípios (spec §34): visual de plataforma profissional de BI, superfícies
   neutras, hierarquia forte e COR RESERVADA A SIGNIFICADO — status (verde /
   âmbar / vermelho / cinza), marca (ação e foco) e séries (identidade de
   campanha, apenas dentro de gráficos). Nada de cor decorativa.

   Tema claro e escuro são ambos *escolhidos*, não invertidos: cada modo tem
   seus próprios passos, validados contra a superfície em que de fato renderiza.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS — tema claro
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* planos */
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e8ecf0;
  --surface-raised: #ffffff;

  /* traços */
  --line: #e4e8ed;
  --line-strong: #d2d9e0;
  --line-dark: #d2d9e0;

  /* tinta */
  --ink: #11161b;
  --ink-2: #4b5865;
  --ink-3: #79858f;
  --ink-4: #9aa5af;

  /* marca — ação, foco e identidade. Nunca decorativa. */
  --brand: #f05a22;
  --brand-strong: #c8461a;
  --brand-ink: #a4380f;
  --brand-soft: #fdefe8;
  --brand-line: #f7d3c1;

  /* status — reservado. Um status nunca vira "série 4". */
  --good: #0ca30c;   --good-ink: #067006;   --good-soft: #e3f5e3;   --good-line: #c2e8c2;
  --warn: #d99000;   --warn-ink: #8d5e00;   --warn-soft: #fdf1d8;   --warn-line: #f2ddaa;
  --crit: #d03b3b;   --crit-ink: #a62626;   --crit-soft: #fbe7e7;   --crit-line: #f0c9c9;
  --calm: #79858f;   --calm-ink: #59656f;   --calm-soft: #eef1f4;   --calm-line: #dde3e8;

  /* séries categóricas — ordem fixa, nunca ciclada.
     Validada (dataviz): banda de luminosidade, piso de croma, separação
     para daltonismo e piso de visão normal, contra a superfície clara. */
  --series-1: #f05a22;
  --series-2: #2a78d6;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #4a3aa7;
  --series-6: #e87ba4;
  --series-7: #008300;

  /* cromo de gráfico */
  --chart-surface: var(--surface);
  --chart-grid: #ecf0f4;
  --chart-axis: #d8dee4;
  --chart-ink: #79858f;
  --chart-halo: #ffffff;

  /* navegação */
  --nav-bg: #11161b;
  --nav-ink: #b6c1cb;
  --nav-ink-strong: #ffffff;
  --nav-line: rgba(255, 255, 255, .09);
  --nav-active: #1e262e;
  --nav-muted: #7b8792;

  /* superfície invertida (heros, cartões de destaque) */
  --inv-bg: #161c22;
  --inv-bg-2: #1e262e;
  --inv-ink: #eef2f6;
  --inv-ink-2: #a6b2bd;
  --inv-line: rgba(255, 255, 255, .1);

  /* elevação */
  /* Elevação existe só para o que FLUTUA sobre a interface (popover, toast,
     tooltip). Superfície fixa se separa por hairline — a tela inteira se
     organiza por linhas, como um relatório impresso, não por sombras. */
  --shadow-1: none;
  --shadow-2: none;
  --shadow-3: 0 1px 1px rgba(15, 23, 31, .1), 0 10px 26px rgba(15, 23, 31, .15);
  --shadow: none;

  /* forma e ritmo */
  /* Raios curtos e desiguais. Nada de "tudo com o mesmo canto macio": o
     contêiner é quase reto, só o que é etiqueta vira pílula. */
  --r-1: 3px;
  --r-2: 5px;
  --r-3: 7px;
  --r-pill: 999px;
  --radius: var(--r-2);
  --sidebar: 238px;

  /* Par tipográfico: grotesca condensada de engenharia (DIN) para número e
     título — a voz do painel de instrumentos — e a UI sans do sistema para
     texto corrido. Números sempre em figuras tabulares, para as colunas
     alinharem na vertical. */
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Inter, Roboto, sans-serif;
  --font-display: "Bahnschrift", "DIN Next LT Pro", "Roboto Condensed", "Segoe UI Variable Display", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  /* interação */
  --ring: 0 0 0 3px rgba(240, 90, 34, .24);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --fast: .14s;
  --slow: .26s;
}

/* --------------------------------------------------------------------------
   2. TOKENS — tema escuro (passos próprios, não uma inversão automática)
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --page: #0e1114;
    --surface: #1b1f24;
    --surface-2: #22272e;
    --surface-3: #2a3038;
    --surface-raised: #21262c;

    --line: #282e35;
    --line-strong: #363d46;
    --line-dark: #363d46;

    --ink: #f1f4f7;
    --ink-2: #a8b3be;
    --ink-3: #7d8894;
    --ink-4: #656f79;

    --brand: #f0703d;
    --brand-strong: #f58756;
    --brand-ink: #f79f77;
    --brand-soft: rgba(240, 112, 61, .15);
    --brand-line: rgba(240, 112, 61, .34);

    --good: #2ebd2e;  --good-ink: #6ad76a;  --good-soft: rgba(46, 189, 46, .15);  --good-line: rgba(46, 189, 46, .32);
    --warn: #e0a52a;  --warn-ink: #f0c260;  --warn-soft: rgba(224, 165, 42, .15); --warn-line: rgba(224, 165, 42, .32);
    --crit: #e35b5b;  --crit-ink: #f08d8d;  --crit-soft: rgba(227, 91, 91, .16);  --crit-line: rgba(227, 91, 91, .34);
    --calm: #7d8894;  --calm-ink: #a8b3be;  --calm-soft: rgba(125, 136, 148, .16); --calm-line: rgba(125, 136, 148, .3);

    --series-1: #e2602c;
    --series-2: #3987e5;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #9085e9;
    --series-6: #d55181;
    --series-7: #12a012;

    --chart-grid: #252b32;
    --chart-axis: #363d46;
    --chart-ink: #8a95a1;
    --chart-halo: #1b1f24;

    --nav-bg: #0b0e11;
    --nav-ink: #aeb9c4;
    --nav-ink-strong: #ffffff;
    --nav-line: rgba(255, 255, 255, .07);
    --nav-active: #1a2027;
    --nav-muted: #6f7a85;

    --inv-bg: #22272e;
    --inv-bg-2: #2a3038;
    --inv-ink: #f1f4f7;
    --inv-ink-2: #a8b3be;
    --inv-line: rgba(255, 255, 255, .08);

    --shadow-1: none;
    --shadow-2: none;
    --shadow-3: 0 1px 1px rgba(0, 0, 0, .5), 0 10px 26px rgba(0, 0, 0, .55);

    --ring: 0 0 0 3px rgba(240, 112, 61, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page: #0e1114;
  --surface: #1b1f24;
  --surface-2: #22272e;
  --surface-3: #2a3038;
  --surface-raised: #21262c;

  --line: #282e35;
  --line-strong: #363d46;
  --line-dark: #363d46;

  --ink: #f1f4f7;
  --ink-2: #a8b3be;
  --ink-3: #7d8894;
  --ink-4: #656f79;

  --brand: #f0703d;
  --brand-strong: #f58756;
  --brand-ink: #f79f77;
  --brand-soft: rgba(240, 112, 61, .15);
  --brand-line: rgba(240, 112, 61, .34);

  --good: #2ebd2e;  --good-ink: #6ad76a;  --good-soft: rgba(46, 189, 46, .15);  --good-line: rgba(46, 189, 46, .32);
  --warn: #e0a52a;  --warn-ink: #f0c260;  --warn-soft: rgba(224, 165, 42, .15); --warn-line: rgba(224, 165, 42, .32);
  --crit: #e35b5b;  --crit-ink: #f08d8d;  --crit-soft: rgba(227, 91, 91, .16);  --crit-line: rgba(227, 91, 91, .34);
  --calm: #7d8894;  --calm-ink: #a8b3be;  --calm-soft: rgba(125, 136, 148, .16); --calm-line: rgba(125, 136, 148, .3);

  --series-1: #e2602c;
  --series-2: #3987e5;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #9085e9;
  --series-6: #d55181;
  --series-7: #12a012;

  --chart-grid: #252b32;
  --chart-axis: #363d46;
  --chart-ink: #8a95a1;
  --chart-halo: #1b1f24;

  --nav-bg: #0b0e11;
  --nav-ink: #aeb9c4;
  --nav-ink-strong: #ffffff;
  --nav-line: rgba(255, 255, 255, .07);
  --nav-active: #1a2027;
  --nav-muted: #6f7a85;

  --inv-bg: #22272e;
  --inv-bg-2: #2a3038;
  --inv-ink: #f1f4f7;
  --inv-ink-2: #a8b3be;
  --inv-line: rgba(255, 255, 255, .08);

  --shadow-1: none;
  --shadow-2: none;
  --shadow-3: 0 1px 1px rgba(0, 0, 0, .5), 0 10px 26px rgba(0, 0, 0, .55);

  --ring: 0 0 0 3px rgba(240, 112, 61, .3);
}

/* --------------------------------------------------------------------------
   3. BASE
   -------------------------------------------------------------------------- */
/* html tambem pintado: o fundo da tela vem de um elemento real, nao da
   propagacao do body — assim a troca de tema repinta sem recarregar. */
html { background: var(--page); }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "cv05" 1;
  letter-spacing: -.005em;
  transition: background var(--fast) linear, color var(--fast) linear;
}

.icon { stroke-width: 1.6; }

/* Foco visível e consistente — teclado antes de mouse. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-1);
}
.btn:focus-visible,
.icon-btn:focus-visible,
.nav-item:focus-visible,
.attention-item:focus-visible,
.ranking-row:focus-visible,
.check-card:focus-within {
  outline: none;
  box-shadow: var(--ring);
}
.compact-select:focus,
.field input:focus,
.field select:focus,
.search-input:focus {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   4. NAVEGAÇÃO LATERAL
   -------------------------------------------------------------------------- */
.sidebar {
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-line);
  color: var(--nav-ink);
}
.sidebar::after { display: none; }

.brand {
  min-height: 70px;
  gap: 11px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--nav-line);
}
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: var(--r-1);
  box-shadow: none;
}
.brand-mark b {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.brand-mark i { display: none; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 620;
  letter-spacing: -.015em;
  color: var(--nav-ink-strong);
}
.brand-text span {
  margin-top: 2px;
  color: var(--nav-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
}

.nav-scroll { padding: 12px 10px; }
.nav-label {
  margin: 16px 10px 6px;
  color: var(--nav-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
}
.nav-scroll > .nav-label:first-child { margin-top: 4px; }
.nav-item {
  position: relative;
  gap: 10px;
  min-height: 38px;
  margin: 1px 0;
  padding: 8px 10px;
  color: var(--nav-ink);
  border-radius: var(--r-1);
  font-size: 13px;
  font-weight: 500;
  transition: color var(--fast) linear, background var(--fast) linear;
}
.nav-item:hover { color: var(--nav-ink-strong); background: rgba(255, 255, 255, .05); transform: none; }
.nav-item.active {
  color: var(--nav-ink-strong);
  background: var(--nav-active);
  box-shadow: none;
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--brand);
  border-radius: 2px;
}
.nav-item .icon { width: 17px; height: 17px; color: var(--nav-muted); }
.nav-item.active .icon { color: var(--brand); }
.nav-count {
  min-width: 20px;
  padding: 1px 6px;
  color: var(--crit-ink);
  background: var(--crit-soft);
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
}
:root[data-theme="dark"] .nav-count,
.nav-count { color: #f5b7b7; background: rgba(208, 59, 59, .22); }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--nav-line); }
.account-mini {
  gap: 9px;
  padding: 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--nav-line);
  border-radius: var(--r-1);
}
/* O avatar e um <span> dentro de .account-mini, e a regra generica
   ".account-mini span { display: block }" vence ".avatar" por especificidade —
   com display block, o place-items: center e simplesmente ignorado e as
   iniciais grudam no topo do circulo. Reancorando o grid com peso suficiente. */
.account-mini .avatar { display: grid; place-items: center; }
.avatar {
  width: 30px;
  height: 30px;
  color: #fff;
  background: #2b333c;
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 11px;
  font-weight: 700;
}
.account-mini strong { color: var(--nav-ink-strong); font-size: 12px; font-weight: 600; }
.account-mini span { color: var(--nav-muted); font-size: 10px; }

/* --------------------------------------------------------------------------
   5. BARRA SUPERIOR
   -------------------------------------------------------------------------- */
.topbar {
  min-height: 66px;
  padding: 12px 24px;
  background: var(--page);
  border-bottom: 1px solid var(--line-strong);
  /* nada de vidro fosco: a barra e um plano solido, como regua de instrumento */
  backdrop-filter: none;
}
.topbar-title strong { font-family: var(--font-display); font-size: 14px; font-weight: 620; letter-spacing: -.015em; }
.topbar-title span { color: var(--ink-3); font-size: 11px; }
.toolbar-separator { height: 24px; background: var(--line-strong); }

.btn, .icon-btn {
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-1);
  transition: background var(--fast) linear, border-color var(--fast) linear, color var(--fast) linear;
}
.btn:hover, .icon-btn:hover {
  transform: none;
  background: var(--surface-2);
  border-color: var(--ink-4);
  box-shadow: var(--shadow-1);
}
.btn:active, .icon-btn:active { background: var(--surface-3); }
.btn .icon, .icon-btn .icon { color: var(--ink-3); }
.btn:hover .icon, .icon-btn:hover .icon { color: var(--ink-2); }

.btn.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand-strong);
  box-shadow: none;
}
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.primary .icon { color: rgba(255, 255, 255, .85); }
.btn.soft { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--brand-line); }
.btn.soft .icon { color: var(--brand); }
.btn.danger-soft { color: var(--crit-ink); background: var(--crit-soft); border-color: var(--crit-line); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn.small { min-height: 30px; padding: 0 9px; font-size: 11px; }
.icon-btn { width: 36px; padding: 0; }

.date-trigger { min-width: 208px; }
.date-trigger strong { font-size: 12px; font-weight: 600; }
.date-trigger span { color: var(--ink-3); font-size: 10px; font-weight: 500; }
.executive-btn.active {
  color: #fff;
  background: var(--inv-bg);
  border-color: var(--inv-bg);
}
.executive-btn.active .icon { color: rgba(255, 255, 255, .8); }

/* botão de tema */
.theme-btn .icon { color: var(--ink-3); }
:root[data-theme="dark"] .theme-btn .icon,
:root:not([data-theme="light"]) .theme-btn .icon { color: var(--ink-3); }

/* --------------------------------------------------------------------------
   6. CABEÇALHO DE PÁGINA
   -------------------------------------------------------------------------- */
.content { max-width: 1600px; padding: 22px 24px 44px; animation: desk-in .2s var(--ease) both; }
@keyframes desk-in { from { opacity: 0; transform: translateY(4px); } }

.page-head {
  align-items: flex-end;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  margin-bottom: 8px;
  color: var(--brand-ink);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 2.6vw, 33px);
  font-weight: 640;
  letter-spacing: -.03em;
  line-height: 1.08;
}
.page-head p { max-width: 720px; margin-top: 8px; color: var(--ink-2); font-size: 13px; }

.source-pill, .status-pill, .badge {
  padding: 4px 9px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: none;
}
.source-pill { color: var(--warn-ink); background: var(--warn-soft); border-color: var(--warn-line); }
.source-pill.connected { color: var(--good-ink); background: var(--good-soft); border-color: var(--good-line); }
.status-pill.active, .status-pill.ativo, .badge.positive { color: var(--good-ink); background: var(--good-soft); border-color: var(--good-line); }
.status-pill.paused, .status-pill.pausado, .badge.warning { color: var(--warn-ink); background: var(--warn-soft); border-color: var(--warn-line); }
.status-pill.ended, .status-pill.encerrado, .badge.neutral { color: var(--calm-ink); background: var(--calm-soft); border-color: var(--calm-line); }
/* Ligada mas sem veicular: usa o tom de atencao, com contorno tracejado para
   nao ser confundida com "Pausada" numa lida rapida. */
.status-pill.stalled {
  color: var(--warn-ink);
  background: transparent;
  border: 1px dashed var(--warn-line);
}
.badge.danger { color: var(--crit-ink); background: var(--crit-soft); border-color: var(--crit-line); }
.badge.good { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--brand-line); }
.badge { border-radius: var(--r-1); }

/* --------------------------------------------------------------------------
   7. CARTÕES
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1);
}
.card-head { padding: 15px 16px 11px; }
.card-head h2 { font-family: var(--font-display); font-size: 16px; font-weight: 620; letter-spacing: -.018em; }
.card-head h3 { font-family: var(--font-display); font-size: 14px; font-weight: 620; letter-spacing: -.012em; }
.card-head p { margin-top: 4px; color: var(--ink-3); font-size: 11.5px; }
.card-body { padding: 0 16px 16px; }
.text-link {
  color: var(--brand-ink);
  font-size: 11.5px;
  font-weight: 600;
  transition: color var(--fast) linear;
}
.text-link:hover { color: var(--brand); }
.muted { color: var(--ink-3); }
.mono { font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   8. KPIs
   -------------------------------------------------------------------------- */
.kpi-grid {
  gap: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1);
}
.kpi-card {
  min-height: 126px;
  padding: 15px 16px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  transition: background var(--fast) linear;
}
.kpi-card:hover { background: var(--surface-2); }
.kpi-card:last-child { border-right: 0; }
.kpi-card::before {
  inset: 0 auto auto 16px;
  width: 22px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--tone, var(--brand));
  opacity: 1;
}
.kpi-head {
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.kpi-info {
  width: 18px;
  height: 18px;
  color: var(--ink-4);
  background: transparent;
  border: 1px solid var(--line-strong);
}
.kpi-value {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 640;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.kpi-bottom { margin-top: 14px; }
.trend {
  padding: 3px 6px;
  border-radius: var(--r-1);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.trend.positive { color: var(--good-ink); background: var(--good-soft); }
.trend.negative { color: var(--crit-ink); background: var(--crit-soft); }
.trend.neutral { color: var(--calm-ink); background: var(--calm-soft); }
.kpi-compare { margin-top: 6px; color: var(--ink-3); font-size: 10px; }
.sparkline { width: 76px; height: 28px; }
.sparkline-line { stroke-width: 1.8; }
.sparkline-line.positive { stroke: var(--good); }
.sparkline-line.negative { stroke: var(--crit); }
.is-positive { color: var(--good-ink); }
.is-negative { color: var(--crit-ink); }

.secondary-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1);
}
.secondary-metric { min-height: 66px; padding: 12px 16px; }
.secondary-metric + .secondary-metric { border-left: 1px solid var(--line); }
.secondary-metric span { color: var(--ink-3); font-size: 10px; font-weight: 600; letter-spacing: .04em; }
.secondary-metric strong {
  margin-top: 7px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 620;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.secondary-metric small { top: 15px; right: 16px; font-size: 10px; font-weight: 700; }

/* --------------------------------------------------------------------------
   9. GRÁFICOS
   -------------------------------------------------------------------------- */
.grid-main, .grid-halves { gap: 10px; margin-bottom: 10px; }
.chart-card { min-height: 372px; }
.chart-controls { gap: 6px; }
.compact-select, .field select, .field input, .search-input {
  min-height: 36px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  font-size: 12px;
}
.compact-select { min-height: 32px; font-size: 11.5px; }

.chart-grid { stroke: var(--chart-grid); stroke-width: 1; stroke-dasharray: none; }
.chart-baseline { stroke: var(--chart-axis); stroke-width: 1; }
.chart-label, .axis-label { fill: var(--chart-ink); font-family: var(--font); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis-label { font-weight: 600; letter-spacing: .04em; }
.chart-line { stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-line-primary { stroke: var(--series-1); }
.chart-line-secondary { stroke: var(--series-2); stroke-dasharray: none; }
.chart-dot { fill: var(--chart-halo); stroke: var(--series-1); stroke-width: 2; }
.chart-dot.secondary { stroke: var(--series-2); }

/* crosshair + tooltip */
.chart-crosshair { stroke: var(--chart-axis); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart-frame.is-active .chart-crosshair { opacity: 1; }
.chart-frame { position: relative; }
.chart-marker { opacity: 0; transition: opacity var(--fast) linear; }
.chart-marker.is-active { opacity: 1; }
.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  box-shadow: var(--shadow-3);
  font-size: 11.5px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity var(--fast) linear;
}
.chart-tooltip.is-active { opacity: 1; }
.chart-tooltip .tt-date {
  display: block;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 600;
}
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.chart-tooltip .tt-swatch { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 2px; }
.chart-tooltip .tt-name { flex: 1; color: var(--ink-2); }
.chart-tooltip .tt-value { font-weight: 700; font-variant-numeric: tabular-nums; }

.chart-legend { gap: 16px; margin-top: 8px; color: var(--ink-2); font-size: 11.5px; }
.legend-item { gap: 7px; }
.legend-line { width: 14px; height: 3px; background: var(--series-1); border-radius: 2px; }
.legend-line.secondary { height: 3px; background: var(--series-2); }
.chart-note {
  margin-top: 10px;
  padding: 8px 10px;
  color: var(--ink-2);
  background: var(--surface-2);
  border-left: 2px solid var(--brand);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  font-size: 11px;
}

/* --------------------------------------------------------------------------
   10. "O QUE PRECISA DA SUA ATENÇÃO"
   -------------------------------------------------------------------------- */
.attention-card {
  color: var(--inv-ink);
  background: var(--inv-bg);
  border-color: var(--inv-bg);
  border-radius: var(--r-2);
  box-shadow: none;
}
.attention-card .card-head { border-bottom: 1px solid var(--inv-line); }
.attention-card .card-head h2 { color: var(--inv-ink); }
.attention-card .card-head p { color: var(--inv-ink-2); }
.attention-card .card-head > .icon { color: var(--inv-ink-2); }
.attention-summary { padding: 15px 20px 11px; color: var(--inv-ink-2); font-size: 12px; }
.attention-summary strong { color: var(--inv-ink); }
.attention-list { gap: 0; padding: 0 10px 10px; }
.attention-item {
  min-height: 50px;
  padding: 10px 10px;
  color: var(--inv-ink);
  background: transparent;
  border-width: 0 0 1px;
  border-color: var(--inv-line);
  border-radius: 0;
  transition: background var(--fast) linear;
}
.attention-item:last-child { border-bottom: 0; }
.attention-item:hover { background: rgba(255, 255, 255, .05); }
.attention-dot { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 16%, transparent); }
.attention-item.danger .attention-dot { background: var(--crit); box-shadow: 0 0 0 4px color-mix(in srgb, var(--crit) 18%, transparent); }
.attention-item.positive .attention-dot { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 18%, transparent); }
.attention-copy strong { font-size: 12px; font-weight: 600; }
.attention-copy span { margin-top: 3px; color: var(--inv-ink-2); font-size: 10.5px; }
.attention-item .icon { width: 15px; color: var(--inv-ink-2); }

/* --------------------------------------------------------------------------
   11. FUNIL — rampa ordinal de um único matiz (magnitude, não identidade)
   -------------------------------------------------------------------------- */
/* Largura e cor vem de --nivel, que o HTML declara em cada etapa.
   Antes vinham de nth-child, e as legendas de taxa (CTR, Conversao) contavam
   como irmas: a ultima etapa caia fora da regra e voltava a 100% de largura —
   um funil que afinava no meio e alargava no fim, dizendo o contrario dos
   numeros escritos nele. Com --nivel, funil de 3 ou de 5 etapas, com ou sem
   legenda entre elas, afina sempre na ordem certa. */
.funnel { --degraus: 3; --estreitamento: 44; }
.funnel-stage {
  width: calc(100% - var(--nivel, 0) * var(--estreitamento) * 1% / (var(--degraus) - 1));
  min-height: 56px;
  margin-inline: auto;
  padding: 9px 16px;
  color: #fff;
  /* O recorte acompanha a largura: em barra estreita, 4% fixos quase nao
     inclinavam. Assim a parede do funil mantem o mesmo angulo do topo a base. */
  clip-path: polygon(0 0, 100% 0, calc(100% - 7px) 100%, 7px 100%);
  transition: width .18s ease;
}
/* Rampa ordinal: escurece na direcao da conversao — o peso visual fica no
   resultado (leads), nao na exposicao. Nenhum passo mais claro que o degrau 250. */
.funnel-stage { background: color-mix(in oklab, #184f95 calc(var(--nivel, 0) * 100% / (var(--degraus) - 1)), #3987e5); }
.funnel-stage span { color: rgba(255, 255, 255, .78); font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.funnel-stage strong { font-family: var(--font-display); font-size: 20px; font-weight: 640; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.funnel-rate { color: var(--ink-3); font-size: 10.5px; font-weight: 600; }
.funnel-metrics { border-top: 1px solid var(--line); }
.funnel-metric + .funnel-metric { border-left: 1px solid var(--line); }
.funnel-metric span { color: var(--ink-3); font-size: 10px; letter-spacing: .06em; }
.funnel-metric strong { font-family: var(--font-display); font-size: 17px; font-weight: 620; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   12. TABELAS
   -------------------------------------------------------------------------- */
.table-card { border-radius: var(--r-2); }
.table-toolbar { padding: 0 18px 14px; }
.search-wrap .icon { color: var(--ink-4); }
/* A tabela rola DENTRO de si mesma.
   Antes o container crescia sem limite: a barra de rolagem horizontal ia parar
   depois da ultima linha, entao ver a coluna da direita exigia descer a pagina
   inteira primeiro. E o cabecalho, ja marcado como sticky, nao tinha contra o
   que grudar — rolava junto e a pessoa perdia de vista o que cada coluna era.
   Com altura maxima, a barra fica no rodape do quadro e o cabecalho gruda. */
.table-wrap { max-height: 68vh; overflow: auto; border-top: 1px solid var(--line); overscroll-behavior-x: contain; }

/* Primeira coluna ancorada: o nome da campanha/anuncio nao pode sumir quando se
   rola para o lado atras do CPL — e ler numero sem saber de quem e o numero e
   pior do que nao ver o numero. A sombra de profundidade ja existia; faltava a
   coluna de fato ficar parada. */
.table-wrap th:first-child,
.table-wrap td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.table-wrap th:first-child { z-index: 3; background: var(--surface-2); }
.table-wrap tbody tr:hover td:first-child { background: var(--surface-2); }
th {
  padding: 9px 14px;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
}
th.sortable:hover { color: var(--ink); }
td {
  height: 46px;
  padding: 8px 14px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
tbody tr:nth-child(even) { background: transparent; }
tbody tr:hover { background: var(--surface-2); }
th:first-child { left: 0; z-index: 3; }
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  color: var(--ink);
  background: var(--surface);
  /* mesma quantidade de camadas nos dois estados: box-shadow so interpola
     bem quando a lista tem o mesmo tamanho — por isso a segunda entra
     transparente aqui em vez de nao existir. */
  box-shadow: 1px 0 0 var(--line), 10px 0 12px -10px transparent;
}
tbody tr:hover td:first-child { background: var(--surface-2); }
.campaign-cell { min-width: 256px; }
.campaign-color { width: 3px; height: 28px; border-radius: 2px; }
.campaign-name strong { font-size: 12px; font-weight: 600; }
.campaign-name span { margin-top: 3px; color: var(--ink-3); font-size: 10.5px; }
.metric-strong { font-family: var(--font); font-size: 12.5px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.creative-thumb { border-radius: var(--r-1); }
.pagination-note { padding: 12px 16px; color: var(--ink-3); background: var(--surface-2); border-top: 1px solid var(--line); font-size: 10.5px; }

.score-ring {
  --score-color: var(--good);
  width: 34px;
  height: 34px;
  background: conic-gradient(var(--score-color) calc(var(--score) * 1%), var(--surface-3) 0);
}
.score-ring::after { width: 27px; height: 27px; background: var(--surface); }
.score-ring span { font-size: 10.5px; font-weight: 700; color: var(--ink); }
.score-ring.warning { --score-color: var(--warn); }
.score-ring.danger { --score-color: var(--crit); }
.score-ring.good { --score-color: var(--brand); }
tbody tr:hover .score-ring::after { background: var(--surface-2); }

/* --------------------------------------------------------------------------
   13. RANKINGS, DISTRIBUIÇÃO, INSIGHTS, ALERTAS
   -------------------------------------------------------------------------- */
.ranking-row {
  min-height: 54px;
  grid-template-columns: 26px minmax(120px, 1fr) 110px 68px 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  transition: background var(--fast) linear;
}
.ranking-row:hover { background: var(--surface-2) !important; }
.ranking-index { color: var(--ink-4); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ranking-name strong { font-size: 12px; font-weight: 600; }
.ranking-name span { margin-top: 3px; color: var(--ink-3); font-size: 10.5px; }
.mini-bar { height: 4px; background: var(--surface-3); border-radius: var(--r-pill); }
.mini-bar span { border-radius: inherit; }

.distribution-donut { width: 148px; height: 148px; }
.distribution-donut::before { width: 104px; height: 104px; background: var(--surface); }
.distribution-donut strong { font-family: var(--font-display); font-size: 17px; font-weight: 640; letter-spacing: -.025em; }
.distribution-donut span { color: var(--ink-3); font-size: 10px; }
.stack-head { color: var(--ink-2); font-size: 11px; }
.stack-head strong { font-variant-numeric: tabular-nums; }
.stacked-bar { height: 10px; gap: 2px; border-radius: var(--r-pill); background: var(--surface-3); }
.stacked-bar span:first-child { border-radius: var(--r-pill) 0 0 var(--r-pill); }
.stacked-bar span:last-child { border-radius: 0 var(--r-pill) var(--r-pill) 0; }
.distribution-note {
  color: var(--ink-2);
  background: var(--surface-2);
  border-left: 2px solid var(--brand);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  font-size: 11px;
}
.distribution-note .icon { color: var(--brand); }
.distribution-legend { display: grid; gap: 6px; margin-top: 14px; }
.distribution-legend > div { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-2); }
.distribution-legend i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 2px; }
.distribution-legend b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }

.insight-list { gap: 0; }
.insight-row {
  grid-template-columns: 96px 1fr;
  padding: 14px 2px;
  background: transparent;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.insight-row:last-child { border-bottom: 0; }
.insight-row span { color: var(--brand-ink); font-size: 10px; font-weight: 700; letter-spacing: .09em; }
.insight-row p { color: var(--ink-2); font-size: 12px; line-height: 1.5; }

.alert-list { gap: 0; }
.alert-row { min-height: 50px; padding: 10px 2px; border-width: 0 0 1px; border-color: var(--line); border-radius: 0; }
.alert-row:last-child { border-bottom: 0; }
.alert-icon { width: 28px; height: 28px; color: var(--warn-ink); background: var(--warn-soft); border-radius: var(--r-1); }
.alert-row.danger .alert-icon { color: var(--crit-ink); background: var(--crit-soft); }
.alert-row.positive .alert-icon { color: var(--good-ink); background: var(--good-soft); }
.alert-copy strong { font-size: 12px; font-weight: 600; }
.alert-copy span { margin-top: 4px; color: var(--ink-3); font-size: 10.5px; }
.rules-list > div { background: var(--surface-2); border-radius: var(--r-1); }
.rules-list span { color: var(--ink-2); }

/* --------------------------------------------------------------------------
   14. CRIATIVOS
   -------------------------------------------------------------------------- */
.creative-grid { gap: 10px; }
.creative-card { border-radius: var(--r-2); transition: border-color var(--fast) linear, box-shadow var(--fast) linear; }
.creative-card:hover { border-color: var(--ink-4); }
.creative-preview {
  min-height: 214px;
  padding: 17px;
  border-bottom: 1px solid var(--line);
}
.creative-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: linear-gradient(180deg, rgba(10, 14, 18, .06) 0%, rgba(10, 14, 18, .58) 100%);
}
.creative-preview::after { display: none; }
.creative-preview.has-media::before { background: linear-gradient(180deg, rgba(10, 14, 18, .1), rgba(10, 14, 18, .76)); }
.creative-art-head {
  color: rgba(255, 255, 255, .7);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .06em;
}
.creative-accent { opacity: .22; }
.creative-type {
  top: 44px;
  left: 17px;
  right: auto;
  padding: 3px 7px;
  color: rgba(255, 255, 255, .88);
  background: rgba(0, 0, 0, .28);
  border-color: rgba(255, 255, 255, .3);
  border-radius: var(--r-1);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .06em;
}
.creative-hook {
  max-width: 78%;
  margin-bottom: 26px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 620;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.creative-cta { color: rgba(255, 255, 255, .82); font-size: 9px; font-weight: 600; letter-spacing: .1em; }
.creative-body { padding: 15px; }
.creative-title h3 { font-family: var(--font-display); font-size: 13px; font-weight: 620; letter-spacing: -.015em; }
.creative-title p { color: var(--ink-3); font-size: 10.5px; }
.creative-score { font-family: var(--font-display); font-size: 18px; font-weight: 640; letter-spacing: -.025em; }
.creative-score small { color: var(--ink-3); font-size: 10px; }
.creative-metrics { gap: 8px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.creative-metric span { color: var(--ink-3); font-size: 9.5px; letter-spacing: .04em; }
.creative-metric strong { margin-top: 4px; font-size: 11.5px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   15. COMPARATIVOS
   -------------------------------------------------------------------------- */
.check-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  transition: border-color var(--fast) linear, background var(--fast) linear;
}
.check-card:hover { border-color: var(--ink-4); }
.check-card:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  box-shadow: inset 2px 0 var(--brand);
}
.check-card input { accent-color: var(--brand); }
.check-card strong { font-size: 11.5px; font-weight: 600; }
.check-card small { color: var(--ink-3); font-size: 10px; }
.bar-head { font-size: 11px; }
.bar-head strong { font-family: var(--font); font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-rank { color: var(--ink-4); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); }
.bar-track span { border-radius: var(--r-pill); }
.auto-conclusion {
  padding: 16px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--r-1) var(--r-1) 0;
}
.auto-conclusion .icon { color: var(--brand); }
.auto-conclusion strong { color: var(--brand-ink); font-size: 10px; letter-spacing: .09em; }
.auto-conclusion span { color: var(--ink-2); font-size: 12.5px; }

/* --------------------------------------------------------------------------
   16. DETALHE DE CAMPANHA
   -------------------------------------------------------------------------- */
.detail-hero {
  padding: 22px;
  color: var(--inv-ink);
  background: var(--inv-bg);
  border-color: var(--inv-bg);
  border-radius: var(--r-2);
  box-shadow: none;
}
.detail-hero::after { display: none; }
.detail-back { color: var(--inv-ink-2); font-size: 11px; font-weight: 600; }
.detail-back:hover { color: var(--inv-ink); }
.detail-top h1 { font-family: var(--font-display); font-size: 28px; font-weight: 640; letter-spacing: -.03em; }
.detail-meta { color: var(--inv-ink-2); font-size: 11px; }
.detail-score strong { font-family: var(--font-display); font-size: 40px; font-weight: 640; letter-spacing: -.035em; }
.detail-score span { color: var(--inv-ink-2); font-size: 10px; letter-spacing: .09em; }
.detail-kpis {
  gap: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1);
}
.detail-kpi { border: 0; border-right: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.detail-kpi:last-child { border-right: 0; }
.detail-kpi span { color: var(--ink-3); font-size: 10px; letter-spacing: .05em; }
.detail-kpi strong { font-family: var(--font-display); font-size: 19px; font-weight: 620; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.diagnosis-score { background: var(--inv-bg); border-radius: var(--r-2); }
.diagnosis-score strong { font-family: var(--font-display); font-size: 26px; font-weight: 640; letter-spacing: -.03em; }
.diagnosis-score span { color: var(--inv-ink-2); font-size: 10px; letter-spacing: .09em; }
.diagnosis-column h4 { color: var(--ink-3); font-size: 10.5px; font-weight: 700; letter-spacing: .07em; }
.diagnosis-column li { color: var(--ink-2); font-size: 12px; }
.diagnosis-column li::before { background: var(--good); }
.diagnosis-column.caution li::before { background: var(--warn); }
.suggestion {
  color: var(--ink-2);
  background: var(--surface-2);
  border-left: 2px solid var(--brand);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   17. HISTÓRICO, METAS, CONFIGURAÇÕES
   -------------------------------------------------------------------------- */
.history-timeline::before { background: var(--line-strong); }
.history-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-2); }
.history-item::before { background: var(--brand); border-color: var(--page); }
.history-date strong { font-weight: 620; }
.history-date span { color: var(--ink-3); font-size: 10.5px; }
.history-metric span { color: var(--ink-3); font-size: 9.5px; letter-spacing: .05em; }
.history-metric strong { font-weight: 650; font-variant-numeric: tabular-nums; }

.field label { color: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.input-prefix span { color: var(--ink-3); }
.settings-note { color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-1); font-size: 11.5px; }
.settings-note .icon { color: var(--ink-3); }
.progress { height: 6px; background: var(--surface-3); border-radius: var(--r-pill); }
.progress span { background: var(--good); border-radius: inherit; }
.progress.warning span { background: var(--warn); }
.goal-head { font-size: 11.5px; }
.goal-head strong { font-family: var(--font); font-weight: 650; font-variant-numeric: tabular-nums; }
.projection-item { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-1); }
.projection-item span { color: var(--ink-3); font-size: 9.5px; letter-spacing: .05em; }
.projection-item strong { font-family: var(--font-display); font-size: 18px; font-weight: 620; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.connection-facts { border: 1px solid var(--line); border-radius: var(--r-1); overflow: hidden; }
.connection-facts > div + div { border-left: 1px solid var(--line); }
.connection-facts span { color: var(--ink-3); font-size: 9.5px; letter-spacing: .08em; }
.connection-facts strong { font-family: var(--font); font-size: 12px; font-weight: 620; }
.organic-permission-list { border: 1px solid var(--line); border-radius: var(--r-1); overflow: hidden; }
/* O item precisava de layout proprio: sem ele, o icone, o titulo e a descricao
   eram tres inlines na mesma linha ("Descoberta automaticaPerfis vinculados...")
   colados na borda do cartao. */
.organic-permission-list > div { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; }
.organic-permission-list > div + div { border-top: 1px solid var(--line); }
.organic-permission-list .icon { flex: 0 0 auto; width: 15px; margin-top: 1px; color: var(--brand); }
.organic-permission-list strong, .organic-permission-list small { display: block; }
.organic-permission-list strong { font-size: 11.5px; font-weight: 600; }
.organic-permission-list small { margin-top: 2px; color: var(--ink-3); font-size: 10.5px; line-height: 1.45; }

/* --------------------------------------------------------------------------
   18. PERFORMANCE ORGÂNICA
   -------------------------------------------------------------------------- */
.organic-brand-panel {
  min-height: 168px;
  padding: 22px;
  color: #fff;
  background: var(--brand-strong);
  border-radius: var(--r-2);
}
.organic-brand-panel:nth-child(even) { background: var(--inv-bg); border-bottom: 0; }
.organic-brand-panel > div:first-child > span { font-size: 10px; font-weight: 600; letter-spacing: .12em; opacity: .72; }
.organic-brand-panel h2 { font-family: var(--font-display); font-size: 27px; font-weight: 640; letter-spacing: -.03em; }
.organic-brand-panel p { font-size: 11px; opacity: .72; }
.organic-brand-metrics span { font-size: 9.5px; font-weight: 600; letter-spacing: .06em; opacity: .7; }
.organic-brand-metrics strong { font-family: var(--font-display); font-size: 18px; font-weight: 620; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.organic-profile-cell > span, .organic-profile-cell > img { width: 38px; height: 38px; font-size: 11px; font-weight: 700; }
.organic-section-head { border-bottom: 1px solid var(--line); }
.organic-section-head span { color: var(--brand-ink); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.organic-section-head h2 { font-family: var(--font-display); font-size: 21px; font-weight: 640; letter-spacing: -.025em; }
.organic-section-head p { color: var(--ink-3); font-size: 11.5px; }
.organic-post-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-2); transition: border-color var(--fast) linear, box-shadow var(--fast) linear; }
.organic-post-card:hover { border-color: var(--ink-4); }
.organic-post-media { min-height: 178px; }
.organic-post-media::after { opacity: .26; }
.organic-post-media span { font-family: var(--font-mono); font-size: 10px; }
.organic-post-media strong { font-size: 9.5px; font-weight: 600; letter-spacing: .1em; }
.organic-post-body { padding: 15px; }
.organic-post-meta { color: var(--ink-3); font-size: 9.5px; letter-spacing: .05em; }
.organic-post-body h3 { font-family: var(--font-display); font-size: 14px; font-weight: 620; letter-spacing: -.018em; line-height: 1.25; }
.organic-post-stats { border-top: 1px solid var(--line); }
.organic-post-stats > div + div { border-left: 1px solid var(--line); }
.organic-post-stats span { color: var(--ink-3); font-size: 9px; letter-spacing: .05em; }
.organic-post-stats strong { font-family: var(--font); font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   19. POPOVER, TOAST, ESTADOS
   -------------------------------------------------------------------------- */
.popover {
  padding: 12px;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-3);
}
.popover-title { color: var(--ink); font-size: 11.5px; font-weight: 700; }
.popover-divider { background: var(--line); }
.range-option { color: var(--ink-2); border-radius: var(--r-1); font-size: 11.5px; font-weight: 500; }
.range-option:hover { background: var(--surface-2); }
.range-option.active {
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-color: var(--brand-line);
  font-weight: 650;
}
.popover-backdrop { background: transparent; }

/* O intervalo que está valendo, escrito por extenso dentro do próprio popover.
   Sem isso a pessoa tem que fechar o popover para conferir no topo se o preset
   que ela clicou é mesmo o período que os números estão usando. */
.popover-hint {
  margin: 0 0 9px;
  color: var(--ink-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.toast {
  color: var(--inv-ink);
  background: var(--inv-bg);
  border: 1px solid var(--inv-line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-3);
  font-size: 12px;
}
.toast .icon { color: var(--good); }

.empty-state .icon { width: 30px; height: 30px; color: var(--ink-4); }
.empty-state h3 { font-family: var(--font-display); font-size: 15px; font-weight: 620; }
.empty-state p { color: var(--ink-3); font-size: 12px; }

.executive-mode .topbar-title strong::after { content: " · Modo Executivo"; color: var(--brand-ink); }
.executive-summary {
  padding: 24px;
  color: var(--inv-ink);
  background: var(--inv-bg);
  border-color: var(--inv-bg);
  border-radius: var(--r-2);
  box-shadow: none;
}
.executive-summary .eyebrow { color: var(--brand-strong); }
.executive-summary h2 { font-family: var(--font-display); font-size: 25px; font-weight: 620; letter-spacing: -.028em; }
.executive-summary p { color: var(--inv-ink-2); }
.overall-score strong { font-family: var(--font-display); font-size: 68px; font-weight: 640; letter-spacing: -.045em; }
.overall-score span { color: var(--ink-3); font-size: 10.5px; letter-spacing: .09em; }

/* --------------------------------------------------------------------------
   19b. OFÍCIO — o que separa uma tela montada de uma ferramenta usada
   -------------------------------------------------------------------------- */

/* Tracking óptico: quanto maior o corpo, mais fechado o espacejamento. Texto
   pequeno respira, número grande fecha. Isso é ajuste manual, não escala
   automática — é o que faz o título parecer desenhado e não gerado. */
.page-head h1 { letter-spacing: -.032em; word-spacing: .02em; }
.kpi-value { letter-spacing: -.04em; }
.overall-score strong { letter-spacing: -.05em; }
.detail-score strong { letter-spacing: -.045em; }
.secondary-metric strong, .funnel-metric strong, .projection-item strong { letter-spacing: -.02em; }

/* Marca curta sob a régua do cabeçalho: uma assinatura de 44px que ancora a
   coluna de texto e dá origem ao alinhamento de tudo abaixo. */
.page-head { position: relative; }
.page-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 44px;
  height: 2px;
  background: var(--brand);
}

/* A coluna fixa só projeta sombra quando existe conteúdo escondido à esquerda.
   Parado, é só uma linha. */
.table-wrap td:first-child { transition: box-shadow var(--fast) linear; }
.table-wrap.is-scrolled td:first-child { box-shadow: 1px 0 0 var(--line), 10px 0 12px -10px rgba(15, 23, 31, .35); }
:root[data-theme="dark"] .table-wrap.is-scrolled td:first-child { box-shadow: 1px 0 0 var(--line), 10px 0 12px -10px rgba(0, 0, 0, .8); }

/* IDs da Meta: o clique seleciona o identificador inteiro, porque quem opera
   copia esse número para o Gerenciador dezenas de vezes por dia. */
.mono {
  color: var(--ink-4);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: -.01em;
  user-select: all;
  cursor: text;
}

/* Chip de atalho de teclado. */
kbd {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 5px;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-1);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
}
.search-wrap { position: relative; }
.search-wrap kbd {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  pointer-events: none;
  transition: opacity var(--fast) linear;
}
.search-wrap:focus-within kbd, .search-wrap.has-value kbd { opacity: 0; }

/* Barra de rolagem alinhada ao tema, fina, sem trilho. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); background-clip: content-box; }

::selection { color: var(--brand-ink); background: var(--brand-soft); }

/* Linha de tabela navegável por teclado, como qualquer grade de dados séria. */
tbody tr.clickable:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* Cabeçalho de coluna ordenada: a seta não empurra o texto ao alternar. */
th.sortable { position: relative; padding-right: 22px; }
th.sortable .sort-caret { position: absolute; right: 9px; color: var(--brand); }

/* Estado de carregamento honesto: a régua do topo pulsa enquanto sincroniza. */
.topbar.is-syncing::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  animation: sync-sweep 1.1s linear infinite;
}
@keyframes sync-sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.topbar { position: sticky; overflow: hidden; }

/* Checklist de diagnóstico da conexão. */
.diagnose-list { display: grid; margin: 14px 0 12px; border: 1px solid var(--line); border-radius: var(--r-1); overflow: hidden; }
.diagnose-row { display: grid; grid-template-columns: 74px 1fr; align-items: start; gap: 12px; padding: 12px 13px; }
.diagnose-row + .diagnose-row { border-top: 1px solid var(--line); }
.diagnose-row.fail { background: var(--crit-soft); }
.diagnose-row.warn { background: var(--warn-soft); }
.diagnose-row .badge { justify-content: center; }
.diagnose-row strong, .diagnose-row span, .diagnose-row em { display: block; }
.diagnose-row strong { font-size: 12px; font-weight: 620; }
.diagnose-row span { margin-top: 3px; color: var(--ink-2); font-size: 11.5px; }
.diagnose-row em { margin-top: 6px; padding-left: 9px; border-left: 2px solid var(--brand); color: var(--ink-2); font-size: 11.5px; font-style: normal; }
@media (max-width: 640px) { .diagnose-row { grid-template-columns: 1fr; gap: 7px; } }

/* Seletor de contas de anuncios na barra superior. Deixou de ser um <select>
   quando passou a aceitar varias contas: um menu nativo nao mostra marcacao
   multipla, e sem ver o que esta marcado ninguem confia no recorte. */
.account-picker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  height: 36px;
  padding: 0 8px 0 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.account-picker > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-picker .icon { width: 15px; color: var(--ink-3); flex: 0 0 auto; }
.account-picker:hover { border-color: var(--brand-line); }
.account-picker:focus-visible { border-color: var(--brand); box-shadow: var(--ring); outline: none; }
@media (max-width: 960px) { .account-picker { max-width: 170px; } }
@media (max-width: 640px) { .account-picker { max-width: 120px; padding-left: 7px; font-size: 11px; } }

/* Nota de metodologia recolhível. Explicação de como um número é calculado
   pertence à tela — mas fechada por padrão: quem confere abre uma vez e
   pronto. Três parágrafos didáticos empilhados no fim de cada tela é cara de
   tutorial gerado, não de ferramenta que alguém usa todo dia. */
.method-note { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); }
.method-note summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.method-note summary::-webkit-details-marker { display: none; }
.method-note summary::before { content: "›"; transition: transform .15s; }
.method-note[open] summary::before { transform: rotate(90deg); }
.method-note[open] summary { border-bottom: 1px solid var(--line); }
.method-note .method-body { display: grid; gap: 8px; padding: 11px 13px; color: var(--ink-2); font-size: 11.5px; line-height: 1.55; }
.method-note .method-body strong { color: var(--ink); }

/* Quanto do total o recorte esta mostrando, ao lado do proprio filtro. Um
   painel filtrado que nao diz que esta filtrado e como alguem le "12" e
   entende "12 no total". */
.filter-note { color: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.filter-note .text-link { font-size: inherit; }

.account-popover { top: 69px; right: 190px; width: 316px; }
/* A lista rola dentro de si mesma: com 7 polos ja passa da altura util da tela
   em notebook, e um popover que empurra o rodape para fora esconde o botao de
   fechar. */
.account-list { max-height: 46vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.account-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-1);
  text-align: left;
  cursor: pointer;
}
.account-option:hover { background: var(--surface-2); }
.account-option.active { background: var(--brand-soft); border-color: var(--brand-line); }
/* A caixa ocupa o espaco mesmo vazia, senao o texto dança lateralmente a cada
   marcacao e a lista inteira parece se mexer. */
.account-check {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  background: var(--surface);
}
.account-option.active .account-check { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--brand); }
.account-check .icon { width: 12px; }
.account-name { display: grid; gap: 1px; min-width: 0; }
.account-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.account-name span { color: var(--ink-3); font-size: 10.5px; }
@media (max-width: 640px) { .account-popover { right: 12px; left: 12px; width: auto; } }

/* Tela de login: substitui a aplicacao inteira, nao sobrepoe. */
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-panel { width: 100%; max-width: 360px; }
.login-card { display: grid; gap: 14px; padding: 28px; }
.login-card .brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--brand); border-radius: var(--r-1); }
.login-card .brand-mark b { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.login-card h1 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 640; letter-spacing: -.028em; }
.login-card p { margin: -8px 0 4px; color: var(--ink-3); font-size: 12.5px; }
.login-card .btn { justify-content: center; min-height: 40px; }
.login-error { padding: 10px 12px; color: var(--crit-ink); background: var(--crit-soft); border: 1px solid var(--crit-line); border-radius: var(--r-1); font-size: 12px; }

/* Marca de valor aproximado (alcance somado entre contas). */
.secondary-metric span .metric-flag { display: inline-block; margin-left: 6px; padding: 1px 5px; color: var(--warn-ink); background: var(--warn-soft); border-radius: var(--r-1); font-size: 8.5px; font-weight: 700; letter-spacing: 0; text-transform: none; cursor: help; }

/* --------------------------------------------------------------------------
   20. RESPONSIVO — reafirmado no fim da cascata
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
  :root { --sidebar: 226px; }
  .content { padding: 24px 24px 40px; }
  .kpi-grid { grid-template-columns: repeat(5, 1fr); }
  .kpi-card { min-height: 140px; padding: 16px; border-top: 0; border-right: 1px solid var(--line); }
  .kpi-card:last-child { border-right: 0; }
  .kpi-card::before { left: 16px; }
  .kpi-value { font-size: 26px; }
  .creative-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
  .content { padding: 22px 20px 38px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card { min-height: 136px; border-right: 1px solid var(--line); }
  .kpi-card:nth-child(even) { border-right: 0; }
  .kpi-card:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpi-value { font-size: 28px; }
  .detail-kpis { grid-template-columns: repeat(3, 1fr); }
  .detail-kpi:nth-child(3n) { border-right: 0; }
  .detail-kpi:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .organic-brand-grid, .organic-post-grid { grid-template-columns: 1fr; }
  .table-wrap { scrollbar-width: thin; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { min-height: 58px; padding: 9px 13px; }
  .content { padding: 18px 14px 32px; }
  .page-head { padding-bottom: 15px; }
  .page-head h1 { font-size: 25px; }
  .page-head p { font-size: 12.5px; }
  .page-context { align-items: flex-start; flex-direction: column; }
  .kpi-card { min-height: 128px; padding: 15px; }
  .kpi-card::before { left: 15px; }
  .kpi-value { font-size: 24px; }
  .secondary-metric { min-height: 70px; padding: 13px; }
  .secondary-metric strong { font-size: 16px; }
  .card-head { padding: 16px 16px 12px; }
  .card-body { padding: 0 16px 16px; }
  .card-head h2 { font-size: 15px; }
  .creative-grid { grid-template-columns: 1fr; }
  .creative-preview { min-height: 228px; }
  .connection-facts { grid-template-columns: 1fr; }
  .connection-facts > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .organic-brand-panel { align-items: flex-start; flex-direction: column; }
  .organic-brand-metrics { width: 100%; grid-template-columns: repeat(3, 1fr); }
  .organic-brand-metrics span, .organic-brand-metrics strong { text-align: left; }
  .organic-section-head { align-items: flex-start; flex-direction: column; }
  .organic-post-media { min-height: 210px; }
  .ranking-row { grid-template-columns: 22px minmax(0, 1fr) 68px 14px; width: 100% !important; gap: 8px; padding: 12px 14px; }
  .ranking-row .mini-bar { display: none; }
  .detail-kpis { grid-template-columns: repeat(2, 1fr); }
  .detail-kpi:nth-child(n) { border-right: 1px solid var(--line); }
  .detail-kpi:nth-child(even) { border-right: 0; }
  .chart-tooltip { min-width: 132px; font-size: 11px; }
}

/* --------------------------------------------------------------------------
   21. IMPRESSÃO / PDF — força o tema claro
   -------------------------------------------------------------------------- */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --page: #fff;
    --surface: #fff;
    --surface-2: #f4f6f8;
    --surface-3: #e8ecf0;
    --line: #d8dee4;
    --line-strong: #c3cbd3;
    --ink: #11161b;
    --ink-2: #38424c;
    --ink-3: #5c6771;
    --shadow-1: none;
    --shadow-2: none;
    --shadow-3: none;
  }
  body { background: #fff; }
  /* A rolagem interna da tabela vale na tela, nao no papel: com altura maxima,
     a impressao cortaria tudo depois da primeira dobra. */
  .table-wrap { max-height: none; overflow: visible; }
  .table-wrap th:first-child, .table-wrap td:first-child { position: static; }
  /* A metodologia e recolhivel na tela porque quem usa todo dia ja sabe. No
     relatorio impresso ela precisa estar aberta: quem le no papel nao clica. */
  .method-note summary { display: none; }
  .method-note .method-body { display: grid !important; }
  .sidebar, .sidebar-overlay, .topbar, .page-actions, .table-toolbar, .text-link, .btn, .icon-btn, .popover, .popover-backdrop, .toast-region { display: none !important; }
  .main { margin: 0; }
  .content { max-width: none; padding: 0; animation: none; }
  .card, .kpi-grid, .detail-kpis, .secondary-strip { break-inside: avoid; box-shadow: none; }
  .chart-tooltip { display: none !important; }
}

/* --------------------------------------------------------------------------
   22. CANAL DE ACESSIBILIDADE — forced-colors
   -------------------------------------------------------------------------- */
@media (forced-colors: active) {
  .card, .kpi-card, .btn, .icon-btn, .popover { border: 1px solid CanvasText; }
  .chart-line, .sparkline-line { forced-color-adjust: none; }
  .trend, .badge, .status-pill, .source-pill { border: 1px solid CanvasText; }
}
