/* ACS Safety. Brand: ACS Dark Blue #0A4B81, ACS Light Blue #1996CE, white.
   Red and amber appear only as door-state signals, never as brand color. */
:root {
  color-scheme: light dark;
  --blue: #0A4B81;
  --sky: #1996CE;
  --bg: #EEF2F6;
  --surface: #FFFFFF;
  --surface-2: #F4F7FA;
  --text: #14212E;
  --muted: #586776;
  --line: #DCE3EA;
  --heading: #0A4B81;
  --link: #0A4B81;
  --track: #0A4B81;
  --track-done: #1996CE;
  --bar-bg: rgba(255, 255, 255, .92);
  --shadow: 0 1px 2px rgba(10, 30, 50, .06), 0 6px 18px rgba(10, 30, 50, .05);
  --locked-bg: #E6EEF6;   --locked-fg: #0A4B81;
  --temp-bg: #DDF0FA;     --temp-fg: #0A5E86;
  --open-bg: #FCE8E6;     --open-fg: #A3241A;
  --att-bg: #FFF1DB;      --att-fg: #7A4300;
  /* Doors page: traffic-light colors (red = locked, green = unlocked) */
  --door-locked-bg: #FDECEA; --door-locked-fg: #B42318;
  --door-open-bg: #E3F4E8;   --door-open-fg: #11733A;
  --serif: "Pollen", Georgia, "Libre Baskerville", serif;
  --sans: "Trade Gothic", "Source Sans 3", Arial, Helvetica, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A121B;
    --surface: #121E2B;
    --surface-2: #182738;
    --text: #E7EEF5;
    --muted: #9AACBD;
    --line: #22344A;
    --heading: #A8D8F0;
    --link: #8FCDEB;
    --track: #1C5B91;
    --track-done: #1996CE;
    --bar-bg: rgba(18, 30, 43, .94);
    --shadow: none;
    --locked-bg: #15304A;   --locked-fg: #B5D6F2;
    --temp-bg: #0F3A50;     --temp-fg: #9FDDF6;
    --open-bg: #4A1712;     --open-fg: #FFB8AE;
    --att-bg: #43300F;      --att-fg: #FFD394;
    --door-locked-bg: #4A1712; --door-locked-fg: #FFB4AB;
    --door-open-bg: #123A22;   --door-open-fg: #8EE0A8;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font: 700 1.9rem/1.15 var(--serif); color: var(--heading); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.logo-plate { background: #FFFFFF; border-radius: 10px; padding: 3px 8px; line-height: 0; }
.logo { display: block; width: 128px; height: auto; }
.logo-text { display: block; padding: 7px 0; font: 700 .95rem/1.2 var(--serif); color: #0A4B81; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--blue); color: #FFFFFF; font-weight: 700; font-size: .95rem; letter-spacing: .02em;
}

main { max-width: 640px; margin: 0 auto; padding: 18px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px); }
.message { max-width: 460px; margin: 12vh auto 0; }
.message p { color: var(--muted); margin: 12px 0 24px; }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.summary { margin: 0; color: var(--muted); font-size: .95rem; }
.lede { margin: 6px 0 0; color: var(--muted); }
.section { margin: 22px 0 10px; font: 700 1rem/1.3 var(--sans); color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--link);
  font-weight: 700; text-decoration: none;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #FFFFFF; }
.btn.compact { min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: .95rem; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--open-fg); border-color: var(--open-fg); background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 8px 0; color: var(--link); font-weight: 700; cursor: pointer; }
.link.danger { color: var(--open-fg); }

