:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --ink: #16171a;
  --muted: #6b6e76;
  --line: #e3e3df;
  --brand: #ffd400;
  --brand-ink: #16171a;
  --ok: #1f9d55;
  --warn: #c98a00;
  --bad: #d13b33;
  --focus: #2f6fed;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11;
    --surface: #17181b;
    --surface-2: #1d1e22;
    --ink: #ececea;
    --muted: #9a9ca3;
    --line: #2a2b30;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.splash { padding: 80px 16px; text-align: center; color: var(--muted); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; text-decoration: none; }
.logo-mark { width: 28px; height: 28px; border-radius: 7px; background: #0b0b0c; display: grid; place-items: center; }
.logo-mark svg { width: 18px; height: 18px; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a.on { background: var(--surface-2); color: var(--ink); }
.me { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 120px; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 4px 0 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.spacer { flex: 1; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(.96); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Station cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; text-decoration: none; display: block;
}
a.card:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.card-top { display: flex; align-items: flex-start; gap: 12px; }
.card-id { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-name { font-weight: 650; font-size: 16px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 4px; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.fact b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.fact span { font-size: 12px; color: var(--muted); }
.problems { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.problems li { font-size: 13.5px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); }
.problems li.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.allgood { margin-top: 12px; font-size: 13.5px; color: var(--ok); }

.thumb { display: block; width: 100%; aspect-ratio: 2340 / 1080; object-fit: cover; border-radius: 10px; margin-top: 14px; background: #0a0a0a; }
.screen { display: block; width: 100%; border-radius: 12px; background: #0a0a0a; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 7px; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 18%, transparent); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 18%, transparent); }
.dot.off { background: var(--muted); box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 18%, transparent); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 24px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--brand); }

/* Settings form */
.layout { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: start; }
.toc { position: sticky; top: 84px; display: grid; gap: 2px; }
.toc a { padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 14px; }
.toc a:hover { background: var(--surface); color: var(--ink); }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 16px; scroll-margin-top: 84px; }
.section > p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.lock { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; margin-left: 8px; vertical-align: 2px; }
.field { display: grid; grid-template-columns: 240px 1fr; gap: 6px 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; }
.field label { font-weight: 600; }
.field .help { color: var(--muted); font-size: 13px; margin-top: 2px; font-weight: 400; }
.field .code { font: 12px ui-monospace, Consolas, monospace; color: var(--muted); }
.control { display: grid; gap: 6px; align-content: start; }
input[type=text], input[type=number], input[type=time], input[type=email], textarea, select {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
}
input[type=number] { max-width: 140px; }
input[type=time] { max-width: 160px; }
textarea { min-height: 96px; resize: vertical; }
input:disabled, textarea:disabled { opacity: .65; }
.error { color: var(--bad); font-size: 13px; font-weight: 600; }
.field.has-error input, .field.has-error textarea { border-color: var(--bad); }
.unit { color: var(--muted); font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 21px; }
.list-editor { display: grid; gap: 8px; }
.list-items { display: grid; gap: 8px; }
.list-row { display: flex; gap: 8px; align-items: center; }
.list-row input[type=time] { max-width: 160px; }
.list-editor .add { justify-self: start; }
.list-empty { color: var(--muted); font-size: 13px; }
.icon { width: 34px; height: 34px; flex: none; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 14px; }
.icon:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.reminder .list-row input[type=time] { background: var(--surface); }
.reminder { background: var(--surface-2); border-radius: 12px; padding: 4px 16px; margin: 10px 0; }
.reminder h3 { margin: 12px 0 0; font-size: 15px; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px 24px; display: flex; justify-content: center;
  transform: translateY(100%); transition: transform .2s;
}
.savebar.on { transform: none; }
.savebar-inner { max-width: 1120px; width: 100%; display: flex; align-items: center; gap: 12px; }

/* Tables and lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 16px; align-items: flex-start; }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.changes { margin: 6px 0 0; padding-left: 18px; font: 13px ui-monospace, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 600; font-size: 13px; border-top: 0; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.admin { background: var(--brand); color: var(--brand-ink); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow); text-align: center; }
.login-card .logo { justify-content: center; font-size: 22px; margin-bottom: 8px; }
.login-card p { color: var(--muted); margin: 0 0 24px; }
#google-button { display: flex; justify-content: center; min-height: 44px; }
.dev { margin-top: 20px; padding-top: 20px; border-top: 1px dashed var(--line); text-align: left; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--surface); border-radius: 18px; padding: 26px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 16px; }
.modal .field { grid-template-columns: 1fr; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.secret { font: 13px ui-monospace, Consolas, monospace; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.note { background: color-mix(in srgb, var(--brand) 22%, transparent); border-radius: 10px; padding: 10px 14px; font-size: 14px; }

#toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; transition: all .2s; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 30; }
#toast.on { opacity: 1; transform: translateX(-50%); }

@media (max-width: 820px) {
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .nav { margin-left: 0; order: 3; width: 100%; }
  .me span { display: none; }
  main { padding: 20px 16px 120px; }
  .layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .field { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(3, 1fr); }
}
