:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #2f6fed; --accent-weak: #e8efff; --ok: #1a7f4b; --ok-weak: #e3f5ec;
  --warn: #9a6400; --warn-weak: #fff4dc; --err: #b42318; --err-weak: #fde8e6; --info-weak: #eef2f8;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1a1f27; --text: #e6e9ef; --muted: #98a1b3; --line: #2a313c;
    --accent: #6d9bff; --accent-weak: #1e2a44; --ok: #5bd197; --ok-weak: #15302a;
    --warn: #f1c069; --warn-weak: #3a2e14; --err: #ff8a80; --err-weak: #3b1d1b; --info-weak: #1f2633;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
nav.side .brand { font-weight: 700; font-size: 16px; margin: 0 8px 16px; }
nav.side a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); }
nav.side a:hover, nav.side a.active { background: var(--accent-weak); text-decoration: none; }
nav.side form { margin-top: 16px; }
main { padding: 20px 28px 60px; max-width: 1400px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 14px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } nav.side { position: static; height: auto; } .g2, .g3, .g4 { grid-template-columns: 1fr; } main { padding: 16px; } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--info-weak); white-space: nowrap; }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.err { background: var(--err-weak); color: var(--err); }
.badge.acc { background: var(--accent-weak); color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; white-space: pre-wrap; }
.flash.ok { background: var(--ok-weak); color: var(--ok); }
.flash.error { background: var(--err-weak); color: var(--err); }
.flash.warn { background: var(--warn-weak); color: var(--warn); }
.flash.info { background: var(--info-weak); }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; max-width: 100%; }
textarea { width: 100%; min-height: 80px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 6px 0 3px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > div { min-width: 120px; }
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px; padding: 6px 12px; display: inline-block; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); }
button.danger { background: var(--err); border-color: var(--err); }
button.small { padding: 2px 8px; font-size: 12px; }
form.inline { display: inline; }
.chat { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg); }
.msg { padding: 7px 10px; border-radius: 8px; margin: 6px 0; background: var(--panel); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.msg.me { background: var(--accent-weak); margin-left: 40px; }
.msg.blocked { border-color: var(--err); background: var(--err-weak); }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; white-space: normal; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.corridor td { padding: 5px 8px; }
.pre { white-space: pre-wrap; }
details summary { cursor: pointer; color: var(--accent); }
.right { text-align: right; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.topbar h1 { margin: 0; }
.searchbox input { width: 260px; }
.pos { color: var(--ok); } .neg { color: var(--err); }