/* ---------- segmented control + search ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 16px 0 0; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--heading); box-shadow: var(--shadow); }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { background: var(--track); color: #FFFFFF; } }
.count { font-weight: 600; opacity: .7; }
.search {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 0 14px; min-height: 46px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.search svg { width: 19px; height: 19px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 17px; outline: none; }
.search:focus-within { outline: 3px solid var(--sky); outline-offset: 1px; }
.banner { margin: 14px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--att-bg); color: var(--att-fg); font-weight: 600; }
.empty { color: var(--muted); text-align: center; margin: 32px 0; }
.empty-block { margin: 18px 0 0; padding: 18px; border: 1.5px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.empty-block p { margin: 0; }

/* ---------- door cards ---------- */
.cards { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.dcard {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 12px 12px 12px 17px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px;
}
.dcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--door-locked-fg); }
.dcard.k-temporary::before { background: var(--door-open-fg); opacity: 1; }
.dcard.k-unlocked::before { background: var(--door-open-fg); opacity: 1; }
.dcard.k-attention::before { background: var(--att-fg); opacity: 1; }
.dcard-head { display: flex; align-items: center; gap: 8px; }
.dcard-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 2px 0; border: 0; background: none; cursor: pointer;
}
.icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dcard .text { min-width: 0; display: flex; flex-direction: column; }
.dcard .name { font-weight: 700; font-size: 1.06rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard .status { font-size: .9rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard.k-locked .status { color: var(--door-locked-fg); font-weight: 600; }
.dcard.k-temporary .status { color: var(--door-open-fg); font-weight: 600; }
.dcard.k-unlocked .status { color: var(--door-open-fg); font-weight: 600; }
.dcard.k-attention .status { color: var(--att-fg); font-weight: 600; }
.chev { flex: none; width: 18px; height: 18px; margin-left: auto; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.star {
  flex: none; width: 44px; height: 44px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; border-radius: 12px;
}
.star svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linejoin: round; }
.star[aria-pressed="true"] svg { fill: var(--sky); stroke: var(--sky); }
.lock-now { width: 100%; min-height: 52px; border-radius: 26px; color: var(--door-locked-fg); border-color: var(--door-locked-fg); background: var(--door-locked-bg); }

.k-locked .icon, .state-line.k-locked { background: var(--door-locked-bg); color: var(--door-locked-fg); }
.k-temporary .icon, .state-line.k-temporary { background: var(--door-open-bg); color: var(--door-open-fg); }
.k-unlocked .icon, .state-line.k-unlocked { background: var(--door-open-bg); color: var(--door-open-fg); }
.k-attention .icon, .state-line.k-attention { background: var(--att-bg); color: var(--att-fg); }

/* ---------- swipe to unlock briefly ---------- */
.swipe {
  position: relative; height: 56px; border-radius: 28px; overflow: hidden; background: var(--track);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
}
.swipe-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--track-done); transition: width .25s ease; }
.swipe-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 14px 0 58px; color: #FFFFFF; font-weight: 700; font-size: 1rem; pointer-events: none; transition: opacity .2s;
}
.swipe-label svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; opacity: .85; }
.swipe-thumb {
  position: absolute; top: 4px; left: 4px; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; cursor: grab; touch-action: none;
  background: #FFFFFF; color: #0A4B81; box-shadow: 0 2px 10px rgba(6, 20, 34, .3); transition: transform .25s ease;
}
.swipe-thumb:active { cursor: grabbing; }
.swipe-thumb:focus-visible { outline: 3px solid #FFFFFF; outline-offset: -6px; }
.swipe-thumb svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.swipe.is-busy, .swipe.is-done { cursor: default; }
.swipe.is-busy .swipe-thumb, .swipe.is-done .swipe-thumb { cursor: default; box-shadow: none; }
.swipe.is-done .swipe-label { padding-left: 14px; padding-right: 58px; }
.swipe-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.swipe-text strong { font-size: 1rem; font-weight: 700; }
.swipe-text small { font-size: .78rem; font-weight: 600; opacity: .85; }
@media (prefers-reduced-motion: reduce) { .swipe-fill, .swipe-thumb, .swipe-label { transition: none; } }

/* ---------- schedule cards ---------- */
.scard { grid-template-columns: minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 6px; }
.scard-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.schip { padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; background: var(--locked-bg); color: var(--locked-fg); }
.st-active .schip { background: var(--temp-bg); color: var(--temp-fg); }
.st-cancelled .schip, .st-missed .schip { background: var(--surface-2); color: var(--muted); }
.st-done .schip { background: var(--surface-2); color: var(--muted); }
.has-problem .schip { background: var(--att-bg); color: var(--att-fg); }
.st-active { border-color: var(--sky); }
.when { font-size: .92rem; color: var(--muted); font-weight: 600; }
.stitle { font: 700 1.12rem/1.3 var(--sans); color: var(--text); }
.sdoors { margin: 0; color: var(--text); font-size: .95rem; }
.sproblem { margin: 2px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--att-bg); color: var(--att-fg); font-size: .9rem; font-weight: 600; }
.sfoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }
.sby { color: var(--muted); font-size: .85rem; }

