/* Dark, big and high-contrast: readable at arm's length and with poor eyesight. */
:root {
  --bg: #0b0f17;
  --surface: #151b27;
  --surface-2: #1d2535;
  --line: #34405a;
  --text: #f4f7fc;
  --muted: #c3cbdb;
  --blue: #4c9bff;
  --blue-ink: #04101f;
  --green: #3ddc84;
  --green-ink: #03200f;
  --amber: #ffc53d;
  --amber-ink: #241800;
  --red: #ff6b6b;
  --red-ink: #2a0606;
  --focus: #ffe066;
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- header / nav ---- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; }
.top-clock { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .5px; }

.netbar {
  padding: 10px 16px; font-size: 15px; font-weight: 700;
  background: var(--amber); color: var(--amber-ink);
}
.netbar.error { background: var(--red); color: var(--red-ink); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr 1fr;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  height: var(--tabs-h); border: 0; background: none;
  font-size: 19px; font-weight: 700; color: var(--muted);
}
.tab[aria-current="page"] { color: var(--text); box-shadow: inset 0 4px 0 var(--blue); background: var(--surface-2); }

.view { padding: 16px 16px calc(var(--tabs-h) + 32px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

/* ---- generic ---- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 51px; padding: 12px 18px;
  border: 2px solid transparent; border-radius: var(--radius);
  font-size: 19px; font-weight: 800; cursor: pointer; text-decoration: none;
  touch-action: manipulation;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; }
.btn-xl { min-height: 78px; font-size: 24px; }
.btn-primary { background: var(--blue); color: var(--blue-ink); }
.btn-go { background: var(--green); color: var(--green-ink); }
.btn-warn { background: var(--amber); color: var(--amber-ink); }
.btn-stop { background: var(--red); color: var(--red-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger-ghost { background: transparent; border-color: var(--red); color: var(--red); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn small { display: block; font-size: 14px; font-weight: 600; }
.btn .stack { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }

.stack-gap > * + * { margin-top: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.card-accent { border-left: 8px solid var(--blue); }
.card-live { border: 2px solid var(--amber); background: #221d0c; }
.card h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.label { color: var(--muted); font-size: 14px; font-weight: 600; }
.big { font-size: 29px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.muted { color: var(--muted); }
.section-title { margin: 26px 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 10px; }
.facts .fact-wide { grid-column: 1 / -1; }
.fact .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.badge {
  display: inline-block; white-space: nowrap; padding: 3px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 800; vertical-align: middle;
}
.badge-open { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.badge-sent { background: var(--green); color: var(--green-ink); }
.badge-live { background: var(--amber); color: var(--amber-ink); }

.banner {
  display: block; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--radius);
  background: #1b2a48; border: 2px solid var(--blue); color: var(--text);
  font-size: 16px; font-weight: 700;
}

/* stop list */
.stops { list-style: none; margin: 0; padding: 0; }
.stop {
  display: grid; grid-template-columns: 40px 1fr; gap: 4px 12px; align-items: start;
  width: 100%; text-align: left;
  padding: 14px; margin-top: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
button.stop { cursor: pointer; }
.stop-n {
  grid-row: span 3; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); font-weight: 800;
}
.stop-name { font-size: 19px; font-weight: 800; overflow-wrap: anywhere; }
.stop-times { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stop-meta { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.counts { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* ---- forms ---- */
.field { display: block; }
.field + .field { margin-top: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 15px; font-weight: 700; color: var(--muted); }
.input {
  width: 100%; min-height: 51px; padding: 10px 14px;
  background: #0f1420; border: 2px solid var(--line); border-radius: 12px;
  font-size: 22px; font-weight: 700;
}
.input:focus { border-color: var(--blue); outline: none; }
textarea.input { min-height: 85px; font-size: 18px; font-weight: 600; resize: vertical; }
input[type="time"].input, input[type="datetime-local"].input { font-variant-numeric: tabular-nums; }
.hint { margin-top: 6px; font-size: 14px; color: var(--muted); }
.hint.ok { color: var(--green); }

.steppers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stepper { text-align: center; }
.stepper > span { display: block; font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.stepper .input { text-align: center; padding: 6px 4px; min-height: 48px; font-size: 24px; }
.stepper-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.stepper-btns button {
  min-height: 44px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface-2); font-size: 26px; font-weight: 800; line-height: 1;
}

/* ---- sheet (dialog) ---- */
.sheet {
  width: 100%; max-width: 640px; max-height: 100dvh; height: 100dvh;
  margin: 0 auto; padding: 0; border: 0;
  background: var(--bg); color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, .7); }
.sheet-inner { padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 22px; }
.sheet-close {
  min-width: 60px; min-height: 44px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface); font-size: 15px; font-weight: 800;
}
.sheet-actions { margin-top: 22px; display: grid; gap: 12px; }
.sheet-error { padding: 12px 14px; border-radius: 12px; background: var(--red); color: var(--red-ink); font-weight: 800; }

/* ---- week ---- */
.weeknav { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; align-items: center; }
.weeknav button { min-height: 51px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-size: 26px; font-weight: 800; }
.weeknav .wk { text-align: center; }
.weeknav .wk b { display: block; font-size: 22px; }
.day-title { margin: 22px 0 8px; font-size: 19px; font-weight: 800; }
.day-empty { color: var(--muted); font-size: 15px; padding: 4px 0 0; }
.shift-card .shift-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 10px; }
.end-shift { margin-top: 56px; padding-top: 20px; border-top: 1px dashed var(--line); }
.shift-card .stops .stop { background: var(--surface-2); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 600px; margin: 0 auto; padding: 16px 18px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); font-size: 17px; font-weight: 800;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.error { background: var(--red); color: var(--red-ink); }

.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- login ---- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 420px; }
.login-card h1 { margin: 8px 0 0; font-size: 29px; }
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 17px; }
.login-card label { display: block; margin: 16px 0 6px; font-size: 16px; font-weight: 700; color: var(--muted); }
.login-card input {
  width: 100%; min-height: 54px; padding: 10px 14px;
  background: #0f1420; border: 2px solid var(--line); border-radius: 12px; font-size: 22px; font-weight: 700;
}
.login-card input:focus { border-color: var(--blue); outline: none; }
.login-card .btn { margin-top: 26px; }
.login-error { padding: 12px 14px; border-radius: 12px; background: var(--red); color: var(--red-ink); font-weight: 800; }

/* iPhone install instructions */
.ios-steps { margin: 0; padding-left: 1.4em; }
.ios-steps li { margin-bottom: 16px; line-height: 1.5; }
.ios-glyph { width: 1.4em; height: 1.4em; vertical-align: -0.35em; color: var(--blue); }

/* pause + live counters */
.card-break { border: 2px solid var(--blue); background: #0f1d36; }
.counter { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: .5px; }
.btn-break { background: var(--surface-2); border-color: var(--blue); color: var(--text); }
.stop-break .stop-n { background: #1b2a48; color: var(--blue); }
