/* Clean light dashboard: white cards on a cool grey page, hairline borders,
 * soft one-pixel shadows, one blue for the primary action.
 *
 * Tokens first, components after: every colour below is a role, not a one-off
 * hex, so the whole app can be re-themed by editing this block alone. No web
 * font is fetched — the CSP is default-src 'self' with no font-src, so a Google
 * Fonts link would be blocked — and the system UI face is used on purpose.
 *
 * The same CSP has no style-src, which means the browser refuses a
 * `style="..."` attribute outright. Anything that would have been written
 * inline is a class here instead. */

:root {
  color-scheme: light;

  /* ── colour roles ─────────────────────────────────────────────────────── */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --subtle: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --ink: #101828;
  --muted: #667085;

  --accent: #2f5bea;
  --accent-hover: #2349cc;
  --on-accent: #ffffff;
  --accent-soft: #eef2ff;

  --ok: #12804a;    --ok-soft: #e7f6ee;
  --bad: #d92d20;   --bad-soft: #fdecea;   --bad-line: #f7c7c2;
  --warn: #b54708;  --warn-soft: #fef4e6;  --warn-line: #f8d9b0;

  /* ── shape and depth ──────────────────────────────────────────────────── */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 1px 3px rgba(16, 24, 40, .08), 0 12px 32px -8px rgba(16, 24, 40, .14);
  --ring: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);

  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --page: 1320px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.hide { display: none !important; }
.wide { width: 100%; }
.spaced { margin-top: 20px; }

/* ── top bar ──────────────────────────────────────────────────────────────
 * One row: brand, destinations, the signed-in account. Sticky and slightly
 * translucent so the page reads as scrolling under it. */

.topnav {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topnav-in {
  max-width: var(--page); margin: 0 auto; padding: 0 20px;
  min-height: 56px; display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--ink);
  display: grid; place-items: center; flex: none;
}
.brand-mark::after { content: ""; width: 10px; height: 10px; border: 2px solid var(--surface); border-radius: 2px; }
.brand .part {
  font: 500 11px/1 var(--mono); color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 6px;
}

.tabs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.navgroup { display: contents; }
button.tab {
  height: 34px; padding: 0 11px; border: 0; border-radius: var(--r-md);
  background: none; color: var(--muted); font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; box-shadow: none;
}
button.tab:hover:not(:disabled) { background: var(--subtle); color: var(--ink); }
button.tab.on { background: var(--subtle); color: var(--ink); }
button.tab.dev.on { background: var(--warn-soft); color: var(--warn); }
button.tab:disabled { opacity: .4; cursor: not-allowed; }

/* Count of benches waiting on an admin, beside the Devices entry. */
.navbadge {
  min-width: 18px; padding: 0 6px; border-radius: 999px; text-align: center;
  background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 600; line-height: 18px;
}

