:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --line: #e4e4df;
  --text: #191919;
  --text-2: #666666;
  --accent: #5b3fd6;
  --accent-ink: #ffffff;
  --series-1: #257de0;
  --series-2: #f47230;
  --good: #0aac23;
  --critical: #dc3c3d;
  --warn-bg: #fff6de;
  --radius: 12px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111111;
    --surface: #191919;
    --surface-2: #222222;
    --line: #2f2f2f;
    --text: #efefef;
    --text-2: #9c9c9c;
    --accent: #9887ef;
    --accent-ink: #111111;
    --series-1: #338ced;
    --series-2: #e76624;
    --warn-bg: #33290d;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 6px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 10px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 18px; letter-spacing: -0.01em; }
.brand small { display: block; font-weight: 500; color: var(--text-2); font-size: 12px; margin-top: 2px; }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--surface-2); color: var(--accent); }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--text-2); }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 4px 10px; }
  .nav { display: flex; flex-wrap: wrap; }
  .side .foot { margin: 0 0 0 auto; }
  .main { padding: 18px 14px 50px; }
}

/* cards and tiles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.tile .label { color: var(--text-2); font-size: 12px; font-weight: 600; }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.hero { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.hero .big { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.section { margin-top: 22px; }

/* controls */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 550; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--critical); }
button:disabled { opacity: 0.55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
input, textarea, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 10px 0 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); }
.pill.good .dot { background: var(--good); }
.pill.bad .dot { background: var(--critical); }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .band:hover .hit { fill: var(--surface-2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px; opacity: 0; transition: opacity 0.08s; z-index: 5; }
.tip.on { opacity: 1; }
.barlist .item { display: grid; grid-template-columns: 150px 1fr 56px; gap: 10px; align-items: center; padding: 5px 0; }
.barlist .track { height: 14px; }
.barlist .fill { height: 14px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.barlist .n { text-align: right; font-variant-numeric: tabular-nums; }

/* campaigns */
.campaign summary { cursor: pointer; list-style: none; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.campaign summary::-webkit-details-marker { display: none; }
.campaign .name { font-weight: 650; font-size: 15px; }
.campaign .stats { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; color: var(--text-2); font-size: 13px; }
.campaign .stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.campaign .body { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
dl { margin: 0; display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; }
dt { color: var(--text-2); }
dd { margin: 0; }

/* inbox */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .inbox { grid-template-columns: 1fr; } }
.threads { padding: 6px; max-height: 78vh; overflow: auto; }
.threads a { display: block; padding: 10px; border-radius: 8px; color: var(--text); }
.threads a:hover { background: var(--surface-2); text-decoration: none; }
.threads a.on { background: var(--surface-2); }
.threads .who { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.threads .snip { color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; white-space: pre-wrap; word-wrap: break-word; }
.msg.in { background: var(--surface-2); }
.msg .meta { font-size: 12px; color: var(--text-2); margin-bottom: 6px; white-space: normal; }
.notice { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 26px; }
.error { color: var(--critical); font-size: 13px; min-height: 18px; margin-top: 8px; }
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre { background: var(--surface-2); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0 14px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre code { background: none; padding: 0; }
.empty { color: var(--text-2); padding: 26px; text-align: center; }
