:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --ink: #142430;
  --muted: #5a6b76;
  --line: #d9e0e4;
  --brand: #12324a;
  --brand-ink: #ffffff;
  --accent: #0d6e6c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1f0;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --bad: #a3261f;
  --bad-soft: #fbe7e5;
  --good: #1f6b3a;
  --good-soft: #e3f3e8;
  --focus: #2b7fd1;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f171d;
    --surface: #17222a;
    --ink: #e6edf1;
    --muted: #9db0bb;
    --line: #2b3a44;
    --brand: #0b1f2e;
    --accent: #3fb3ae;
    --accent-ink: #062322;
    --accent-soft: #143633;
    --warn: #f0c060;
    --warn-soft: #3a2e14;
    --bad: #ff8a80;
    --bad-soft: #3d1c1a;
    --good: #7fd69b;
    --good-soft: #163322;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.topbar {
  background: var(--brand);
  color: var(--brand-ink);
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; }
.topbar .brand small { font-weight: 500; opacity: .75; font-size: 12px; border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 1px 8px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 14px; opacity: .9; }
.topbar button, .topbar select {
  background: transparent; color: var(--brand-ink); border: 1px solid rgba(255,255,255,.45);
  border-radius: 8px; padding: 6px 10px; font-size: 14px; cursor: pointer;
}
.topbar select option { color: #142430; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.narrow { max-width: 460px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: var(--mono); font-size: 13px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input, select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px 12px; font-weight: 400; min-width: 0;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; padding: 16px; font-size: 18px; border-radius: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; }

.msg { border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.msg.good { background: var(--good-soft); color: var(--good); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.row > .btn { flex: 0 0 auto; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.pill.off { background: var(--line); color: var(--muted); }
