:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --bg: #f5f6f8; --surface: #ffffff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb; --grid: #eef0f3;
  --accent: #2f6fed; --accent-soft: #e8f0fe; --series2: #9aa7bd;
  --up: #0f8a4f; --down: #c93a3a; --warn: #c07a00; --info: #2f6fed;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #181b21; --text: #e7e9ee; --muted: #9098a6; --line: #2a2f38; --grid: #232830;
    --accent: #6c9bff; --accent-soft: #1d2940; --series2: #5d6778;
    --up: #3ccf86; --down: #ff6b6b; --warn: #f0b440; --info: #6c9bff;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); } .info { color: var(--info); }
.error { color: var(--down); font-weight: 600; }
.hidden { display: none !important; }

header.top { display: flex; align-items: center; gap: 24px; padding: 0 16px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header.top .brand { font-weight: 700; color: var(--text); }
header.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
header.top nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
header.top nav a.on, header.top nav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.narrow { max-width: 420px; margin: 60px auto; }
.chead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--text); }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tl { color: var(--muted); font-size: 12px; } .tv { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.delta { font-size: 12px; font-weight: 600; color: var(--muted); } .delta.up { color: var(--up); } .delta.down { color: var(--down); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.pcard { color: var(--text); display: flex; flex-direction: column; gap: 10px; margin: 0; }
.pcard:hover { border-color: var(--accent); text-decoration: none; }
.phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pname { font-weight: 650; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kl { font-size: 11px; color: var(--muted); } .kv { font-weight: 600; font-variant-numeric: tabular-nums; }
.pfoot { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.pfoot b { color: var(--text); }
canvas.spark { width: 100% !important; height: 36px !important; }
canvas.spark.inv { width: 110px !important; height: 24px !important; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; white-space: nowrap; }

.ptitle { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; } .ptitle h1 { margin-bottom: 8px; }
nav.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
nav.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs a:hover { text-decoration: none; color: var(--text); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; white-space: nowrap; }
td.url { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.card { overflow-x: auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; color: var(--muted); padding: 4px; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
select { width: auto; }
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; } label.check input { width: auto; }
.qr { display: block; margin: 12px auto; border-radius: 8px; background: #fff; padding: 6px; }
.pre { white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 8px; }
details summary { cursor: pointer; color: var(--muted); margin-top: 8px; }

.sugg .shead { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.chip { font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.sugg-act { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.md p { margin: 6px 0; } .md ul, .md ol { margin: 6px 0; padding-left: 20px; } .md pre { white-space: pre-wrap; background: var(--bg); padding: 8px; border-radius: 6px; }
.md table { font-size: 13px; } .md h1, .md h2, .md h3 { font-size: 15px; margin: 12px 0 4px; }

.chatwrap { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
@media (max-width: 800px) { .chatwrap { grid-template-columns: 1fr; } }
.threads { display: flex; flex-direction: column; gap: 4px; }
.threads a { padding: 6px 10px; border-radius: 6px; color: var(--text); }
.threads a.on { background: var(--accent-soft); font-weight: 600; }
.threads form { margin-top: 12px; }
.chat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 210px); min-height: 480px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; background: var(--bg); }
.msg.user { align-self: flex-end; background: var(--accent-soft); }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.progress { padding: 0 16px 6px; min-height: 20px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
.chatform { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
