:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #1b2430;
  --muted: #5d6b7a;
  --line: #dbe2ea;
  --primary: #1f4e79;
  --primary-ink: #ffffff;
  --primary-soft: #d3e4f7;
  --ok: #2e7d4f;
  --warn: #b26a00;
  --err: #b3261e;
  --private: #7b4fa3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --surface: #171d24; --surface-2: #1f2730; --text: #e6ebf0; --muted: #9aa7b4; --line: #2b3540;
    --primary: #9cc4ec; --primary-ink: #0b2741; --primary-soft: #173a5b; --ok: #6fcf97; --warn: #f2b45b; --err: #f2b8b5; --private: #c7a6ec;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
.loading { padding: 2rem; color: var(--muted); }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; margin: 0 .5rem 1rem; }
.brand img { width: 30px; height: 30px; }
.nav a { display: block; padding: .55rem .75rem; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary-soft); color: var(--text); font-weight: 600; }
.nav .group { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem .75rem .35rem; }
.main { padding: 1.25rem 1.75rem 3rem; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.topbar h1 { font-size: 1.45rem; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.filters label { display: flex; flex-direction: column; font-size: .75rem; color: var(--muted); gap: 2px; }
.menu-toggle { display: none; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; min-width: 0; }
textarea { min-height: 4.5rem; width: 100%; }
button, .btn { background: var(--primary); color: var(--primary-ink); border: 0; border-radius: 8px; padding: .5rem .9rem; cursor: pointer; text-decoration: none; display: inline-block; font-weight: 600; }
button.secondary, .btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--err); color: #fff; }
button:disabled { opacity: .55; cursor: default; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; }
.card .label { color: var(--muted); font-size: .8rem; }
.card .value { font-size: 1.4rem; font-weight: 700; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.card.attention { border-left: 4px solid var(--warn); }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.panel h2 { font-size: 1.05rem; margin: 0 0 .75rem; color: var(--primary); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .5rem .65rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); margin-right: .25rem; white-space: nowrap; }
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.err { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.chip.private { background: color-mix(in srgb, var(--private) 18%, transparent); color: var(--private); }

.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem 1rem; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: .8rem; color: var(--muted); }
.form label.wide { grid-column: 1 / -1; }
.form label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.kv { display: grid; grid-template-columns: minmax(150px, 35%) 1fr; gap: .3rem .9rem; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.issues { list-style: none; margin: 0; padding: 0; }
.issues li { padding: .45rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; }
.issues li:last-child { border-bottom: 0; }
.sev-ERROR { color: var(--err); font-weight: 700; }
.sev-WARNING { color: var(--warn); font-weight: 700; }
.sev-INFO { color: var(--muted); }

.docs { display: flex; flex-wrap: wrap; gap: .75rem; }
.docs figure { margin: 0; background: var(--surface-2); border-radius: 10px; padding: .5rem; width: 220px; }
.docs img { width: 100%; height: 280px; object-fit: contain; background: #fff; border-radius: 6px; }
.docs figcaption { font-size: .78rem; color: var(--muted); margin-top: .35rem; overflow-wrap: anywhere; }
.route { width: 100%; height: 280px; background: var(--surface-2); border-radius: 10px; }
.route path { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
pre.ocr { white-space: pre-wrap; background: var(--surface-2); padding: .75rem; border-radius: 8px; font-size: .8rem; max-height: 320px; overflow: auto; }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 10; max-width: 90vw; }
.toast.err { background: var(--err); color: #fff; }

.login { max-width: 420px; margin: 8vh auto; }
.login .panel { padding: 1.5rem; }
.login h1 { font-size: 1.4rem; display: flex; align-items: center; gap: .6rem; }
.login img { width: 36px; }
.login .form { grid-template-columns: 1fr; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.9rem; letter-spacing: .25em; font-weight: 700; padding: .5rem 0; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 5; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-block; }
  .main { padding: 1rem; }
  .kv { grid-template-columns: 1fr; }
}
a.plain { text-decoration: none; color: inherit; }
