/* ---------- fonts (self-hosted so they work offline) ---------- */

@font-face { font-family: "Franklin"; font-weight: 400; font-display: swap; src: url(/fonts/lf-latin-400.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Franklin"; font-weight: 400; font-display: swap; src: url(/fonts/lf-latin-ext-400.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Franklin"; font-weight: 400; font-display: swap; src: url(/fonts/lf-cyrillic-400.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Franklin"; font-weight: 500; font-display: swap; src: url(/fonts/lf-latin-500.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Franklin"; font-weight: 500; font-display: swap; src: url(/fonts/lf-latin-ext-500.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Franklin"; font-weight: 500; font-display: swap; src: url(/fonts/lf-cyrillic-500.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Franklin"; font-weight: 600; font-display: swap; src: url(/fonts/lf-latin-600.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Franklin"; font-weight: 600; font-display: swap; src: url(/fonts/lf-latin-ext-600.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Franklin"; font-weight: 600; font-display: swap; src: url(/fonts/lf-cyrillic-600.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Franklin"; font-weight: 700; font-display: swap; src: url(/fonts/lf-latin-700.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Franklin"; font-weight: 700; font-display: swap; src: url(/fonts/lf-latin-ext-700.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Franklin"; font-weight: 700; font-display: swap; src: url(/fonts/lf-cyrillic-700.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

/* ---------- tokens ---------- */

:root {
  --paper: #f3f4f6;
  --card: #ffffff;
  --ink: #141a21;
  --ink-2: #3f4852;
  --muted: #6b7480;
  --line: #e4e6ea;
  --line-strong: #cdd1d7;
  --accent: #1b50d8;        /* ballot-pen blue, used sparingly */
  --accent-ink: #ffffff;
  --accent-wash: #eef2fe;
  --ok: #1f7a5c;
  --ok-wash: #e6f3ee;
  --no: #c23b32;
  --no-wash: #fbebe9;
  --amber: #c98a1a;
  --amber-wash: #fcf3e3;
  --r: 10px;
  --r-lg: 16px;
  --font: "Franklin", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-underline-offset: 2px; }
p { margin: 0 0 12px; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.15; letter-spacing: -.011em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; margin: 32px 0 12px; }
h3 { font-size: 17px; margin: 22px 0 8px; }

.wrap { max-width: 620px; margin: 0 auto; padding: 24px 18px 72px; }
.wrap.wide { max-width: 1180px; }

.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- top bar ---------- */

.top { background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in {
  max-width: 1180px; margin: 0 auto; padding: 12px 18px; min-height: 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { color: inherit; text-decoration: none; font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand .tag {
  display: inline-block; margin-left: 2px; padding: 1px 8px; border-radius: 999px;
  background: var(--accent-wash); color: var(--accent); font-size: 14px; font-weight: 600;
}
.who { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.netbar { background: var(--amber-wash); color: #7a540a; border-bottom: 1px solid #f0dcb0; padding: 8px 16px; font-size: 13.5px; text-align: center; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--card); color: var(--ink); font: 500 15.5px/1.2 var(--font);
  text-decoration: none; cursor: pointer; transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #1743bd; border-color: #1743bd; }
.btn.danger { color: var(--no); }
.btn.danger:hover { border-color: var(--no); }
.btn.sm { min-height: 34px; padding: 5px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.block { display: flex; width: 100%; min-height: 52px; font-size: 16px; }
.btn[disabled], .btn.off { opacity: .4; cursor: default; }
.btn[disabled]:hover, .btn.off:hover { border-color: var(--accent); background: var(--accent); }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }

/* ---------- messages and fields ---------- */

.msg { padding: 12px 14px; margin: 0 0 16px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); }
.msg.err { background: var(--no-wash); border-color: #f1cfcb; color: #9a2f27; }
.msg.ok { background: var(--ok-wash); border-color: #c3e2d5; color: #166049; }
.msg.warn { background: var(--amber-wash); border-color: #f0dcb0; color: #7a540a; }
.msg ul { margin: 6px 0 0; padding-left: 20px; }

label.f { display: block; margin: 0 0 16px; }
label.f > span:first-child { display: block; font-size: 13.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=time], input[type=search], input[type=tel], textarea, select {
  width: 100%; padding: 11px 12px; font: 16px var(--font); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--card);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
textarea { min-height: 170px; font-size: 14px; line-height: 1.55; }
.check { display: flex; gap: 10px; align-items: center; margin: 12px 0 4px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- login ---------- */

.login-hero { margin: 8px 0 28px; }
.login-hero h1 { font-size: 34px; }
.login-hero p { margin: 10px 0 0; color: var(--muted); max-width: 36ch; }
.login { max-width: 400px; margin: 0 auto; }
.login .btn.block { margin-top: 8px; }

/* ---------- operator home ---------- */

.station { display: flex; align-items: baseline; gap: 14px; padding: 8px 0 22px; border-bottom: 1px solid var(--line); }
.station .no { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: -.02em; color: var(--accent); }
.station .meta { align-self: center; }
.station .meta .lbl { font-size: 12.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.station .meta b { display: block; font-size: 17px; font-weight: 600; line-height: 1.3; }
.station .meta span.nm { font-size: 14px; color: var(--muted); }

.slots { margin: 4px 0 28px; }
.slot {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  padding: 18px 2px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.slot .t { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.slot .s { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.slot .v { text-align: right; font-size: 20px; font-weight: 600; }
.slot .v small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); margin-top: 3px; }
.slot .v.none { font-size: 14px; font-weight: 400; color: var(--muted); }
.slot.na { color: var(--muted); }
a.slot { grid-template-columns: 1fr auto 12px; }
a.slot::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--line-strong); border-top: 2px solid var(--line-strong); transform: rotate(45deg); justify-self: end; transition: border-color .12s; }
a.slot:hover::after { border-color: var(--accent); }
a.slot:hover .t { color: var(--accent); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 16px; font-size: 13.5px; margin: 0 0 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- number entry ---------- */

.back { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back::before { content: ""; width: 7px; height: 7px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.back:hover { color: var(--accent); }
.page-sub { color: var(--muted); margin: 6px 0 0; }
.sec-t { font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 28px 0 10px; }

.timebox {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 16px; margin-top: 20px;
}
.timebox span { font-weight: 500; color: var(--ink-2); }
.timebox input { width: 130px; font-size: 24px; font-weight: 600; text-align: right; border: 0; padding: 0; background: transparent; }
.timebox input:focus { box-shadow: none; }

/* control numbers: airy grid, hairlines only */
.tot {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.tot.one { grid-template-columns: 1fr; }
.cell { background: var(--card); padding: 12px 16px 14px; display: block; cursor: text; transition: background .12s; }
.cell .l { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; line-height: 1.35; color: var(--muted); min-height: 2.7em; }
.cell .l b { font-weight: 600; color: var(--muted); font-variant-numeric: normal; }
.cell input {
  width: 100%; border: 0; padding: 0; margin: 4px 0 0; background: transparent; border-radius: 0;
  font-size: 34px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); font-variant-numeric: tabular-nums;
}
.cell input::placeholder { color: #aeb4bc; font-size: 15px; font-weight: 400; letter-spacing: 0; }
.cell:focus-within { background: var(--accent-wash); }
.cell input:focus { outline: none; box-shadow: none; }
.cell.bad { background: var(--no-wash); }

/* options: one airy row per list */
.opts { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 2px 16px; }
.opt { display: grid; grid-template-columns: 26px 1fr 104px; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.opt:last-child { border-bottom: 0; }
.opt .k { font-size: 15px; font-weight: 600; color: var(--muted); font-variant-numeric: normal; }
.opt .n { font-size: 15.5px; line-height: 1.3; }
.opt input {
  width: 100%; text-align: right; padding: 6px 10px; height: 44px;
  font-size: 22px; font-weight: 600; background: var(--paper); border-color: var(--line); border-radius: 8px;
}
.opt input:focus { background: var(--accent-wash); }
.opt input.bad { border-color: var(--no); background: var(--no-wash); }
.sum { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 4px 0; color: var(--muted); font-size: 14px; }
.sum .num { font-size: 22px; font-weight: 600; color: var(--ink); }
.sum.no, .sum.no .num { color: var(--no); }

/* bottom dock */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px);
  border-top: 1px solid var(--line);
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
}
.dock-in { max-width: 620px; margin: 0 auto; }
.chips { display: flex; gap: 8px; margin-bottom: 12px; }
.chip {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 4px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: var(--paper); color: var(--muted);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; }
.chip.ok { background: var(--ok-wash); color: var(--ok); }
.chip.ok::before { opacity: 1; }
.chip.no { background: var(--no-wash); color: var(--no); }
.chip.no::before { opacity: 1; }
.dock .btn { width: 100%; min-height: 52px; font-size: 16px; }
.dock .note { font-size: 12.5px; color: var(--muted); margin: 9px 0 0; text-align: center; }
.dock-space { height: 156px; }

/* a sent message */
.board { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 16px 0 12px; }
.board pre { margin: 0; font: 500 16px/1.55 var(--font); white-space: pre-wrap; word-break: break-word; font-variant-numeric: tabular-nums; }
.board pre.sm { font-size: 15px; }
.sent-item { margin: 0 0 22px; }
.sent-item .h { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); }
.sent-item .board { margin: 6px 0 8px; }

/* ---------- admin ---------- */

nav.tabs { display: flex; gap: 24px; align-items: flex-end; border-bottom: 1px solid var(--line); margin: 0 0 26px; overflow-x: auto; }
nav.tabs a { padding: 8px 0 12px; text-decoration: none; color: var(--muted); white-space: nowrap; font-size: 15px; font-weight: 500; }
nav.tabs a.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
nav.tabs a:hover { color: var(--ink); }
nav.tabs .sp { flex: 1; }

.lead { max-width: 72ch; color: var(--muted); margin-top: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar .sp { flex: 1; }

.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 24px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: 12.5px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td .btns { display: flex; flex-wrap: wrap; gap: 6px; }
td.bm { font-size: 21px; font-weight: 700; white-space: nowrap; color: var(--accent); }
td.bm small { display: block; font-size: 13px; font-weight: 400; line-height: 1.35; color: var(--muted); margin-top: 3px; white-space: normal; max-width: 22ch; }
.flag { color: var(--no); font-size: 18px; font-weight: 700; }
.zero { color: var(--line-strong); font-size: 18px; font-weight: 600; }
.live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }

.ed { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 22px 24px; margin-bottom: 28px; max-width: 760px; }
.ed h2 { font-size: 24px; margin-top: 20px; }
.ed-row { display: grid; grid-template-columns: 76px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.ed-row input.code { font-size: 16px; font-weight: 600; text-transform: uppercase; text-align: center; padding: 8px 6px; }
.ed-row .fixed { font-size: 16px; font-weight: 600; text-align: center; color: var(--muted); }
.ed-row .ctl { display: flex; gap: 4px; }
.ed .board pre { font-size: 15px; }

/* dialog */
dialog {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0;
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--ink); background: var(--card);
  box-shadow: 0 24px 60px -16px rgba(20, 26, 33, .32);
}
dialog::backdrop { background: rgba(20, 26, 33, .42); }
#dlg-body { padding: 24px 22px; }
#dlg-body h2 { margin: 0 0 14px; font-size: 24px; }
.code-show {
  font-size: 34px; font-weight: 700; letter-spacing: .08em; padding: 20px 12px; text-align: center;
  color: var(--accent); background: var(--accent-wash); border-radius: var(--r); margin: 10px 0 16px;
}

@media (max-width: 560px) {
  .wrap { padding: 20px 16px 72px; }
  .who { max-width: 52vw; }
  .ed { padding: 6px 16px 20px; }
  .ed-row { grid-template-columns: 64px 1fr; }
  .ed-row .ctl { grid-column: 1 / -1; justify-content: flex-end; }
  nav.tabs { gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

.timebox select {
  width: auto; border: 0; padding: 4px 6px; background: var(--paper); border-radius: 8px;
  font-size: 22px; font-weight: 600; color: var(--ink); -webkit-appearance: menulist; appearance: auto;
}
.timebox select:focus { box-shadow: 0 0 0 3px var(--accent-wash); }

/* ---------- warning dialog (numbers don't reconcile) ---------- */
dialog.modal {
  border: 0; border-radius: 16px; padding: 0; color: var(--ink); background: var(--card);
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 24px 60px -16px rgba(20, 26, 33, .35);
}
dialog.modal::backdrop { background: rgba(20, 26, 33, .45); }
.modal-in { padding: 22px 20px 18px; }
.modal-in h2 { font-size: 21px; margin: 0 0 6px; }
.modal-in > p { margin: 0 0 14px; }
.warnlist { list-style: none; margin: 0 0 18px; padding: 0; }
.warnlist li {
  font-size: 13.5px; line-height: 1.35; padding: 10px 12px; margin-bottom: 8px; border-radius: 10px;
  background: var(--no-wash); color: #9a2f27; font-variant-numeric: tabular-nums;
}
.warnlist li:last-child { margin-bottom: 0; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns .btn { flex: 1; min-height: 48px; }
@media (prefers-reduced-motion: no-preference) {
  dialog.modal[open] { animation: modal-in .14s ease-out; }
  @keyframes modal-in { from { opacity: 0; transform: translateY(8px); } }
}
