:root {
  --bg: #f4f6f7; --card: #fff; --ink: #1c2a2a; --muted: #66767a; --line: #dde4e6;
  --brand: #1f5f5b; --brand-ink: #fff; --side: #14403d; --good: #1b7f4c; --bad: #b3261e; --warn: #9a6700;
  --good-bg: #e3f4ea; --bad-bg: #fbe7e5; --warn-bg: #fff3d6;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1717; --card: #172221; --ink: #e5eeee; --muted: #93a6a8; --line: #2a3a39;
    --brand: #4fb3aa; --brand-ink: #062623; --side: #0b2220; --good-bg: #123524; --bad-bg: #3b1a17; --warn-bg: #3a2e0c;
    --good: #6fd9a0; --bad: #ff9c94; --warn: #f0c35c; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; }
a { color: var(--brand); }
code { background: color-mix(in srgb, var(--line) 60%, transparent); padding: 1px 6px; border-radius: 5px; font-size: 13px; overflow-wrap: anywhere; }
.side { width: 220px; background: var(--side); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 800; font-size: 18px; margin-bottom: 14px; }
.brand small { display: block; font-weight: 500; opacity: .7; font-size: 12px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side a { color: #fff; text-decoration: none; padding: 9px 12px; border-radius: 8px; opacity: .85; }
.side a:hover { background: rgba(255,255,255,.1); opacity: 1; }
.side a.on { background: rgba(255,255,255,.18); opacity: 1; font-weight: 700; }
.side .out { opacity: .7; }
main { flex: 1; padding: 22px 28px 60px; max-width: 1100px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
h1 { margin: 0; font-size: 24px; }
h2 { margin: 0 0 10px; font-size: 17px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card.danger { border-color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 14px 0 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi span { display: block; color: var(--muted); font-size: 13px; }
.kpi b { font-size: 26px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kv th { width: 120px; }
.units td:first-child { width: 38%; }
input, select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input[type=checkbox] { width: auto; }
input.narrow { width: 80px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
label input, label select { margin-top: 4px; font-weight: 400; }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; }
label.check input { margin-top: 5px; }
.form { max-width: 560px; }
.form.cols { max-width: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline input, .inline select { width: auto; flex: 1; min-width: 150px; }
.row-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.row-head h2 { flex: 1; min-width: 200px; margin: 0; }
.row-head label { margin: 0; }
.btn { display: inline-block; font: inherit; font-weight: 700; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash.ok { background: var(--good-bg); color: var(--good); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--line); }
.pill.yes, .pill.ev-impression, .pill.ev-reward { background: var(--good-bg); color: var(--good); }
.pill.no, .pill.ev-fail { background: var(--bad-bg); color: var(--bad); }
.pill.ev-click { background: var(--warn-bg); color: var(--warn); }
.muted { color: var(--muted); }
.range { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.range label { margin: 0; }
.range input, .range select { width: auto; }
.bars { display: flex; gap: 8px; align-items: flex-end; height: 190px; padding-top: 10px; overflow-x: auto; }
.bar { flex: 1 0 44px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; text-align: center; }
.bar .col { width: 70%; background: var(--brand); border-radius: 5px 5px 0 0; }
.bar small { font-size: 11px; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; }
.secret { user-select: all; }
.login { align-items: center; justify-content: center; }
.login-card { width: min(380px, 92vw); }
.login-card h1 small { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
@media (max-width: 800px) {
  body { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { margin: 0 10px 0 0; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
}
