:root {
  --bg: #0b0d12;
  --surface: #151821;
  --surface-2: #1d2130;
  --border: #272c3c;
  --text: #f2f3f7;
  --muted: #a3a9bb;
  --faint: #6c7286;
  --accent: #ffd43b;
  --accent-ink: #111;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ── Top bar ─────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 13, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.status { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; text-align: right; }
.status .led { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status .led.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15); }
.status .led.busy { background: var(--accent); }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(21, 24, 33, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; padding: 12px 0 10px; font-size: 12px; font-weight: 600; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabs button .ico { font-size: 18px; line-height: 1; }
.tabs button.on { color: var(--accent); }
.tabs .badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 10px; padding: 0 6px; margin-left: 4px; }

main { padding: 16px; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 10px 0 0; }

/* ── Cards ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card.new { border-color: rgba(255, 212, 59, 0.45); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.sub { font-size: 12px; color: var(--muted); }
.faint { color: var(--faint); }
.chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: rgba(74, 222, 128, 0.14); color: var(--ok); }
.chip.warn { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.chip.bad { background: rgba(248, 113, 113, 0.14); color: var(--bad); }
.chip.accent { background: rgba(255, 212, 59, 0.16); color: var(--accent); }

.media { display: flex; gap: 10px; }
.media > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.media .portrait { flex: 0 0 38%; }
.frame { width: 100%; border-radius: 10px; background: #000; display: block; object-fit: cover; }
.frame.p { aspect-ratio: 9 / 16; }
.frame.l { aspect-ratio: 16 / 9; }
.placeholder { width: 100%; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; text-align: center; color: var(--faint); font-size: 12px; padding: 10px; }
.placeholder.p { aspect-ratio: 9 / 16; }
.placeholder.l { aspect-ratio: 16 / 9; }

.issues { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.issues li { display: flex; gap: 8px; font-size: 13px; color: var(--muted); }
.issues .at { flex: none; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--text); font: 600 11px/1 ui-monospace, monospace; padding: 5px 6px; height: 22px; }
.issues .warn b { color: var(--warn); }
.issues .error b { color: var(--bad); }
.quote { font-style: italic; color: var(--faint); margin-top: 2px; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.sources { margin: 6px 0 0; padding-left: 16px; font-size: 12px; color: var(--faint); }
.sources a { color: var(--text); text-decoration: none; }

/* ── Controls ────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 9px 14px;
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: none; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.45; }
.btn.block { width: 100%; }
input[type="text"], input[type="url"], input[type="password"], textarea, select {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select.inline { width: auto; padding: 4px 8px; font-size: 12px; border-radius: 8px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button { border: 0; background: none; border-radius: 7px; padding: 7px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.segmented button.on { background: var(--surface-2); color: var(--text); }

.msg { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.msg.bad { color: var(--bad); }
.empty { text-align: center; color: var(--faint); padding: 30px 10px; font-size: 14px; }

/* ── Stats ───────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.kpi .v { font-size: 20px; font-weight: 800; }
.kpi .l { font-size: 11px; color: var(--faint); }
.list { display: flex; flex-direction: column; }
.list .item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.list .item:last-child { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; min-width: 52px; }

/* ── Login ───────────────────────────────────────────────── */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 360px; margin: 0 auto; padding: 24px; }
.login h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 10; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.toast.bad { color: var(--bad); }
.hidden { display: none !important; }
