:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-soft: #e8efff; --ok: #15803d; --ok-soft: #e7f6ec;
  --warn: #b45309; --warn-soft: #fdf3e3; --bad: #b91c1c; --bad-soft: #fdecec;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 8px rgba(0,0,0,.04);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --text: #e6e8ec; --muted: #9aa3b2; --line: #272b35;
    --accent: #6b9bff; --accent-soft: #1c2742; --ok: #4ade80; --ok-soft: #13291c;
    --warn: #fbbf24; --warn-soft: #2d2412; --bad: #f87171; --bad-soft: #301617;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
header.top { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; height: 52px; overflow-x: auto; }
header.top .brand { font-weight: 700; white-space: nowrap; color: var(--text); }
header.top nav { display: flex; gap: 4px; }
header.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
header.top nav a.on, header.top nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
header.top .right { margin-left: auto; display: flex; gap: 10px; align-items: center; white-space: nowrap; color: var(--muted); font-size: 12px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 14px; }
.cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.muted { background: var(--line); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.flash { background: var(--accent-soft); color: var(--accent); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button, .btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; display: inline-block; }
button.secondary, .btn.secondary { background: var(--line); color: var(--text); }
button.danger { background: var(--bad-soft); color: var(--bad); }
button:hover, .btn:hover { filter: brightness(1.05); text-decoration: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
.chat .log { flex: 1; overflow-y: auto; padding: 8px 4px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: min(760px, 92%); padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat form { display: flex; gap: 8px; margin-top: 10px; }
.chat textarea { flex: 1; resize: none; height: 46px; }
.hints { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.hints button { background: var(--accent-soft); color: var(--accent); font-size: 12px; padding: 4px 10px; }
.login { max-width: 360px; margin: 12vh auto; }
.chart-box { position: relative; height: 260px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
