:root {
  --bg: #f5f4f0;
  --panel: #ffffff;
  --ink: #17191c;
  --ink-2: #4a4f57;
  --ink-3: #8a9099;
  --line: #e4e2dc;
  --line-2: #efede8;
  --side: #121417;
  --side-ink: #c9ccd1;
  --accent: #e8590c;
  --accent-soft: #fff0e6;
  --good: #1f8a4c;
  --good-soft: #e6f4ec;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --meta: #2f6fde;
  --google: #20a464;
  --radius: 10px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: -0.03em; color: #fff;
}
.brand-name { font-weight: 600; font-size: 14px; line-height: 1.15; }
.brand-name small { display: block; color: #7d838c; font-weight: 400; font-size: 11px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: #6b7179; padding: 16px 10px 6px; }
.side a.nav {
  display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 7px;
  text-decoration: none; color: var(--side-ink); font-size: 13.5px;
}
.side a.nav:hover { background: #1d2025; color: #fff; }
.side a.nav.on { background: #23272d; color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.side .count { background: var(--accent); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #23272d; font-size: 12.5px; }
.side-foot a { color: #9aa0a8; text-decoration: none; }
.side-foot a:hover { color: #fff; }

.main { padding: 26px 32px 60px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); margin-top: 3px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel, .stack > * + * { margin-top: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.panel-body { padding: 16px 18px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: 2fr 1fr; }
.empty { padding: 28px 18px; text-align: center; color: var(--ink-3); }

/* ---------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.kpi { padding: 14px 16px; border-right: 1px solid var(--line-2); }
.kpi:last-child { border-right: 0; }
.kpi .label { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .value { font-size: 21px; font-weight: 600; margin: 3px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.kpi.flag { background: var(--bad-soft); }

/* ---------- tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fbfaf8; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfbf9; }
.table-wrap { overflow-x: auto; }
td .title { font-weight: 500; }
td a.title { text-decoration: none; }
td a.title:hover { text-decoration: underline; }
.sub-line { font-size: 12px; color: var(--ink-3); }

/* ---------- badges */
.delta { font-size: 11.5px; font-weight: 500; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag.meta { background: #e9f0fd; color: var(--meta); }
.tag.google_ads { background: #e5f5ec; color: var(--google); }
.tag.ga4 { background: #fdf0e3; color: #c25e00; }
.tag.alta, .tag.bad, .tag.erro { background: var(--bad-soft); color: var(--bad); }
.tag.media, .tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.baixa { background: var(--line-2); color: var(--ink-2); }
.tag.good, .tag.ok, .tag.validada { background: var(--good-soft); color: var(--good); }
.tag.em_teste { background: #eef0ff; color: #4c5bd4; }
.tag.revertida, .tag.sem_efeito { background: var(--line-2); color: var(--ink-3); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--good); } .dot.warn { background: #e0a100; } .dot.bad { background: var(--bad); } .dot.none { background: #cfd2d6; }

/* ---------- forms */
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #d7d4cc; border-radius: 8px; padding: 8px 10px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #ffd2b8; border-color: var(--accent); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); margin: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; max-height: 220px; overflow: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 500; padding: 7px 13px; border-radius: 8px;
  border: 1px solid #d7d4cc; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #b9b5ab; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2b2f35; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: #d4500b; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.seg { display: inline-flex; border: 1px solid #d7d4cc; border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 6px 12px; text-decoration: none; font-size: 12.5px; color: var(--ink-2); border-right: 1px solid #ebe8e1; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--ink); color: #fff; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters select { width: auto; min-width: 180px; }

/* ---------- flashes */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--good-soft); color: #145c33; border: 1px solid #c4e5d1; }
.flash.erro { background: var(--bad-soft); color: #8f1d1d; border-color: #f3c7c7; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--warn-soft); color: #6d4a10; border: 1px solid #f1dcb3; font-size: 13px; }
.secret { font-family: var(--mono); background: #121417; color: #ffd8c2; padding: 2px 8px; border-radius: 6px; }

/* ---------- alerts list */
.alert-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); align-items: start; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--ink-3); }
.alert-item .bar.alta { background: var(--bad); } .alert-item .bar.media { background: #e0a100; } .alert-item .bar.baixa { background: #cfd2d6; }

/* ---------- impact */
.impact { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.impact .cell { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.impact .cell .l { font-size: 11.5px; color: var(--ink-3); }
.impact .cell .v { font-variant-numeric: tabular-nums; font-size: 13px; margin-top: 2px; }
.impact .cell.bom { border-color: #bfe2cd; background: var(--good-soft); }
.impact .cell.ruim { border-color: #f1c4c4; background: var(--bad-soft); }
.mini-impact { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }

/* ---------- analysis */
.prose { max-width: 820px; font-size: 14.5px; line-height: 1.65; }
.prose h2 { font-size: 17px; margin: 26px 0 8px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.prose h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.prose h3 { font-size: 14.5px; margin: 18px 0 6px; }
.prose table { margin: 10px 0; font-size: 13px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 9px; }
.prose li { margin-bottom: 5px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.chart-box { position: relative; height: 260px; }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--side); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 30px; }
.login-card .brand { color: var(--ink); padding: 0 0 22px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; gap: 4px; }
  .brand { padding: 4px 8px; width: 100%; }
  .nav-label, .side-foot { display: none; }
  .main { padding: 18px 16px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line-2); }
}
.grid > .panel { margin-top: 0; }
.main { min-width: 0; }
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side a.nav.client { display: none; }
  .side a.nav { padding: 6px 9px; font-size: 13px; }
}
