:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6eb;
  --text: #17202b;
  --muted: #667085;
  --accent: #0f6fde;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0fd;
  --ok: #12805c;
  --ok-soft: #e3f5ee;
  --warn: #a45f00;
  --warn-soft: #fff3df;
  --danger: #c4312b;
  --danger-soft: #fdeceb;
  --side: #121a24;
  --side-ink: #c8d0db;
  --side-on: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #161b22; --surface-2: #1c222b; --border: #2a313c;
    --text: #e6eaf0; --muted: #8b95a3; --accent: #4c9bff; --accent-soft: #15253d;
    --ok: #3fbf8a; --ok-soft: #10291f; --warn: #e5a23a; --warn-soft: #2d2210;
    --danger: #f06a63; --danger-soft: #331716; --side: #0a0e13; color-scheme: dark;
  }
}
* { 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(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.ic { width: 18px; height: 18px; flex: none; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; }
.brand b { color: #fff; display: block; font-size: 15px; }
.brand small { font-size: 12px; opacity: .7; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.side nav { padding: 4px 8px; flex: 1; }
.side nav a, .side-foot > a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.side nav a:hover, .side-foot > a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side nav a.on { background: rgba(76,155,255,.16); color: var(--side-on); }
.side hr { border: 0; border-top: 1px solid rgba(255,255,255,.08); margin: 8px 6px; }
.count { margin-left: auto; font-style: normal; background: var(--danger); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side-foot { padding: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; }
.me b { color: #fff; display: block; font-size: 13px; }
.me small { font-size: 12px; opacity: .7; }
.me form { margin-left: auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #2b3747; color: #fff; display: grid; place-items: center; font-weight: 700; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; font-size: 18px; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.main { padding: 0 28px 40px; min-width: 0; }
.top { display: flex; align-items: center; gap: 10px; height: 64px; }
.top h1 { font-size: 20px; font-weight: 650; }
.menu-btn { display: none; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat.accent { border-left: 3px solid var(--accent); }

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

.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.plat { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .03em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 7px; white-space: nowrap; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

form.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
label.f { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
label.f small { color: var(--muted); font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.form-foot { display: flex; gap: 8px; margin-top: 16px; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar small { font-size: 10.5px; color: var(--muted); }
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.meter i { display: block; height: 100%; background: var(--accent); }
.split { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }

.thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-pair img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
details summary { cursor: pointer; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
.pager .muted { margin-right: auto; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login .card-b { display: grid; gap: 14px; padding: 26px; }
.login .brand { padding: 0 0 6px; }
.login .brand b { color: var(--text); }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .side { position: fixed; z-index: 20; width: 250px; left: -260px; transition: left .2s; }
  .side.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .menu-btn { display: grid; }
  .main { padding: 0 16px 32px; }
  .g2, .g4 { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; }
}
