:root {
  --bg: #f6f7f9; --panel: #fff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-soft: #e8efff; --ok: #15803d; --ok-soft: #e7f6ec;
  --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --bad-soft: #fdecec;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --text: #e6e8ec; --muted: #9aa1ad; --line: #272b34;
    --accent: #6d9bff; --accent-soft: #1c2740; --ok: #4ade80; --ok-soft: #14291c;
    --warn: #fbbf24; --warn-soft: #2d2412; --bad: #f87171; --bad-soft: #2f1717;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 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; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 14px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .sep { margin: 12px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.side .me { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px 10px; word-break: break-all; }

main { padding: 20px 24px 40px; min-width: 0; }
.top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.top h1 { font-size: 20px; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select, input, button, textarea { font: inherit; color: var(--text); }
select, input[type=text], input[type=email], input[type=search], input[type=number], textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 34px;
}
textarea { width: 100%; min-height: 60px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; min-height: 34px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 2px 8px; min-height: 26px; font-size: 12px; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 14px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h2 small { font-weight: 400; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.two { grid-template-columns: 1fr 1fr; }
.chart { position: relative; height: 280px; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; }
tr:hover td { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.trunc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.err { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.note { background: var(--accent-soft); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }

.heat { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; font-size: 10.5px; }
.heat div { aspect-ratio: 1; border-radius: 3px; }
.heat .lb { aspect-ratio: auto; color: var(--muted); display: flex; align-items: center; justify-content: center; }

.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.form label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.app-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: var(--panel); }
.app-card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--accent); margin-top: 8px; }

.menu-btn { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 10; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: inline-block; }
  main { padding: 14px 16px 40px; }
  .two { grid-template-columns: 1fr; }
}
