/* Loaner Board — presentation layer.
   Single stylesheet, no build step, no external fonts. */

/* Ink on paper. The board is a working document, not an interface to admire, so
   it's drawn the way the paper sheet it replaces was: hairline rules, square
   corners, no shadows, no fills competing for attention.

   Status still carries colour, just muted rather than saturated. Spotting the
   one bad row at a glance is the entire job — going fully monochrome would make
   it prettier and worse. The hues sit at low chroma so a screen of clean rows
   reads as neutral, and the exception is the only thing with colour on it. */
:root {
  --bg:            #f7f7f5;
  --surface:       #ffffff;
  --surface-2:     #fbfbfa;
  --surface-sunk:  #f0f0ee;
  --border:        #d8d8d4;
  --border-strong: #1a1a18;
  --text:          #161614;
  --text-dim:      #5e5e58;
  --text-faint:    #91918a;

  --accent:        #161614;
  --accent-soft:   #eeeeea;
  --accent-text:   #ffffff;

  --ok:            #3a6b52;
  --ok-soft:       #eef4f0;
  --warn:          #8a6524;
  --warn-soft:     #f7f2e8;
  --bad:           #9e3b31;
  --bad-soft:      #f8eeec;
  /* The one fill on the board loud enough to read as an alarm. It needs an
     explicit pair per theme: in dark mode --bad is a light salmon, and white
     text on it would be unreadable. */
  --bad-strong:      #9e3b31;
  --bad-strong-text: #ffffff;
  --out:           #4a4a70;
  --out-soft:      #eeeef4;

  --radius:   3px;
  --radius-s: 2px;
  --shadow:   none;
  --rule:     1px solid var(--border);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --bg:            #131312;
  --surface:       #1a1a19;
  --surface-2:     #1f1f1d;
  --surface-sunk:  #141413;
  --border:        #34342f;
  --border-strong: #e8e8e2;
  --text:          #e8e8e2;
  --text-dim:      #9d9d94;
  --text-faint:    #6e6e66;

  --accent:        #e8e8e2;
  --accent-soft:   #262623;
  --accent-text:   #131312;

  --ok:            #7fb096;
  --ok-soft:       #1a221d;
  --warn:          #c9a25e;
  --warn-soft:     #241f16;
  --bad:           #d4837a;
  --bad-soft:      #251a18;
  --bad-strong:      #5c2621;
  --bad-strong-text: #f8dcd7;
  --out:           #9a9ac4;
  --out-soft:      #1c1c24;

  --shadow: none;
}

* { box-sizing: border-box; }

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p  { margin: 0 0 10px; }
a  { color: var(--accent); }

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

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 22px;
  padding: 0 18px; height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
/* A drawn mark rather than a rendered one: two rules and a box, like the sheet
   this replaces. */
.brand-mark {
  width: 24px; height: 24px; flex: none;
  border: 1.5px solid var(--text); border-radius: var(--radius-s);
  position: relative;
}
.brand-mark::before,
.brand-mark::after {
  content: ""; position: absolute; left: 4px; right: 4px;
  height: 1.5px; background: var(--text);
}
.brand-mark::before { top: 6px; }
.brand-mark::after  { top: 11px; right: 9px; }
.brand-name { font-weight: 680; font-size: 14px; letter-spacing: -.01em; }
.brand-sub  { font-size: 11px; color: var(--text-faint); margin-top: -1px; }

.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
/* Marked with a rule under the label, not a filled pill — one less block of
   colour competing with the rows. */
.tab {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; color: var(--text-dim);
  font: inherit; font-weight: 550; font-size: 13px;
  padding: 7px 12px; margin-bottom: -1px;
  cursor: pointer; white-space: nowrap;
}
.tab:hover { background: none; color: var(--text); border-bottom-color: var(--border); }
.tab.is-active {
  background: none; color: var(--text);
  font-weight: 620; border-bottom-color: var(--text);
}

.topbar-right { display: flex; align-items: center; gap: 6px; flex: none; }

.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: none; color: var(--text-dim); cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--text); border-color: var(--text-dim); }

/* ---------- icons ----------
   Phosphor, inlined by js/icons.js. Sized in em so an icon tracks the type it
   sits next to, and filled with currentColor so it inherits status colour from
   whatever chip or row contains it. */