/* ---------- log ---------- */
.log-day { margin: 20px 0 6px; font: 700 .95rem/1.3 var(--sans); color: var(--muted); }
.log-list { list-style: none; margin: 0; padding: 4px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.log-list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.log-list li:last-child { border-bottom: 0; }
.log-dot { flex: none; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--locked-fg); }
.lk-unlock .log-dot { background: var(--sky); }
.lk-hold .log-dot { background: var(--open-fg); }
.lk-schedule .log-dot { background: var(--blue); outline: 2px solid var(--sky); outline-offset: 1px; }
.lk-problem .log-dot { background: var(--att-fg); }
.log-text { flex: 1; min-width: 0; font-size: .95rem; }
.lk-problem .log-text { color: var(--att-fg); font-weight: 600; }
.log-list time { flex: none; color: var(--muted); font-size: .85rem; padding-top: 1px; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1 1 0; min-width: 0; min-height: 52px; border: 0; background: none; cursor: pointer; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .78rem; font-weight: 700;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="page"] { color: var(--heading); }

/* ---------- sheets ---------- */
dialog {
  width: min(560px, 100%); max-width: 100%; max-height: 92dvh; overflow-y: auto;
  margin: auto auto 0; padding: 0; border: 0; border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--text);
}
@media (min-width: 640px) { dialog { margin: auto; border-radius: 22px; } }
dialog::backdrop { background: rgba(4, 14, 24, .55); }
.sheet { padding: 8px 20px calc(24px + var(--safe-bottom)); display: grid; gap: 14px; margin: 0; }
.grabber { justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font: 700 1.45rem/1.2 var(--serif); color: var(--heading); }
.close { flex: none; width: 44px; height: 44px; margin: -6px -10px 0 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.close svg { width: 22px; height: 22px; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.state-line { margin: 0; padding: 12px 14px; border-radius: 12px; font-weight: 700; }
.state-line small { display: block; font-weight: 400; opacity: .85; }
.sheet-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.hint { margin: -4px 0 0; color: var(--muted); font-size: .9rem; }
.fav-toggle { justify-self: start; min-height: 44px; padding: 0; border: 0; background: none; color: var(--link); font-weight: 700; cursor: pointer; }
.activity { border-top: 1px solid var(--line); padding-top: 14px; }
.activity h3 { margin: 0 0 6px; font: 700 1rem/1.3 var(--sans); color: var(--heading); }
.act-list { list-style: none; margin: 0; padding: 0; }
.act-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.act-list li:last-child { border-bottom: 0; }
.act-list time { flex: none; color: var(--muted); font-size: .85rem; }
.act-denied .act-text { color: var(--att-fg); font-weight: 600; }
.act-note { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- schedule form ---------- */
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > span, .field legend { font-weight: 700; color: var(--text); padding: 0; }
.field small { font-weight: 400; color: var(--muted); }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .mini-search {
  width: 100%; min-height: 48px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 17px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.door-picks { list-style: none; margin: 6px 0 0; padding: 4px 0; max-height: 34dvh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.door-picks label { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; cursor: pointer; }
.door-picks input { width: 22px; height: 22px; accent-color: var(--blue); flex: none; }
.sf-summary { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--temp-bg); color: var(--temp-fg); font-weight: 600; }
.sf-summary:empty { display: none; }
.form-error { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--open-bg); color: var(--open-fg); font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); transform: translateX(-50%); z-index: 30;
  width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; text-align: center;
  background: var(--blue); color: #FFFFFF; font-weight: 600; box-shadow: 0 8px 28px rgba(4, 14, 24, .28);
}
.toast.err { background: #A3241A; }

/* ================= v0.5: emergencies, roles, admin ================= */
:root { --red: #B42318; --red-dark: #8F1C13; --red-bg: #FDECEA; }
@media (prefers-color-scheme: dark) { :root { --red-bg: #4A1712; } }

.top-right { display: flex; align-items: center; gap: 10px; }
.emergency-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 22px;
  background: var(--red); color: #FFFFFF; font-weight: 700; font-size: .95rem; cursor: pointer;
}
.emergency-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* banners under the header */
.banners { position: sticky; top: calc(57px + var(--safe-top)); z-index: 9; display: grid; }
.banner-incident {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border: 0; text-align: left; cursor: pointer;
  color: #FFFFFF; font: inherit;
}
.banner-incident.tone-real { background: var(--red); }
.banner-incident.tone-drill { background: var(--blue); }
.banner-incident svg { width: 28px; height: 28px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ib-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.ib-text strong { font-size: 1.1rem; }
.ib-text span { font-size: .9rem; opacity: .95; }
.tag { flex: none; padding: 3px 9px; border-radius: 6px; background: #FFFFFF; color: var(--blue); font-size: .8rem; font-weight: 700; letter-spacing: .04em; }
.tone-real .tag { color: var(--red); }
.tag-real { background: var(--red); color: #FFFFFF; }
.tag-drill { background: var(--locked-bg); color: var(--locked-fg); }
.banner-announce { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--red); color: #FFFFFF; }
.ab-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.ab-text strong { font-size: 1.05rem; }
.ab-text small { opacity: .9; font-size: .8rem; }
.ab-btn { flex: none; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: #FFFFFF; color: var(--red); font-weight: 700; cursor: pointer; }

body.no-tabs main { padding-bottom: calc(var(--safe-bottom) + 28px); }
body.no-tabs .toast { bottom: calc(var(--safe-bottom) + 16px); }

/* home for staff without doors */
.home-card { margin: 16px 0; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.home-card p { margin: 0 0 10px; }
.home-card p:last-child { margin: 0; color: var(--muted); }
.home-lede { font-size: 1.15rem; }

/* incident view */
.tags { display: flex; gap: 6px; }
.tags .tag { background: var(--blue); color: #FFFFFF; }
.tone-real .tags .tag { background: var(--red); }
.intro-box { display: grid; gap: 2px; margin: 14px 0 0; padding: 14px 16px; border-radius: 16px; background: var(--locked-bg); color: var(--locked-fg); }
.tone-real .intro-box { background: var(--red-bg); color: var(--red-dark); }
@media (prefers-color-scheme: dark) { .tone-real .intro-box { color: #FFB8AE; } }
.intro-box strong { font-size: 1.2rem; line-height: 1.2; }
.intro-box span { color: var(--text); font-size: .95rem; }
.checkin, .checked-card { margin: 16px 0 0; padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 12px; }
.checkin h2, .checked-card h2 { margin: 0; font: 700 1.35rem/1.2 var(--serif); color: var(--heading); }
.checked-card p { margin: 0; }
.checked-card.is-help { border-color: var(--red); }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.stepper button { height: 46px; border: 0; background: none; color: var(--heading); font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.stepper input { width: 100%; min-width: 0; border: 0; background: transparent; text-align: center; font-size: 1.25rem; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type="number"] { width: 100%; }
.row-btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.btn.big { min-height: 60px; font-size: 1.05rem; border-radius: 16px; line-height: 1.15; text-align: center; }
.btn.danger { color: var(--red); border-color: var(--red); background: var(--surface); }
#incEnd { margin-top: 18px; border-color: var(--heading); }

/* dashboard */
#dash { margin-top: 20px; }
.dash-head { display: flex; align-items: baseline; justify-content: space-between; }
.dash-head h2 { margin: 0; font: 700 1.35rem/1.2 var(--serif); color: var(--heading); }
.timer { font: 700 1.6rem/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--heading); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat { display: grid; gap: 2px; padding: 12px; border-radius: 14px; }
.stat b { font-size: 1.7rem; line-height: 1; }
.stat span { font-size: .82rem; font-weight: 700; }
.st-help { background: var(--red-bg); color: var(--red); }
@media (prefers-color-scheme: dark) { .st-help { color: #FFB8AE; } }
.st-safe { background: var(--locked-bg); color: var(--locked-fg); }
.st-none { background: var(--surface-2); color: var(--muted); }
#stStudents { margin-top: 8px; }
.dash-sec { margin: 18px 0 6px; font: 700 .95rem/1.3 var(--sans); color: var(--muted); }
.dash-list, .drill-list { list-style: none; margin: 0; padding: 2px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.dash-list li, .drill-list li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dash-list li:last-child, .drill-list li:last-child { border-bottom: 0; }
.dash-list.is-help { border-color: var(--red); }
.dl-top { display: flex; align-items: baseline; gap: 8px; }
.dl-top time { margin-left: auto; color: var(--muted); font-size: .85rem; }
.dl-who, .dl-detail { color: var(--muted); font-size: .9rem; }
.dl-note { justify-self: start; margin-top: 2px; padding: 5px 9px; border-radius: 8px; background: var(--att-bg); color: var(--att-fg); font-size: .9rem; font-weight: 600; }
.dl-missing { font-weight: 600; }

/* emergency chooser */
.test-note { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--att-bg); color: var(--att-fg); font-weight: 600; font-size: .9rem; }
.em-sec { margin: 6px 0 0; font: 700 .95rem/1.3 var(--sans); color: var(--muted); }
#emBody { display: grid; gap: 8px; }
.em-group { display: grid; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.em-group .em-row { border-radius: 0; border: 0; border-bottom: 1px solid var(--line); }
.em-group .em-row:last-child { border-bottom: 0; }
.em-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; cursor: pointer; font: inherit;
  border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
}
.em-row:disabled { cursor: default; opacity: .7; }
.em-ic svg { width: 26px; height: 26px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.em-tx { flex: 1; display: grid; gap: 2px; }
.em-tx strong { font-size: 1.05rem; }
.em-tx span { font-size: .88rem; color: var(--muted); }
.em-row .chev { margin-left: 0; }
.em-row.tone-red { background: var(--red); border-color: var(--red); color: #FFFFFF; }
.em-row.tone-red .em-tx span, .em-row.tone-red .chev { color: #FFFFFF; stroke: #FFFFFF; opacity: .95; }
.em-row.tone-redline { border-color: var(--red); }
.em-row.tone-redline strong, .em-row.tone-redline .em-ic { color: var(--red); }
.em-row.tone-blue .em-ic, .em-row.tone-blue strong { color: var(--heading); }

/* full-screen confirm */
dialog.full { width: 100%; max-width: 560px; height: 100dvh; max-height: 100dvh; margin: 0 auto; border-radius: 0; }
@media (min-width: 640px) { dialog.full { height: auto; max-height: 92dvh; margin: auto; border-radius: 22px; } }
.confirm { min-height: 100%; box-sizing: border-box; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding: calc(16px + var(--safe-top)) 22px calc(24px + var(--safe-bottom)); }
.confirm-top { display: grid; gap: 16px; align-content: start; }
.confirm-bottom { display: grid; gap: 12px; }
.back { justify-self: start; min-height: 44px; }
.cf-icon { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: var(--locked-bg); color: var(--blue); }
.tone-red .cf-icon { background: var(--red-bg); color: var(--red); }
.cf-icon svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.confirm h1 { font-size: 2rem; }
.tone-red .confirm h1 { color: var(--red); }
@media (prefers-color-scheme: dark) { .tone-red .confirm h1 { color: #FFB8AE; } }
.cf-directive { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--red-bg); color: var(--red-dark); font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
@media (prefers-color-scheme: dark) { .cf-directive { color: #FFB8AE; } }
.tone-blue .cf-directive { background: var(--locked-bg); color: var(--locked-fg); }
.cf-list { margin: 0; padding: 14px 16px 14px 34px; display: grid; gap: 8px; border-radius: 16px; background: var(--surface-2); }
.cf-warn { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--att-bg); color: var(--att-fg); font-weight: 700; }
.swipe.big { height: 64px; border-radius: 32px; }
.swipe.big .swipe-thumb { width: 56px; height: 56px; }
.swipe.big .swipe-label { padding-left: 66px; }
.swipe.tone-red { background: var(--red); }
.swipe.tone-red .swipe-fill { background: var(--red-dark); }
.swipe.tone-red .swipe-thumb { color: var(--red); }
.swipe.tone-blue { background: var(--blue); }

/* doors during lockdown */
.ld-off { margin: 0; min-height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 26px; border: 1.5px dashed var(--line); background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: .95rem; }

/* admin */
.admin-card { margin: 16px 0 0; padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 12px; }
.admin-card h2 { margin: 0; font: 700 1.25rem/1.2 var(--serif); color: var(--heading); }
.admin-card h3 { margin: 6px 0 0; font: 700 1rem/1.3 var(--sans); color: var(--text); }
.admin-card p { margin: 0; }
.group-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .92rem; }
.group-list li { display: flex; justify-content: space-between; gap: 10px; }
.group-list span { color: var(--muted); overflow-wrap: anywhere; text-align: right; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; cursor: pointer; }
.switch input { width: 24px; height: 24px; accent-color: var(--blue); flex: none; margin: 0; }
.field select { width: 100%; min-height: 48px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font: inherit; color: var(--text); }
.seg.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.seg.three button { font-size: .9rem; }

/* drill log */
.tally { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.tally-item { display: grid; gap: 2px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.tally-item b { font-size: 1.5rem; line-height: 1; color: var(--heading); }
.tally-item span { color: var(--muted); font-size: .85rem; font-weight: 600; }
#logDrills .btn.wide { margin-top: 14px; }
#logDrills .drill-list .tag { background: var(--surface-2); color: var(--muted); }
#logDrills .drill-list .tag-real { background: var(--red); color: #FFFFFF; }
#logDrills .drill-list .tag-drill { background: var(--locked-bg); color: var(--locked-fg); }
