:root {
  --bg: #f4f6fa; --panel: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-ink: #fff; --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --warn: #a16207; --warn-bg: #fef9c3; --nav: #0f172a; --nav-ink: #cbd5e1; --nav-active: #ffffff;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --panel: #111a2e; --text: #e2e8f0; --muted: #94a3b8; --line: #1e293b;
    --accent: #3b82f6; --ok: #4ade80; --ok-bg: #14301f; --bad: #f87171; --bad-bg: #3a1414;
    --warn: #facc15; --warn-bg: #332a0a; --nav: #070c18; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 16px; } h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .err { color: var(--bad); min-height: 1em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; }
.side a { color: var(--nav-ink); padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.side a i { font-style: normal; width: 20px; text-align: center; }
.side a.active { background: rgba(255,255,255,.08); color: var(--nav-active); }
.side-foot { margin-top: auto; padding: 12px; font-size: 13px; }
.brand { font-weight: 700; font-size: 17px; padding: 6px 12px 18px; color: var(--nav-active); }
.login .brand { color: var(--text); padding: 0 0 8px; }
.logo { color: var(--accent); } .beta { font-size: 11px; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 6px; vertical-align: middle; }
.view { padding: 24px; max-width: 1200px; width: 100%; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; overflow-x: auto; gap: 0; }
  .side .brand, .side-foot { display: none; }
  .side a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; min-width: 56px; }
  .side a i { font-size: 18px; }
  .view { padding: 16px 16px 90px; }
  .hide-sm { display: none; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.kpi .v { font-size: 26px; font-weight: 700; } .kpi .l { color: var(--muted); font-size: 13px; }
.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 9px 14px; border-radius: 9px;
  font: inherit; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.big { padding: 14px 18px; font-size: 16px; font-weight: 600; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; min-height: 40px; width: 100%; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.ok { background: var(--ok-bg); color: var(--ok); } .bad { background: var(--bad-bg); color: var(--bad); }
.warn { background: var(--warn-bg); color: var(--warn); } .neutral { background: var(--line); color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr.click { cursor: pointer; } tr.click:hover td { background: rgba(37,99,235,.05); }
.table-wrap { overflow-x: auto; }
.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.door { display: grid; gap: 8px; }
.checks { display: grid; gap: 8px; } .checks label { flex-direction: row; display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 15px; }
.checks input { width: auto; min-height: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.on { background: var(--ok); } .dot.off { background: var(--bad); }
.notice { padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100% - 32px); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.feed .list-item { animation: fade .4s; } @keyframes fade { from { background: rgba(37,99,235,.15); } to { background: transparent; } }