.who { margin-left: auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px; border-radius: var(--r-md); color: var(--muted); font-weight: 500;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: var(--subtle); color: var(--ink); }
.usermenu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 8px; display: flex; flex-direction: column; gap: 4px;
}
.usermenu .menu > button.link { justify-content: flex-start; width: 100%; text-align: left; padding: 8px 10px; }
.chev {
  width: 7px; height: 7px; margin-top: -3px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform .15s ease;
}
.usermenu[open] .chev { transform: rotate(-135deg); margin-top: 3px; }
.versions {
  display: flex; flex-direction: column; gap: 6px; padding: 10px; margin-top: 4px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.versions #winVersionRow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.versions label { margin: 0; font-size: 12px; }
.versions select.mini { height: 28px; padding: 0 6px; font-size: 12px; width: auto; }
.versions button.link { padding: 2px 4px; }
.versions .err:empty { display: none; }
.versions .err, .versions .ok { margin: 0; font-size: 12px; }
.offerline { margin: 0 0 12px; font-size: 14px; }
.offerline button.link { padding: 0 4px; }
.rowbtns { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ── page layout ──────────────────────────────────────────────────────────*/

.view {
  max-width: var(--page); margin: 0 auto; padding: 24px 20px 48px;
  display: flex; flex-direction: column; gap: 20px;
}

/* Flash: the job on the left, what happened on the right. */
.flashview { display: grid; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.flashview.hide { display: none !important; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col.side { position: sticky; top: 76px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }

/* An operator loses every .detail block, so the two-up row would hold two
   half-empty boxes. One column reads cleaner. */
body.operator .row2 { grid-template-columns: 1fr; }

/* ── cards ────────────────────────────────────────────────────────────────*/

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 16px 18px 18px; min-width: 0;
}
.card > h2, .card > .rowhead {
  margin: -16px -18px 16px; padding: 12px 18px; min-height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.rowhead-right { display: flex; align-items: center; gap: 8px; }
.card.danger { border-color: var(--bad-line); }
.card.danger > h2 { color: var(--bad); }

h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 14px; font-weight: 600; margin: 0; color: var(--ink); }

/* ── the status card at the top of Flash ──────────────────────────────────*/

.herocard { padding: 0; overflow: hidden; }
.hero { display: flex; align-items: center; gap: 18px; padding: 22px; flex-wrap: wrap; }
.stage { display: flex; align-items: center; gap: 16px; flex: 1 1 320px; min-width: 0; }
.stage-ic {
  flex: none; width: 52px; height: 52px; border-radius: 14px;
  background: var(--subtle); color: var(--muted); display: grid; place-items: center;
}
/* The icon is a mask so it takes the state's colour from `color`. */
.stage-ic::before {
  content: ""; width: 26px; height: 26px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.stage { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 7V3M15 7V3M7 7h10v5a5 5 0 0 1-10 0zM12 17v4'/%3E%3C/svg%3E"); }
.stage.good { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E"); }
.stage.bad { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.5v.5'/%3E%3C/svg%3E"); }
.stage.busy { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.stage.good .stage-ic { background: var(--ok-soft); color: var(--ok); }
.stage.bad .stage-ic { background: var(--bad-soft); color: var(--bad); }
.stage.busy .stage-ic { background: var(--warn-soft); color: var(--warn); }
.stage-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stage-big { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.stage.good .stage-big { color: var(--ok); }
.stage.bad .stage-big { color: var(--bad); }
.stage-small { color: var(--muted); }
.stage-small:empty { display: none; }
.hero #doFlash { flex: 0 0 auto; }

/* Linear progress, as a hairline along the bottom of the status row. */
.bar { height: 3px; background: var(--subtle); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
.bar.done > div { background: var(--ok); }
.bar.failed > div { background: var(--bad); }

.tracker {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--border);
}
.bar:not(.hide) + .tracker { border-top: 0; }
.tracker li {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  font-size: 13px; color: var(--muted); border-right: 1px solid var(--border);
}
.tracker li:last-child { border-right: 0; }
.tracker li::before {
  content: ""; flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); box-sizing: border-box;
}
.tracker li.done { color: var(--ink); }
.tracker li.done::before { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 3px var(--surface); }
.tracker li.on { color: var(--ink); font-weight: 600; }
.tracker li.on::before { border-color: var(--warn); border-top-color: transparent; animation: spin .8s linear infinite; }
.tracker li.fail { color: var(--bad); font-weight: 600; }
.tracker li.fail::before { background: var(--bad); border-color: var(--bad); box-shadow: inset 0 0 0 3px var(--surface); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Why the button is off. Always spelled out, never a bare greyed button. */
.why {
  margin: 0; padding: 11px 22px; border-top: 1px solid var(--border);
  background: var(--subtle); color: var(--ink); font-size: 13px;
}
.why::before { content: "ⓘ"; color: var(--muted); margin-right: 8px; }
.why:empty { display: none; }

/* ── form fields ──────────────────────────────────────────────────────────*/

label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 500; color: var(--ink); }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; }
label.inline > span { white-space: nowrap; }
label.check { cursor: pointer; }

input[type=text], input[type=password], input[type=email], input[type=date],
input:not([type]), select {
  width: 100%; height: 38px; padding: 0 12px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow);
}
select { padding-right: 32px; }
input[type=file] {
  width: 100%; padding: 10px; font: inherit; color: var(--muted);
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: var(--subtle);
}
input[type=file]::file-selector-button {
  margin-right: 12px; height: 30px; padding: 0 12px; font: inherit; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
}
input::placeholder { color: #98a2b3; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:disabled, select:disabled { background: var(--subtle); color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* A checkbox drawn as a switch. */
label.switch { margin-top: 16px; }
label.switch input {
  appearance: none; -webkit-appearance: none; width: 34px; height: 20px; flex: none;
  border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer;
  transition: background .15s;
}
label.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s;
}
label.switch input:checked { background: var(--accent); }
label.switch input:checked::after { transform: translateX(14px); }

/* Labelled fields in a row, with the buttons sitting on their baseline. */
.fields { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; }
.field { flex: 1 1 220px; min-width: 0; }
.field.narrow { flex: 0 1 180px; }
.field-actions { display: flex; gap: 8px; padding-top: 16px; }
.card > .rowhead + .fields label, .card > .rowhead + .hide + .fields label { margin-top: 0; }

/* ── buttons ──────────────────────────────────────────────────────────────
 * .primary filled blue · .warn red outline · default and .ghost outlined ·
 * .link text only · .big the one action of the flash screen. */

button {
  height: 36px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: var(--shadow); transition: background-color .12s, border-color .12s, box-shadow .12s;
}
button:hover:not(:disabled) { background: var(--subtle); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { height: 30px; padding: 0 10px; font-size: 13px; }

button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.warn { color: var(--bad); border-color: var(--bad-line); }
button.warn:hover:not(:disabled) { background: var(--bad-soft); }
button.ghost { background: var(--surface); }
button.link {
  height: auto; padding: 4px 6px; border: 0; background: none; box-shadow: none;
  color: var(--accent); border-radius: var(--r-sm);
}
button.link:hover:not(:disabled) { background: var(--accent-soft); }

button.big {
  height: 52px; padding: 0 28px; font-size: 16px; font-weight: 600; border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), 0 6px 16px -4px color-mix(in srgb, var(--accent) 50%, transparent);
}
button.big:disabled { opacity: 1; background: var(--subtle); border-color: var(--border); color: var(--muted); box-shadow: none; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.controls.end { justify-content: flex-end; margin-top: 24px; }
.controls input:not([type=checkbox]), .controls select { flex: 0 1 260px; width: auto; }
.card > input:not([type=checkbox]):not([type=file]), .card > select:not(.wide) { max-width: 520px; }
.card > .kv + .controls { margin-top: 16px; }

/* ── pills: state at a glance ─────────────────────────────────────────────*/

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; background: var(--subtle); color: var(--muted);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.busy { background: var(--warn-soft); color: var(--warn); }

/* A headline number, with its unit beside it. */
.metric { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin: 0 0 6px; }
.metric-value { font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric-value.bad { color: var(--bad); }
.metric-label { color: var(--muted); }

/* ── content ──────────────────────────────────────────────────────────────*/

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font: 13px/1.5 var(--mono); text-align: right; min-width: 0; overflow-wrap: anywhere; }
.card > .kv:not(:first-child):not(.rowhead + .kv) { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

.hint { color: var(--muted); margin: 12px 0 0; font-size: 13px; }
.hint b { color: var(--ink); font-weight: 600; }
code { font: 12px var(--mono); background: var(--subtle); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; }
.err { color: var(--bad); margin: 12px 0 0; font-size: 13px; }
.ok { color: var(--ok); margin: 12px 0 0; font-size: 13px; }
.err:empty, .ok:empty { display: none; }

.status { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.status:empty { display: none; }
.status.good { color: var(--ok); }
.status.bad { color: var(--bad); }
.empty { margin: 0; color: var(--muted); }

.log {
  font: 12px/1.7 var(--mono); color: var(--muted);
  background: var(--subtle); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 12px; margin: 10px 0 0; overflow: auto; white-space: pre-wrap;
  max-height: min(420px, calc(100vh - 360px));
}
.log:empty { display: none; }

.devbanner, .oldbanner {
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line);
  border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 16px; font-weight: 500;
}
.oldbanner { margin: 16px 0 0; }
.card > .rowhead + .oldbanner { margin-top: 0; }

/* The one thing the page says before it has a page: no WebUSB here. */
.nousb { margin: 0; padding: 12px 20px; background: var(--bad-soft); color: var(--bad); border-bottom: 1px solid var(--bad-line); font-weight: 500; }

/* ── tables ───────────────────────────────────────────────────────────────*/

.tablewrap { overflow-x: auto; margin: 0 -18px; }
.tablewrap:last-child { margin-bottom: -18px; }
/* Flush under the card header, even with a hidden banner or error between. */
.card > .rowhead + .tablewrap, .card > h2 + .tablewrap,
.card > .rowhead + .hide + .tablewrap, .card > .rowhead + .err:empty + .tablewrap { margin-top: -16px; }
.tablewrap:not(:last-child) { border-bottom: 1px solid var(--border); }
.tablewrap.scroll { max-height: 460px; overflow-y: auto; }
.tablewrap.scroll th { position: sticky; top: 0; z-index: 1; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 11px 18px; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { background: var(--subtle); color: var(--muted); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr:hover td { background: #fafbfc; }
td.mono { font: 12px var(--mono); }
td:empty { padding: 0; }
.metric + .tablewrap, .hint + .tablewrap { margin-top: 16px; border-top: 1px solid var(--border); }

/* An icon-only control: the handle that opens a row's actions. */
.iconbtn {
  width: 32px; height: 32px; padding: 0; border: 0; background: none; box-shadow: none;
  border-radius: var(--r-md); color: var(--muted);
}
.iconbtn:hover:not(:disabled) { background: var(--subtle); color: var(--ink); }
.ic { width: 20px; height: 20px; fill: currentColor; transition: transform .15s ease; }
.iconbtn.open .ic { transform: rotate(180deg); }

/* What a row can *do*, opened underneath it. */
.rowdetail td { white-space: normal; padding: 0; background: var(--subtle); }
.rowdetail:hover td { background: var(--subtle); }
.rowacts { display: flex; flex-wrap: wrap; gap: 20px 32px; padding: 16px 18px 18px; border-left: 3px solid var(--accent); }
.rowact { display: flex; flex-direction: column; gap: 8px; }
.rowact-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.rowact-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.rowact-buttons button { height: 32px; padding: 0 12px; font-size: 13px; }
/* Detail lines in a panel: a flex row ignores <br>, so each <small> takes a line. */
.rowact-buttons > small { flex-basis: 100%; color: var(--muted); }
.rowact-buttons { max-width: 560px; overflow-wrap: anywhere; }

/* Tabs inside a card, flush where a header would be. */
.tabstrip { display: flex; gap: 4px; margin: -16px -18px 16px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.tabstrip-tab {
  position: relative; height: 48px; padding: 0 10px; border: 0; border-radius: 0;
  background: none; box-shadow: none; color: var(--muted); font-weight: 500;
}
.tabstrip-tab:hover:not(:disabled) { background: none; color: var(--ink); }
.tabstrip-tab.on { color: var(--ink); }
.tabstrip-tab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }

/* Controls that live in a card header. */
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.filters .hint { margin: 0; }
.filters label.inline { color: var(--muted); }
.filters select, .filters input[type=date] { height: 32px; width: auto; font-size: 13px; }

/* ── dialogs ──────────────────────────────────────────────────────────────*/

.modal {
  position: fixed; inset: 0; z-index: 50; padding: 24px;
  background: rgba(16, 24, 40, .45); backdrop-filter: blur(2px);
  display: grid; place-items: center;
}
.modalbox {
  width: 100%; max-width: 480px; max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 24px; box-shadow: var(--shadow-lg);
}
.modalbox h2 { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.modalbox > .hint:first-of-type { margin-top: 0; }
.modalbox label.inline { margin: 16px 0 0; }
.modalbox label.inline + .hint { margin-top: 6px; }

/* A field with Show / Generate beside it, at the same height. */
.reveal { display: flex; align-items: stretch; gap: 8px; }
.reveal input { flex: 1 1 auto; min-width: 0; }
.reveal button { flex: 0 0 auto; height: 38px; }

/* ── sign in ──────────────────────────────────────────────────────────────
 * Its own screen: the top bar is hidden (body.signedout), the card is centred,
 * and the pad is sized for a thumb at arm's length rather than a mouse. */

body.signedout .topnav { display: none; }

.boot { position: fixed; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }

.view.login { max-width: none; min-height: 100vh; min-height: 100dvh; padding: 24px; align-items: center; justify-content: center; }
.signin { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.signin-brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.signin-brand .mark { flex: none; width: 40px; height: 40px; padding: 9px; border-radius: 10px; background: var(--ink); fill: var(--surface); }
.signin-name { font-size: 18px; font-weight: 600; }
.signin-part { font: 500 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.signin-foot { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }

.card.auth { width: 100%; padding: 28px 24px 24px; border-radius: var(--r-xl); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.card.auth h1 { margin: 0 0 4px; }
.card.auth .sub { margin: 0 0 8px; color: var(--muted); }
.card.auth .sub:empty { display: none; }
.card.auth .err { min-height: 20px; }
.card.auth .err:empty { display: block; }
.card.auth > .link { align-self: center; margin-top: 16px; }
.card.auth > button.big { margin-top: 24px; width: 100%; }
.signin-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 16px; }

/* Caps Lock: amber, not red. Nothing has gone wrong yet. */
.caps { margin-top: 10px; padding: 8px 12px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn); font-weight: 500; }

/* Who the machine remembers: the fastest check that the pad will unlock YOUR
   account and not the shift before yours. */
.avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 0 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-size: 22px; font-weight: 600; text-transform: uppercase;
}

/* One dot per digit, never the digits. */
.pindots { display: flex; gap: 14px; margin: 20px 0 0; min-height: 16px; }
.pindots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); transition: transform .12s, background-color .12s, border-color .12s; }
.pindots span.on { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }
.pindots.wrong { animation: shake .3s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.pinkey {
  height: 62px; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 22px; font-weight: 500;
}
.pinkey svg { width: 22px; height: 22px; fill: currentColor; }
.pinkey:hover:not(:disabled) { background: var(--subtle); }
.pinkey:active:not(:disabled) { background: var(--border); }
.pinkey.ghost { border-color: transparent; box-shadow: none; background: none; color: var(--muted); }
.pinkey.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pinkey.primary:hover:not(:disabled) { background: var(--accent-hover); }
.pinkey.primary:disabled { opacity: 1; background: var(--subtle); border-color: var(--border); color: var(--muted); }

/* Detail an operator has no use for: probe and chip readouts, the build's hash
   and addresses, and the log. Safety text stays for everyone. */
body.operator .detail { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ── narrower screens ─────────────────────────────────────────────────────*/

@media (max-width: 1100px) {
  .flashview { grid-template-columns: 1fr; }
  .col.side { position: static; }
}

@media (max-width: 760px) {
  .topnav-in { flex-wrap: wrap; gap: 8px 16px; padding: 8px 16px; }
  .tabs { order: 3; flex: 1 1 100%; margin: 0 -4px; }
  .view { padding: 16px 16px 40px; gap: 16px; }
  .row2 { grid-template-columns: 1fr; }
  .hero { padding: 18px; }
  .hero #doFlash { width: 100%; }
  .tracker { grid-template-columns: repeat(3, 1fr); }
  .tracker li:nth-child(3) { border-right: 0; }
  .tracker li:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { text-align: left; margin-bottom: 8px; }
  .usermenu .menu { right: -8px; }
  .brand .part { display: none; }
}

/* A table with nothing visible after it sits flush with the card's bottom edge,
   even when hidden panels or empty message lines follow it in the markup. */
.tablewrap:not(:has(~ :not(.hide, .err:empty, .ok:empty))) { margin-bottom: -18px; border-bottom: 0; }
.signin-links:not(:has(> :not(.hide))) { display: none; }

/* ── approving this computer (sign-in) ───────────────────────────────────*/

.bench-ic {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 0 16px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.bench-ic::before {
  content: ""; width: 26px; height: 26px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='12' rx='2'/%3E%3Cpath d='M8 20h8M12 16v4'/%3E%3C/svg%3E");
}
#benchCard[data-kind="wait"] .bench-ic { background: var(--warn-soft); color: var(--warn); }
#benchCard[data-kind="stop"] .bench-ic { background: var(--bad-soft); color: var(--bad); }
#benchForm > button.big { margin-top: 20px; width: 100%; }
.benchwait {
  display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--subtle); color: var(--muted); font-size: 13px;
}
.spinner {
  flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--warn); animation: spin .8s linear infinite;
}
.card.auth .ok:empty { display: none; }

/* PCROP start/end on the firmware upload form. */
.pcroprow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pcroprow input { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); }
@media (max-width: 560px) { .pcroprow { grid-template-columns: 1fr; } }