.ic {
  width: 1.15em; height: 1.15em; flex: none;
  fill: currentColor; vertical-align: -.16em;
}
.ic-label { display: inline-flex; align-items: center; gap: 6px; }
.btn .ic { width: 1.05em; height: 1.05em; }
.icon-btn .ic { width: 17px; height: 17px; }

.backup-pill {
  font-size: 11px; padding: 2px 8px; border-radius: var(--radius-s);
  color: var(--text-dim); background: none; border: 1px solid var(--border);
  white-space: nowrap;
}
.backup-pill.is-stale { border-color: var(--warn); color: var(--warn); font-weight: 600; }

/* ---------- layout ---------- */

main { max-width: 1180px; margin: 0 auto; padding: 22px 18px 80px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head .sub { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); flex-wrap: wrap;
}
.card-head .hint { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stack  { display: flex; flex-direction: column; gap: 10px; }
.row    { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

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

.btn {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 550; font-size: 13px;
  padding: 7px 13px; border-radius: var(--radius-s); cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover { background: var(--surface-sunk); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
}
/* The accent is near-black, so brightness() barely moves it — shift the ink
   towards the page instead, which reads as a press on both themes. */
.btn-primary:hover { background: var(--text-dim); border-color: var(--text-dim); }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: none; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-sunk); color: var(--text); }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ---------- form fields ---------- */

label.field { display: block; }
.field > span {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: 4px;
}
input[type=text], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-s); padding: 7px 9px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 62px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13px; }
.check input { margin-top: 2px; flex: none; }
.check .desc { display: block; color: var(--text-dim); font-size: 12px; margin-top: 2px; }

/* ---------- status chips ---------- */

/* Outlined, not filled. The border carries the status colour and the interior
   stays paper, so a column of chips reads as a list rather than a swatch. */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  padding: 2px 8px; border-radius: var(--radius-s); white-space: nowrap;
  border: 1px solid currentColor; background: var(--surface);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip .ic  { width: 13px; height: 13px; }
.chip.key_missing  { color: var(--warn); }
.chip.car_no_key   { color: var(--bad); }
.chip.unverified   { color: var(--warn); }
.chip.no_contract  { color: var(--bad); }
.chip.accent       { color: var(--text); }

/* On lot and out-on-contract are the two ways a night is meant to go, and in a
   fleet table they're most of the column. Outlining them boxes up every row and
   leaves the exceptions with nothing to stand out against, so they keep only a
   coloured dot and lose the border. What's left ruled is what needs a person. */
/* No border means no need for a fill either — and on the shaded carried-over
   rows the paper-white fill showed up as a floating white block. */
.chip.pending      { color: var(--text-faint); border-style: dashed; }
.chip.pending .dot { background: var(--text-faint); }
.chip.ok, .chip.checked_out, .chip.neutral {
  border-color: transparent; background: none; padding-left: 0;
}
.chip.ok, .chip.checked_out { color: var(--text-dim); font-weight: 550; }
.chip.neutral               { color: var(--text-faint); font-weight: 500; }
.chip.ok .dot          { background: var(--ok); }
.chip.checked_out .dot { background: var(--out); }
.chip.neutral .dot     { background: var(--text-faint); }

/* ---------- count sheet ---------- */

.count-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 14px; position: sticky; top: 58px; z-index: 30;
  box-shadow: var(--shadow);
}
.search-box { position: relative; flex: 1; min-width: 180px; max-width: 300px; }
.search-box input { padding-left: 28px; }
/* Phosphor magnifying-glass, masked so it takes the theme's text colour. */
.search-box::before {
  content: ""; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; pointer-events: none;
  background: var(--text-faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20256%20256%22%3E%3Cpath%20d%3D%22M229.66%2C218.34l-50.07-50.06a88.11%2C88.11%2C0%2C1%2C0-11.31%2C11.31l50.06%2C50.07a8%2C8%2C0%2C0%2C0%2C11.32-11.32ZM40%2C112a72%2C72%2C0%2C1%2C1%2C72%2C72A72.08%2C72.08%2C0%2C0%2C1%2C40%2C112Z%22%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20256%20256%22%3E%3Cpath%20d%3D%22M229.66%2C218.34l-50.07-50.06a88.11%2C88.11%2C0%2C1%2C0-11.31%2C11.31l50.06%2C50.07a8%2C8%2C0%2C0%2C0%2C11.32-11.32ZM40%2C112a72%2C72%2C0%2C1%2C1%2C72%2C72A72.08%2C72.08%2C0%2C0%2C1%2C40%2C112Z%22%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
}

.tally { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; }
.tally b { font-size: 15px; font-weight: 680; display: block; line-height: 1.2; }
.tally .t-label { color: var(--text-faint); font-size: 11px; }
.tally .t-ok b   { color: var(--ok); }
.tally .t-out b  { color: var(--out); }
.tally .t-flag b { color: var(--bad); }
.tally .t-bad b  { color: var(--bad); }
.tally .t-bad .t-label { color: var(--bad); font-weight: 600; }

.sheet { display: flex; flex-direction: column; }
.sheet-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.6fr) auto auto minmax(150px, 1fr);
  align-items: center; gap: 14px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.sheet-row:last-child { border-bottom: 0; }
