:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1c2330; --muted: #677084; --line: #e1e4ea;
  --accent: #2456d6; --accent-ink: #fff; --ok: #1a8a4a; --bad: #c8322b; --warn: #b26a00;
  --ok-bg: #e5f5ec; --bad-bg: #fbe9e7; --warn-bg: #fdf1dc; --chip: #eef0f4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --ink: #e7eaf0; --muted: #98a1b3; --line: #2c323d;
    --accent: #6b93f5; --accent-ink: #0e1220; --ok: #5bd08a; --bad: #f0807a; --warn: #f0b860;
    --ok-bg: #173324; --bad-bg: #3a1d1b; --warn-bg: #3a2c12; --chip: #272d38;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.brand { font-weight: 700; margin-right: 14px; padding: 14px 0; color: var(--ink); }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.top nav a { padding: 14px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.top nav a.on { color: var(--ink); border-color: var(--accent); }
.top nav a:hover { text-decoration: none; color: var(--ink); }
.top form { margin: 0; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: space-between; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head h1 { margin: 0; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--chip); font-size: 12px; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

.btn, button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 14px; border-radius: 8px; display: inline-block; }
.btn:hover, button:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; max-width: 100%;
}
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }
.field { margin-bottom: 14px; }
.field input[type=text], .field input[type=number], .field select { width: 100%; }
.help { color: var(--muted); font-size: 13px; margin-top: 3px; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--bad); font-size: 13px; }

.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--ok-bg); color: var(--ok); }
.msg.error { background: var(--bad-bg); color: var(--bad); }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--warn-bg); color: var(--warn); display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }

.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.preview { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 520px; }
.preview blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--accent); }
.preview tg-spoiler { background: var(--chip); border-radius: 4px; }
.fakebtn { max-width: 520px; margin-top: 6px; text-align: center; padding: 8px; border-radius: 8px; background: var(--chip); font-weight: 600; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar button { padding: 3px 10px; font-size: 13px; }
.picker { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.picker label { display: flex; gap: 8px; font-weight: 400; margin: 0; padding: 3px 0; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.bars i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .8; }

.login { max-width: 360px; margin: 9vh auto; }
.login input { width: 100%; }
.login button { width: 100%; margin-top: 6px; }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; margin-bottom: 6px; }
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.chart .col i { display: flex; align-items: flex-end; width: 100%; min-height: 1px; background: var(--chip); border-radius: 2px 2px 0 0; }
.chart .col u { display: block; width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; }
.chart .col:hover i { outline: 1px solid var(--accent); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--chip); border: 1px solid var(--line); }
.key.tagged { background: var(--accent); border-color: var(--accent); }
summary { cursor: pointer; }
