:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #18202b; --muted: #5d6878; --line: #e3e7ed;
  --brand: #1f5eff; --brand-ink: #ffffff; --brand-soft: #e8efff;
  --ok: #127a43; --ok-soft: #e3f5ea; --warn: #9a5b00; --warn-soft: #fff3db;
  --bad: #b42318; --bad-soft: #fde8e6; --neutral-soft: #eef1f5;
  --side: #121926; --side-ink: #c9d2e0; --side-active: #ffffff;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b; --panel: #161d28; --ink: #e6ebf2; --muted: #93a0b3; --line: #263142;
    --brand: #5b8cff; --brand-soft: #1b2a4a; --ok: #4cc38a; --ok-soft: #12301f;
    --warn: #f0b252; --warn-soft: #3a2a0e; --bad: #ff8a80; --bad-soft: #3d1714; --neutral-soft: #212b3a;
    --side: #0a0f16; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { font-size: 12px; background: var(--neutral-soft); padding: 1px 5px; border-radius: 4px; }

/* layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 16px; line-height: 1.25; }
.side .brand span { display: block; font-weight: 400; font-size: 11px; color: var(--side-ink); opacity: .7; }
.side nav a { display: flex; align-items: center; gap: 8px; color: var(--side-ink); padding: 7px 10px; border-radius: 7px; font-size: 13.5px; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.on { background: rgba(255,255,255,.12); color: var(--side-active); font-weight: 600; }
.side nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 10px; }
.side .who { margin-top: 18px; padding: 10px; font-size: 12px; opacity: .8; border-top: 1px solid rgba(255,255,255,.08); }
.side .who button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; text-decoration: underline; font-size: 12px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.btn.menu-btn { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .main { padding: 14px 16px 60px; }
  .btn.menu-btn { display: inline-flex; margin-bottom: 10px; }
}

/* components */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: block; color: inherit; }
.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.hl { border-left: 3px solid var(--brand); }
@media (max-width: 1000px) { .g2, .g3 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 7px 12px; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 9px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
select[multiple] { min-height: 110px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 600; font-size: 13px; padding: 0 6px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--neutral-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--neutral-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--brand-soft); color: var(--brand); }
.score { display: inline-block; min-width: 34px; text-align: center; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 14px; font-size: 13px; }
.notice.info { background: var(--brand-soft); color: var(--brand); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

dl.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 12.5px; }
dl.kv dd { margin: 0; }
@media (max-width: 600px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { margin-top: 6px; } }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline .meta { font-size: 11.5px; color: var(--muted); }
.timeline .diff { font-size: 12px; margin-top: 2px; }
.timeline .diff del { color: var(--bad); }
.timeline .diff ins { color: var(--ok); text-decoration: none; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
details.filterbox { margin-bottom: 14px; }
details.filterbox summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--ink); background: var(--panel); }
.chips a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chips a:hover { text-decoration: none; border-color: var(--brand); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.chart-box { position: relative; height: 240px; }
#map { height: 600px; border-radius: var(--radius); border: 1px solid var(--line); }
.bar { height: 6px; background: var(--neutral-soft); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.login-wrap { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
