:root {
  --bg: #f4f5f1; --panel: #ffffff; --ink: #1c2420; --muted: #67716b; --line: #e3e6df;
  --soft: #eef2ee; --accent: #1f6f4a; --accent-ink: #ffffff; --accent-soft: #e3f0e8;
  --warn: #a4421d; --warn-soft: #fbece5; --gold: #9a6b00; --gold-soft: #fbf1d9;
  --side: #17211c; --side-ink: #c9d4cd; --side-active: #25352d;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 25, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101412; --panel: #181e1b; --ink: #e6ebe8; --muted: #95a19a; --line: #29312d;
    --soft: #1f2723; --accent: #52c08c; --accent-ink: #0b1811; --accent-soft: #1d3428;
    --warn: #f0906a; --warn-soft: #3a221a; --gold: #e2b54d; --gold-soft: #332a14;
    --side: #0b0f0d; --side-ink: #b7c3bc; --side-active: #1b2520;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh;
        display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 650; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: #1f6f4a; display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; color: var(--side-ink); font-size: 12px; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); }
.side a.nav:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.side a.nav.on { background: var(--side-active); color: #fff; }
.side a.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side .badge { margin-left: auto; background: #c98a00; color: #111; font-size: 11px; padding: 0 7px; border-radius: 99px; font-weight: 600; }
.side .grow { flex: 1; }
.side .me { font-size: 12.5px; padding: 10px; border-top: 1px solid #26322b; margin-top: 8px; }
.side .me button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
main { padding: 24px 28px 60px; min-width: 0; max-width: 1280px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-bar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; }
  .mobile-bar button { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 6px; cursor: pointer; }
  main { padding: 18px 16px 50px; }
}

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.grid > .panel + .panel { margin-top: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid.two { grid-template-columns: 2fr 1fr; }
.grid.half { grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .grid.two, .grid.half { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { color: var(--muted); font-size: 12.5px; }
.stat.attn { border-color: var(--gold); background: var(--gold-soft); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--soft); }
td.nowrap { white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Bits */
.pill { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.bad { background: var(--warn-soft); color: var(--warn); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--soft); border: 1px solid var(--line); margin: 0 4px 4px 0; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; background: var(--accent-soft); color: var(--ink); border: 1px solid transparent; }
.flash.error { background: var(--warn-soft); }
.banner { padding: 8px 14px; border-radius: 10px; margin-bottom: 14px; background: var(--gold-soft); color: var(--gold); font-size: 13.5px; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 650; flex: none; }
.who { display: flex; gap: 14px; align-items: center; }

/* Forms */
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.fields .wide { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters > div { min-width: 140px; }
.filters .search { flex: 1; min-width: 200px; }
.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
       background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--warn); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
form.inline { display: inline; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Chart */
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 170px; padding-top: 10px; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.chart .col:last-child .bar { opacity: 1; }
.chart .lbl { font-size: 11.5px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .meta { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.timeline p { margin: 4px 0 0; white-space: pre-wrap; }
.keybox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--soft); padding: 2px 8px; border-radius: 6px; user-select: all; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: 100%; max-width: 380px; }
details summary { cursor: pointer; color: var(--accent); }