.sheet-row:hover { background: var(--surface-2); }
.sheet-row.is-flagged { background: var(--bad-soft); }
.sheet-row.is-flagged:hover { filter: brightness(.985); }
.sheet-row.is-out { background: var(--out-soft); }
/* Un-punched. Deliberately quiet — it isn't a finding yet, it's a gap in the
   walk, and the row should read as "not done" rather than "wrong". */
.sheet-row.is-pending { background: repeating-linear-gradient(
  135deg, transparent 0 7px, var(--surface-sunk) 7px 14px); }

.veh-name { font-weight: 600; }
.veh-meta {
  font-size: 11.5px; color: var(--text-faint); font-family: var(--mono);
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px;
}
.veh-meta .carried { color: var(--out); font-family: var(--sans); font-weight: 600; }

/* two-state toggle — three, counting "nobody has answered this yet" */
.toggle {
  display: inline-flex; border: 1px solid var(--border-strong);
  border-radius: var(--radius-s); overflow: hidden; background: var(--surface);
}
.toggle button {
  border: 0; background: none; font: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 12px; cursor: pointer; color: var(--text-dim); white-space: nowrap;
}
.toggle button:hover { background: var(--surface-sunk); }
.toggle button.on[data-val="present"] { background: var(--ok); color: #fff; }
/* "Gone" is a fact, not an alarm — most nights a dozen units are legitimately
   out on contract. The status chip and row tint carry the judgement. */
.toggle button.on[data-val="out"]     { background: var(--out); color: #fff; }
.sheet-row.is-flagged .toggle button.on[data-val="out"] { background: var(--bad); }
.toggle-label {
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 4px; display: block; text-align: center;
}
/* Neither side chosen: dashed, so an un-walked row is obvious at arm's length
   without being coloured like a problem. */
.toggle.tri.is-pending { border-style: dashed; border-color: var(--text-faint); }
.pending-note {
  display: block; text-align: center; margin-top: 3px;
  font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--text-faint);
}

/* dealerware prompt */
.dw-prompt {
  grid-column: 1 / -1; margin-top: 4px;
  border: 1px solid var(--out); border-left-width: 3px;
  background: var(--surface); border-radius: var(--radius-s); padding: 12px 14px;
}
.dw-prompt.is-unverified { border-color: var(--warn); background: var(--warn-soft); }
.dw-prompt.is-bad        { border-color: var(--bad);  background: var(--bad-soft); }
.dw-title { font-weight: 640; font-size: 13px; margin-bottom: 3px; }
.dw-note  { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.dw-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dw-actions input[type=text] { max-width: 220px; }

.empty {
  text-align: center; padding: 46px 20px; color: var(--text-dim);
}
.empty .big { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { font-family: var(--mono); font-size: 12px; }
table.data .clickable { cursor: pointer; }

/* ---------- diff report ---------- */

.diff-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.diff-group { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.diff-group > h3 {
  padding: 9px 13px; font-size: 12px; letter-spacing: .02em;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.diff-group ul { list-style: none; margin: 0; padding: 0; }
.diff-group li { padding: 9px 13px; border-bottom: 1px solid var(--border); font-size: 13px; }
.diff-group li:last-child { border-bottom: 0; }
.diff-group li .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.diff-group.g-out  > h3 { color: var(--out); }
.diff-group.g-in   > h3 { color: var(--ok); }
.diff-group.g-flag > h3 { color: var(--bad); }
.diff-group .none { padding: 13px; color: var(--text-faint); font-size: 12.5px; font-style: italic; }

/* ---------- weekly grid ---------- */

.week-grid { overflow-x: auto; }
.week-grid table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.week-grid th, .week-grid td { border: 1px solid var(--border); padding: 6px 8px; }
.week-grid th { background: var(--surface-2); font-size: 11px; font-weight: 650; white-space: nowrap; text-align: left; }
.week-grid th.day { text-align: center; width: 62px; }
.week-grid td.vname { white-space: nowrap; font-weight: 550; }
.week-grid td.cell { text-align: center; padding: 4px; }
.cell-dot {
  display: inline-block; width: 20px; height: 20px; line-height: 18px;
  border-radius: var(--radius-s); font-size: 10px; font-weight: 650;
  border: 1px solid currentColor; background: var(--surface);
  font-family: var(--mono);
}
.cell-dot.ok           { color: var(--ok); }
.cell-dot.checked_out  { color: var(--out); }
.cell-dot.key_missing  { color: var(--warn); }
.cell-dot.car_no_key   { color: var(--bad); }
/* A day with no count is an absence, so it's drawn as one: dashed, empty. */
.cell-dot.none         { color: var(--text-faint); border-style: dashed; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- retention ---------- */

.block {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; background: var(--surface);
}
.block.safe    { border-left: 3px solid var(--ok); }
.block.blocked { border-left: 3px solid var(--warn); }
.block.young   { border-left: 3px solid var(--border-strong); opacity: .8; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.block-title { font-weight: 650; font-size: 15px; }
.blockers { list-style: none; margin: 12px 0 0; padding: 0; }
.blockers li {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 8px 11px; background: var(--warn-soft); color: var(--warn);
  border-radius: var(--radius-s); margin-bottom: 6px; font-size: 12.5px;
}
.blockers li .why { color: var(--text-dim); display: block; margin-top: 2px; font-weight: 400; }
.keeps {
  margin-top: 12px; padding: 11px 13px; background: var(--surface-sunk);
  border-radius: var(--radius-s); font-size: 12.5px; color: var(--text-dim);
}
.keeps b { color: var(--text); }

.callout {
  padding: 12px 14px; border-radius: var(--radius); font-size: 13px;
  border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 14px;
}
.callout.info { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.callout.bad  { border-color: var(--bad);  background: var(--bad-soft);  color: var(--bad); }
.callout.ok   { border-color: var(--ok);   background: var(--ok-soft);   color: var(--ok); }
.callout b { font-weight: 650; }

/* ---------- modal ---------- */

.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
/* `display:grid` above outranks the UA's [hidden] rule, so restate it. */
.modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10,14,20,.44); }
.modal {
  position: relative; width: min(620px, 100%); max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); border-color: var(--border-strong);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.modal-foot:empty { display: none; }

/* ---------- toasts ---------- */

.toast-stack {
  position: fixed; bottom: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: var(--radius-s);
  box-shadow: var(--shadow); font-size: 13px; max-width: 340px;
  animation: toast-in .18s ease-out;
}
.toast.ok  { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- misc ---------- */

.mono { font-family: var(--mono); font-size: 12px; }
.dim  { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid; grid-template-columns: 92px 1fr; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.timeline li:last-child { border-bottom: 0; }
.timeline .t-date { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

hr.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
  .tabs { order: 3; width: 100%; }
  main { padding: 14px 12px 70px; }
  .sheet-row { grid-template-columns: 1fr auto; row-gap: 10px; }
  .sheet-row .status-cell { grid-column: 1 / -1; }
  .count-toolbar { position: static; }
}

/* ---------------- missing keys ----------------
   The one thing on this board allowed to shout. Everything else is hairlines
   and low chroma precisely so that this reads as different in peripheral
   vision — if a missing key looked like the rest of the page, the page would
   have failed at its only real job. */

.alarm {
  display: flex; align-items: flex-start; gap: 14px;
  border: 1px solid var(--bad); border-left-width: 4px;
  background: var(--bad-soft); color: var(--bad);
  padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius);
}
.alarm-mark { flex: none; margin-top: 1px; }
.alarm-mark .ic { width: 22px; height: 22px; }
.alarm-body { flex: 1; min-width: 0; }
.alarm-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.alarm-text { font-size: 13.5px; margin-top: 5px; line-height: 1.5; }
.alarm-do   { font-size: 13.5px; margin-top: 7px; font-weight: 600; }
.alarm-tier {
  flex: none; align-self: flex-start;
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: var(--radius-s); padding: 3px 7px;
}
/* A key gone one night is a search; a key gone a week is a security incident.
   The tiers escalate the ink so the difference is visible before it is read. */
.alarm-new      { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.alarm-serious  { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.alarm-urgent   { border-color: var(--bad);  background: var(--bad-soft);  color: var(--bad); }
.alarm-critical {
  border-color: var(--bad); background: var(--bad-strong); color: var(--bad-strong-text);
}
.alarm-critical .alarm-tier { border-color: currentColor; opacity: .95; }

.mk-list { display: flex; flex-direction: column; gap: 10px; }
.mk-block { margin-bottom: 18px; }
.mk-row {
  border: 1px solid var(--border); border-left: 4px solid var(--warn);
  background: var(--surface); padding: 12px 14px; border-radius: var(--radius);
}
.mk-urgent   { border-left-color: var(--bad); }
.mk-critical { border-left-color: var(--bad); background: var(--bad-soft); }

.mk-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.mk-who  { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mk-no   { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.mk-desc { font-size: 13.5px; color: var(--text-dim); }
.mk-tag  { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }

/* The number the manager actually asks for, given the size to match. */
.mk-days { flex: none; text-align: right; line-height: 1.05; }
.mk-days b { font-size: 26px; font-weight: 700; letter-spacing: -.03em; color: var(--bad); }
.mk-days span { font-size: 10.5px; color: var(--text-faint); display: block; margin-top: 2px; }

.mk-tier {
  flex: none; font-size: 10px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; padding: 3px 7px; border-radius: var(--radius-s);
  border: 1px solid var(--warn); color: var(--warn);
}
.mk-urgent .mk-tier, .mk-critical .mk-tier { border-color: var(--bad); color: var(--bad); }

.mk-facts {
  margin-top: 8px; display: flex; flex-direction: column; gap: 3px;
  font-size: 13px; color: var(--text-dim); line-height: 1.5;
}
.mk-facts b { color: var(--text); font-weight: 620; }
/* The date is only as good as the nights someone actually looked. Set apart so
   it reads as a qualification of the line above, not another fact. */
.mk-caveat {
  border-left: 2px solid var(--border-strong); padding-left: 8px;
  font-style: italic; opacity: .85;
}
/* ---------- boot screen ----------
   Shows the result of the startup checks. On a clean boot it is a one-second
   reassurance and leaves; on a bad one it blocks, because carrying on would
   mean counting into a record that is not there. */
.boot-root {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
  transition: opacity .25s ease;
}
.boot-root.is-blocking { background: color-mix(in srgb, var(--bg) 94%, transparent); }
.boot-root.is-going { opacity: 0; pointer-events: none; }

.boot-card {
  width: 100%; max-width: 520px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px;
}
.boot-card.is-bad { max-width: 640px; border-color: var(--bad); }

.boot-head { margin-bottom: 16px; }
.boot-title { font-size: 19px; font-weight: 680; letter-spacing: -0.01em; }
.boot-sub { color: var(--text-dim); font-size: 13.5px; margin-top: 3px; }
.boot-card.is-bad .boot-sub { color: var(--bad); font-weight: 600; }

.boot-steps { display: flex; flex-direction: column; gap: 2px; }
.boot-line {
  display: grid; grid-template-columns: 22px 1fr auto;
  align-items: center; gap: 8px;
  font-size: 13.5px; padding: 5px 0;
}
.boot-mark { display: inline-flex; width: 16px; height: 16px; color: var(--text-faint); }
.boot-mark svg { width: 16px; height: 16px; }
.boot-line.is-ok  .boot-mark { color: var(--ok); }
.boot-line.is-bad .boot-mark { color: var(--bad); }
.boot-line.is-wait .boot-label { color: var(--text-faint); }
.boot-detail { color: var(--text-dim); font-size: 12.5px; }
.boot-line.is-bad .boot-detail { color: var(--bad); font-weight: 600; }

/* The placeholder before a check reports — a dot, not a spinner: nothing is
   spinning, the answer simply has not been painted yet. */
.boot-dot {
  width: 7px; height: 7px; margin: 4px; border-radius: 50%;
  background: var(--border-strong); display: block;
  animation: boot-pulse 1s ease-in-out infinite;
}
@keyframes boot-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .boot-dot { animation: none; }
  .boot-root { transition: none; }
}

.boot-why {
  margin-top: 14px; font-size: 13px; line-height: 1.55; color: var(--text-dim);
}
.boot-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.where-block {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}
.where-title { font-size: 12px; font-weight: 680; text-transform: uppercase;
               letter-spacing: .06em; color: var(--text-dim); margin-bottom: 8px; }
.where-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
              font-size: 12.5px; margin: 0; }
.where-list dt { color: var(--text-dim); }
.where-list dd { margin: 0; }
.where-list .mono, .where-block .mono { font-family: var(--mono); font-size: 11.5px; }
.where-list .wrap { overflow-wrap: anywhere; }
.where-note { font-size: 12px; color: var(--text-dim); line-height: 1.5; margin-top: 10px; }

/* Storage answered plainly, because saving is silent and silence is ambiguous. */
.storage-panel {
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface-sunk); padding: 10px 12px; margin-top: 10px;
}
.storage-line {
  display: flex; justify-content: space-between; gap: 16px;
  font-size: 13px; line-height: 1.9;
}
.storage-line span { color: var(--text-dim); }
.storage-line b { text-align: right; }
.ok-text { color: var(--ok); }

/* One chip per uncounted night, each with the action that explains it. */
.day-fixes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.day-fix {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 4px 6px 4px 10px; font-size: 13px;
}
.mk-do  { margin-top: 8px; font-size: 13px; font-weight: 600; }
.mk-act { margin-top: 10px; }

.tier {
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 5px; border: 1px solid currentColor; border-radius: var(--radius-s);
  vertical-align: middle;
}
.tier-new, .tier-serious { color: var(--warn); }
.tier-urgent, .tier-critical { color: var(--bad); }
tr.row-bad td { background: var(--bad-soft); }

/* ---------------- secondary follow-ups ---------------- */

.follow { padding: 12px 0; border-bottom: var(--rule); }
.follow:last-child { border-bottom: 0; padding-bottom: 0; }
.follow-head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.follow-head .ic { width: 17px; height: 17px; }
.follow.bad  .follow-head { color: var(--bad); }
.follow.warn .follow-head { color: var(--warn); }
.follow-note { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.follow-list { margin: 7px 0 0; padding-left: 18px; font-size: 13.5px; }
.follow-list li { margin: 3px 0; }

/* ---------------- the printable report ----------------
   Hidden on screen; it exists so the manager's copy is a document with its own
   order and its own signature line, rather than a screenshot of whatever tab
   happened to be open. */

.print-sheet { display: none; }

.rep-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 24px; border-bottom: 2px solid var(--border-strong); padding-bottom: 12px;
}
.rep-title { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.rep-sub   { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.rep-meta  { font-size: 11.5px; text-align: right; }
.rep-meta div { margin-bottom: 3px; }
.rep-meta span { color: var(--text-faint); margin-right: 6px; }

.rep-verdict {
  margin: 14px 0; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-left-width: 4px;
}
.rep-verdict.bad  { border-left-color: var(--bad);  background: var(--bad-soft); }
.rep-verdict.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.rep-verdict.ok   { border-left-color: var(--ok);   background: var(--ok-soft); }

.rep-tally { display: flex; gap: 30px; margin: 16px 0 20px; }
.rep-tally b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.rep-tally span { font-size: 11px; color: var(--text-faint); }
.rep-tally .ok  b { color: var(--ok); }
.rep-tally .out b { color: var(--out); }
.rep-tally .bad b { color: var(--bad); }

.rep-h {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  margin: 22px 0 8px; padding-bottom: 5px; border-bottom: var(--rule);
}
.rep-note { font-size: 12.5px; color: var(--text-dim); margin-bottom: 10px; }
.rep-list { margin: 0 0 10px; padding-left: 20px; font-size: 13.5px; }
.rep-list li { margin: 4px 0; }
.rep-table { width: 100%; }

.rep-sign { display: flex; gap: 40px; margin-top: 34px; }
.rep-sign div { flex: 1; }
.rep-sign span { font-size: 11px; color: var(--text-faint); display: block; }
.rep-sign i { display: block; border-bottom: 1px solid var(--border-strong); height: 26px; }

@media print {
  .topbar, .count-toolbar, .head-actions, .toast-stack, .modal-root { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  main { max-width: none; padding: 0; }
  .alarm, .mk-row, .rep-verdict { break-inside: avoid; }

  /* Printing the report means printing the report — not the screen it was
     launched from. Everything else in the view steps out of the way. */
  body.printing-report #view > *:not(.print-sheet) { display: none !important; }
  body.printing-report .print-sheet { display: block; }
  .print-sheet .mk-row { border-left-width: 3px; }
  .print-sheet .mk-act { display: none; }
}
