/* 75_sheet.css - KP Equipment Spreadsheet view (slices C1a + C1b-2a). Tokens from 01_tokens.css only; the badge, select,
 * tool-btn, field and counts classes are the app's own (30_plan.css). Two layouts from one table:
 *   table  = wider than a phone: sticky header row, sticky id + name columns, the table scrolls inside the view.
 *            Three widths: full (1400 and up, every column), medium (1100 to 1399, no Site / Retired date) and
 *            compact (tablet, up to 1099: id, name, area, status and the five cleaning numbers, no sideways scroll)
 *   cards  = phone / short landscape (the same breakpoint the record's bottom sheet uses): one card per machine
 * Both media arms carry `screen`, so neither lands on paper.
 * C1b-2a: the sheet bar (Edit numbers, undo / redo, hint, legend) and the edit state (.sheet.is-edit): each cleaning
 * number is a button (.sheet-num) that becomes a field (.sheet-input); .is-changed = differs from the imported value. */

/* ---- the third segment of the header view switch ---- */
.view-btn[hidden] { display: none; }
.view-ic { display: none; width: 20px; height: 20px; margin: 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the sheet takes the stage's place; the stage keeps its box (nothing shows, nothing takes a tap) ---- */
body.is-sheet .stage { position: absolute; inset: 0; visibility: hidden; }
/* A6f: Colour and Key belong to the drawn plan, so they step aside in the sheet as Show retired and zoom do */
body.is-sheet .toolbar .check, body.is-sheet .toolbar .zoom, body.is-sheet .toolbar .marks, body.is-sheet #counts { display: none; }
body.is-sheet .search-results, body.is-sheet .legend-panel { display: none; }
.sheet-counts[hidden] { display: none; }

.sheet { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.sheet[hidden] { display: none; }
.sheet-note { display: none; margin: 0; }
.sheet-scroll { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; outline: none; }
.sheet-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }

/* ---- the sheet bar: Edit numbers at rest; in the edit state also undo / redo, the hint and the legend ---- */
.sheet-bar { flex: 0 0 auto; display: flex; align-items: center; gap: var(--sp-2) var(--sp-3); min-height: 52px; box-sizing: border-box; padding: 4px var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-sortfield, .sheet-bar .sheet-dir { display: none; } /* the table sorts by its headers; the cards arm shows these */
/* FX-1 (A-04): a viewer has no Edit numbers, and the table sorts by its headers, so the bar has nothing to show: it gives its row to the table */
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) {
  .sheet-bar:not(:has(> .sheet-edit-btn:not([hidden]), > .sheet-steps:not([hidden]), > .sheet-hint:not([hidden]), > .sheet-legend:not([hidden]))) { display: none; }
}
.sheet-ic { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sheet-edit-btn { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); white-space: nowrap; }
.sheet-edit-btn .sheet-ic-done { display: none; }
.sheet.is-edit .sheet-edit-btn { background: var(--brand-solid); border-color: var(--brand-solid); color: var(--acc-ink); }
.sheet.is-edit .sheet-edit-btn:hover { background: var(--brand-solid-hover); border-color: var(--brand-solid-hover); }
.sheet.is-edit .sheet-edit-btn .sheet-ic-edit { display: none; }
.sheet.is-edit .sheet-edit-btn .sheet-ic-done { display: block; }
.sheet-steps { flex: 0 0 auto; display: inline-flex; gap: var(--sp-1); }
.sheet-steps[hidden], .sheet-hint[hidden], .sheet-legend[hidden], .sheet-hint-keys[hidden] { display: none; }
.sheet-step { display: inline-flex; align-items: center; justify-content: center; width: 44px; padding: 0; }
.sheet-hint { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 13px; line-height: 1.35; color: var(--ink-soft); }
.sheet-hint.is-status { color: var(--ink); font-weight: 500; }
/* rc3-A2: a refused Undo / Redo reads as off but can be tapped; its reason is a notice on its own row under the bar, with Close */
.sheet-step[aria-disabled="true"] { position: relative; border-style: dashed; border-color: var(--ink-muted); background: var(--surface-alt); color: var(--ink-soft); cursor: pointer; } /* FX-1: the same look as the plan editor - not dead, a dashed edge and a dot in the colour of its notice */
.sheet-step[aria-disabled="true"]::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.sheet-bar.has-why { flex-wrap: wrap; }
.sheet-bar.has-why::after { content: ""; order: 9; flex: 0 0 100%; height: 0; } /* FX-1: ends the row of buttons, so the notice under it can be only as wide as its words */
.sheet-hint.is-why:not([hidden]) { order: 10; flex: 0 1 auto; max-width: 100%; display: flex; align-items: center; gap: var(--sp-3); box-sizing: border-box; margin: calc(-1 * var(--sp-2)) 0 2px; padding: 4px 4px 4px 11px; border: 1px solid var(--line); border-left: 3px solid var(--info); border-radius: var(--r); background: var(--surface); font-size: 14px; } /* FX-1: as wide as its words (it used to span the bar, half empty), and the neutral accent: a refusal is information. The negative top margin takes back the row gap the empty break row adds */
.sheet-hint.is-why > span:first-child { flex: 0 1 auto; min-width: 0; max-width: 78ch; overflow-wrap: anywhere; }
.sheet-hint-x { flex: 0 0 auto; }
.sheet-hint-x[hidden] { display: none; }
/* ---- F9c: the mark on a changed number, and the legend that names it. Two states that read without colour:
 *   saved for everyone (.is-committed; a bare dot reads the same) = a small filled dot
 *   not saved yet (.is-pending)                                  = a larger open ring
 * The cell (td.is-changed.is-committed / td.is-changed.is-pending) takes no tint of its own: the number stays as easy
 * to read as any other and the open field is untouched. Both marks take the same 13 px beside the number, so a cell
 * keeps its width when its state flips. The filled dot is drawn with its border as well as its fill, so it stays
 * filled where the system forces its own colours. td.is-saved is the short green flash after a change (further down). */
.sheet-dot, .sheet-dot.is-committed { display: inline-block; flex: 0 0 auto; box-sizing: border-box; width: 7px; height: 7px; margin: 1px 5px 1px 1px; border: 3px solid var(--success-fg); border-radius: 50%; background: var(--success-fg); vertical-align: middle; }
.sheet-dot.is-pending { width: 9px; height: 9px; margin: 0 4px 0 0; border: 2px solid var(--info); background: transparent; }
/* the legend: one item per state (.sheet-legend-item.is-committed / .is-pending), a dot and its words. It sits at the
   end of the bar while there is room, drops to a row of its own when there is not, and on a phone its two items go
   one under the other */
.sheet-legend { flex: 0 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 2px var(--sp-4); margin: 0 0 0 auto; font-size: 13px; line-height: 1.35; color: var(--ink-soft); }
.sheet-legend-item { display: inline-flex; align-items: flex-start; min-width: 0; }
.sheet-legend-item[hidden] { display: none; }
.sheet-legend-item .sheet-dot { margin: calc((1.35em - 7px) / 2) 7px 0 1px; }
.sheet-legend-item .sheet-dot.is-pending { margin: calc((1.35em - 9px) / 2) 6px 0 0; }

.sheet-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; color: var(--ink); }
.sheet-table[hidden] { display: none; }
.sheet-row { cursor: pointer; }
.sheet.is-edit .sheet-row { cursor: default; }
.sheet-id { font-family: var(--mono); font-weight: 600; font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
.sheet-open { display: block; max-width: 100%; margin: 0; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.sheet-open:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--brand); }
.sheet-val.is-blank { color: var(--ink-muted); }
.sheet-cell.is-num { font-variant-numeric: tabular-nums; }
.sheet-cell.c-added, .sheet-cell.c-retired { font-variant-numeric: tabular-nums; }
.sheet-row.is-retired .sheet-open, .sheet-row.is-retired .sheet-id, .sheet-row.is-retired .sheet-val { color: var(--ink-muted); }
.sheet-row.is-retired .sheet-open { font-weight: 500; }

/* ---- a cleaning number in the edit state: a button, then a field ---- */
.sheet-num { display: inline-flex; align-items: center; justify-content: flex-end; box-sizing: border-box; width: 100%; min-height: 44px; margin: 0; padding: 0 7px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: text; }
.sheet-num:hover { border-color: var(--brand); }
.sheet-num:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.sheet-input { display: block; box-sizing: border-box; width: 100%; min-height: 44px; margin: 0; padding: 0 7px; border: 1px solid var(--brand); border-radius: var(--r-sm); outline: none; box-shadow: 0 0 0 2px var(--brand); background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; }
.sheet-cell.is-changed .sheet-val { font-weight: 600; }
.sheet-row.is-retired .sheet-cell.is-changed .sheet-val:not(.is-blank) { color: var(--ink-soft); }
.sheet-cell.is-busy .sheet-input { color: var(--ink-muted); border-color: var(--line); box-shadow: none; background-image: linear-gradient(90deg, transparent, var(--brand-soft), transparent); background-size: 200% 100%; animation: sheet-busy .9s linear infinite; }
@keyframes sheet-busy { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sheet-cell.is-busy .sheet-input { animation: none; } }
.sheet-cell.is-error .sheet-input { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.sheet-cell.is-saved .sheet-num { border-color: var(--success); background-color: var(--surface); background-image: linear-gradient(var(--success-bg), var(--success-bg)); }
/* the reason a value was refused, beside its field */
.sheet-msg { box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--danger); border-radius: var(--r); background-color: var(--surface); background-image: linear-gradient(var(--danger-bg), var(--danger-bg)); box-shadow: var(--shadow); color: var(--ink); font-size: 13px; font-weight: 400; line-height: 1.4; font-variant-numeric: normal; text-align: left; white-space: normal; cursor: default; }
.sheet-msg-title { display: block; margin-bottom: 2px; color: var(--danger-fg); font-weight: 700; }
.sheet-msg-text { display: block; }
.sheet-msg-keep { display: block; min-height: 44px; margin-top: var(--sp-2); font-size: 14px; }

.sheet-empty { max-width: 460px; margin: var(--sp-6) auto; padding: var(--sp-5); text-align: center; }
.sheet-empty[hidden] { display: none; }
.sheet-empty h2 { margin: 0 0 var(--sp-1); font-size: 18px; }
.sheet-empty p { margin: 0 0 var(--sp-4); color: var(--ink-soft); font-size: 15px; }
.sheet-empty .tool-btn[hidden] { display: none; }

/* ================================ table: tablet and PC ================================ */
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) {
  .sheet-table { table-layout: fixed; min-width: 1400px; }
  .sheet-scroll { padding-bottom: 12px; } /* P2-13: the last row scrolls clear of the page footer, with a little air */
  /* F9c: the legend names two states now, so it is longer. The hint keeps its place beside the buttons (it asks for
     12em and takes what is left); the legend stays at the end of that row while it fits and drops to a row of its
     own, still at the right, when it does not (an upright tablet in the edit state) */
  .sheet-bar { flex-wrap: wrap; }
  .sheet-hint { flex: 1 1 12em; }

  .sheet-h { position: sticky; top: 0; z-index: 2; height: 48px; padding: 0; background: var(--surface-alt); border-bottom: 1px solid var(--line); text-align: left; font-weight: 600; }
  .sheet-th { display: flex; align-items: center; gap: 6px; width: 100%; height: 48px; margin: 0; padding: 0 10px; border: 0; background: transparent; color: var(--ink-soft); font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; text-align: left; white-space: nowrap; cursor: pointer; }
  .sheet-th:hover { color: var(--ink); background: var(--line-soft); }
  .sheet-th:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--brand); }
  .sheet-th-words { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
  .sheet-th-sub { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-muted); }
  .sheet-h.is-num .sheet-th { flex-direction: row-reverse; text-align: right; }
  .sheet-h.is-num .sheet-th-words { align-items: flex-end; }
  /* sort mark: a small triangle; faint on hover, solid on the sorted column */
  .sheet-arrow { flex: 0 0 auto; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 6px solid currentColor; opacity: 0; }
  .sheet-th:hover .sheet-arrow, .sheet-th:focus-visible .sheet-arrow { opacity: .35; }
  .sheet-h[aria-sort="ascending"] .sheet-th, .sheet-h[aria-sort="descending"] .sheet-th { color: var(--brand); }
  .sheet-h[aria-sort="ascending"] .sheet-arrow, .sheet-h[aria-sort="descending"] .sheet-arrow { opacity: 1; }
  .sheet-h[aria-sort="descending"] .sheet-arrow { border-bottom: 0; border-top: 6px solid currentColor; }
  .sheet-h[aria-sort="ascending"], .sheet-h[aria-sort="descending"] { box-shadow: inset 0 -2px 0 0 var(--brand); }

  .sheet-cell { height: 48px; padding: 0 10px; border-bottom: 1px solid var(--line-soft); background: var(--surface); vertical-align: middle; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-cell.is-num { text-align: right; }
  .sheet-cell.c-added, .sheet-cell.c-retired { padding-right: 2px; }
  .sheet-cell .sheet-val { color: var(--ink-soft); }
  .sheet-cell .sheet-val.is-blank { color: var(--ink-muted); }
  .sheet-cell.is-num .sheet-val:not(.is-blank) { color: var(--ink); }
  .sheet-open { min-height: 44px; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* fixed columns; the name takes whatever is left */
  .sheet-h.c-id { width: 108px; }
  .sheet-h.c-site { width: 100px; }
  .sheet-h.c-area { width: 164px; }
  .sheet-h.c-sort { width: 68px; }
  .sheet-h.c-status { width: 88px; }
  .sheet-h.c-added, .sheet-h.c-retired { width: 100px; }
  .sheet-h.c-cw { width: 84px; }
  .sheet-h.c-dcw { width: 90px; }
  .sheet-h.c-ct { width: 84px; }
  .sheet-h.c-dct { width: 90px; }
  .sheet-h.c-freq { width: 108px; }

  /* sticky id + name */
  .sheet-h.c-id, .sheet-cell.c-id { position: sticky; left: 0; }
  .sheet-h.c-name, .sheet-cell.c-name { position: sticky; left: 108px; border-right: 1px solid var(--line); }
  .sheet-cell.c-id, .sheet-cell.c-name { z-index: 1; }
  .sheet-h.c-id, .sheet-h.c-name { z-index: 3; }
  .sheet-h.c-id .sheet-th, .sheet-cell.c-id { padding-left: var(--sp-4); }

  /* A6f: every tint is painted over an opaque base, so the sticky header and the sticky id and name cells never show the
     columns sliding under them (the dark theme tints are see-through) */
  .sheet-h { background-color: var(--surface); background-image: linear-gradient(var(--surface-alt), var(--surface-alt)); }
  .sheet-row:hover .sheet-cell { background-color: var(--surface); background-image: linear-gradient(var(--surface-alt), var(--surface-alt)); }
  .sheet-row.is-retired .sheet-cell { background-color: var(--surface); background-image: linear-gradient(var(--surface-alt), var(--surface-alt)); }
  .sheet-row.is-retired:hover .sheet-cell { background-color: var(--surface); background-image: linear-gradient(var(--line-soft), var(--line-soft)); }
  .sheet-row.is-selected .sheet-cell, .sheet-row.is-selected:hover .sheet-cell { background-color: var(--surface); background-image: linear-gradient(var(--brand-soft), var(--brand-soft)); }
  .sheet-row.is-selected .sheet-cell.c-id { box-shadow: inset 3px 0 0 0 var(--brand); }

  /* C1b-2a: the edit state. The number fills its cell; an open field may show its note below the row. */
  .sheet.is-edit .sheet-cell[data-edit] { padding: 0 3px; }
  .sheet.is-edit .sheet-cell[data-edit] > .sheet-val { padding: 0 8px; }
  .sheet-num, .sheet-input { height: 44px; min-height: 0; }
  .sheet-cell.is-editing { position: relative; overflow: visible; }
  div.sheet-msg { position: absolute; top: calc(100% + 4px); right: 3px; z-index: 4; width: 300px; max-width: 72vw; }
  .sheet-table .sheet-row .sheet-cell.is-saved { background-color: var(--surface); background-image: linear-gradient(var(--success-bg), var(--success-bg)); }

  /* A6f: while the record's Hide / Show tab is on screen it gets a rail of its own beside the table, so it never sits on
     the cells. Only the sheet's scroll area gives way; the plan view is untouched. */
  body.is-sheet:has(#drawer-tab:not([hidden])) .sheet-scroll { margin-right: 46px; border-right: 1px solid var(--line); }
  @supports not selector(:has(*)) {
    body.is-sheet.drawer-open .sheet-scroll, body.is-sheet.drawer-tucked .sheet-scroll { margin-right: 46px; border-right: 1px solid var(--line); }
  }
}
/* ---- table, tighter headers below the full width (medium and compact) ---- */
@media screen and (min-width: 701px) and (max-width: 1399px) and (min-height: 501px), screen and (min-width: 961px) and (max-width: 1399px) {
  .sheet-th { gap: 4px; padding: 0 6px; font-size: 11px; letter-spacing: .02em; }
  .sheet-h.c-site, .sheet-cell.c-site, .sheet-h.c-retired, .sheet-cell.c-retired { display: none; } /* the site is the header switch; the retired date is in the record */
}
/* ---- medium: a tablet on its side, a small laptop. Everything but Site and the Retired date, no sideways scroll ---- */
@media screen and (min-width: 1100px) and (max-width: 1399px) {
  .sheet-table { min-width: 1040px; }
  .sheet-h.c-area { width: 150px; }
  .sheet-h.c-sort { width: 62px; }
  .sheet-h.c-status { width: 86px; }
  .sheet-h.c-added { width: 98px; }
  .sheet-h.c-cw { width: 78px; }
  .sheet-h.c-dcw { width: 84px; }
  .sheet-h.c-ct { width: 78px; }
  .sheet-h.c-dct { width: 84px; }
  .sheet-h.c-freq { width: 104px; }
}
/* ---- compact: a tablet upright (or a small one on its side). Id, name, area, status and the five cleaning numbers ---- */
@media screen and (min-width: 701px) and (max-width: 1099px) and (min-height: 501px), screen and (min-width: 961px) and (max-width: 1099px) {
  .sheet-table { min-width: 700px; }
  .sheet-h.c-sort, .sheet-cell.c-sort, .sheet-h.c-added, .sheet-cell.c-added { display: none; }
  .sheet-cell { padding: 0 6px; }
  .sheet-h.c-id { width: 96px; }
  .sheet-h.c-id .sheet-th, .sheet-cell.c-id { padding-left: var(--sp-3); }
  .sheet-id { font-size: 13px; }
  .sheet-h.c-name, .sheet-cell.c-name { left: 96px; }
  .sheet-h.c-area { width: 128px; }
  .sheet-h.c-status { width: 80px; }
  .sheet-h.c-cw { width: 70px; }
  .sheet-h.c-dcw { width: 78px; }
  .sheet-h.c-ct { width: 70px; }
  .sheet-h.c-dct { width: 78px; }
  .sheet-h.c-freq { width: 96px; }
  .sheet-bar { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .sheet-hint-keys { display: none; } /* a tablet bar has room for the main hint only */
}
/* ---- upright tablet: the Status column gives its room to the name; a retired machine says so beside its name ---- */
@media screen and (min-width: 701px) and (max-width: 899px) and (min-height: 501px) {
  .sheet-h.c-status, .sheet-cell.c-status { display: none; }
  .sheet-row.is-retired .sheet-cell.c-name .sheet-open { display: inline-block; width: calc(100% - 68px); vertical-align: middle; }
  .sheet-row.is-retired .sheet-cell.c-name::after { content: "Retired"; display: inline-block; box-sizing: border-box; width: 62px; margin-left: 6px; padding: 2px 0; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-soft); font-size: 11px; font-weight: 600; line-height: 1.3; text-align: center; vertical-align: middle; }
}
@media screen and (min-width: 1300px) and (pointer: fine) {
  .sheet-cell { height: 44px; }
  .sheet-open { min-height: 40px; }
  .sheet-num, .sheet-input { height: 38px; }
  .sheet-input { font-size: 14px; }
  .sheet-h.c-id .sheet-th, .sheet-cell.c-id { padding-left: var(--sp-5); }
  .sheet-h.c-id { width: 116px; }
  .sheet-h.c-name, .sheet-cell.c-name { left: 116px; }
  .sheet-bar { padding-left: var(--sp-5); padding-right: var(--sp-5); }
}

/* ================================ cards: phone and short landscape ================================ */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  /* three views in the 52 px bar: narrower segments, the sheet shows its mark instead of its word */
  .kp-bar .view-btn { min-width: 0; width: clamp(30px, calc((100vw - 306px) / 3), 44px); padding: 0; }
  .kp-bar .view-btn .view-ic { display: block; }
  .kp-bar .view-btn .view-text { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* C1b-2a: the toolbar is a sideways strip here and cut the count line short; the cards carry the same words on top
     (.sheet-note), so the toolbar copy stays for screen readers only */
  body.is-sheet .toolbar .sheet-counts { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  .sheet { background: var(--bg); }
  .sheet-bar { flex-wrap: wrap; gap: var(--sp-2); min-height: 0; padding: var(--sp-2) var(--sp-3); }
  .sheet-sortfield { display: inline-flex; flex: 1 1 110px; min-width: 110px; }
  .sheet-bar .select { flex: 1 1 auto; min-width: 0; max-width: none; width: 100%; }
  .sheet-bar .sheet-dir { display: inline-block; flex: 0 0 auto; min-height: 44px; white-space: nowrap; }
  .sheet-bar .field-label { white-space: nowrap; }
  .sheet-edit-btn .sheet-ic-edit { display: none; }
  .sheet.is-edit .sheet-sortfield, .sheet.is-edit .sheet-bar .sheet-dir { display: none; } /* editing, not sorting */
  .sheet-hint { order: 10; flex: 1 1 100%; }
  .sheet-hint-keys { display: none; }
  .sheet-legend { order: 11; flex: 1 1 100%; justify-content: flex-start; margin: 0; } /* F9c: a row of its own under the hint, from the left edge like the cards */
  .sheet-scroll { padding: var(--sp-3); }
  .sheet-note { display: block; margin: 0 4px var(--sp-2); font-size: 13px; color: var(--ink-muted); }
  body.is-sheet.drawer-open .sheet-scroll { padding-bottom: 220px; }

  .sheet-table, .sheet-table tbody { display: block; width: 100%; }
  .sheet-table thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sheet-row { display: flex; flex-wrap: wrap; align-items: flex-start; margin: 0 0 var(--sp-2); padding: 12px 10px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
  .sheet-row:last-child { margin-bottom: 0; }
  .sheet-row.is-retired { background: var(--surface-alt); box-shadow: none; }
  .sheet-row.is-selected { background: var(--brand-soft); border-color: var(--brand); }
  .sheet-cell { display: block; box-sizing: border-box; min-width: 0; padding: 0 4px; font-size: 14px; line-height: 1.35; }

  .sheet-cell.c-name { order: 1; flex: 0 0 calc(100% - 84px); }
  .sheet-cell.c-status { order: 2; flex: 0 0 84px; text-align: right; }
  .sheet-cell.c-id { order: 3; flex: 0 0 104px; padding-top: 2px; }
  .sheet-cell.c-area { order: 4; flex: 0 0 calc(100% - 104px); padding-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
  .sheet-cell.c-cw { order: 5; }
  .sheet-cell.c-dcw { order: 6; }
  .sheet-cell.c-ct { order: 7; }
  .sheet-cell.c-dct { order: 8; }
  .sheet-cell.c-freq { order: 9; }
  .sheet-cell.c-cw, .sheet-cell.c-dcw, .sheet-cell.c-ct, .sheet-cell.c-dct, .sheet-cell.c-freq { flex: 0 0 20%; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
  .sheet-cell.c-sort { order: 10; flex: 0 0 18%; }
  .sheet-cell.c-site { order: 11; flex: 0 0 28%; }
  .sheet-cell.c-added { order: 12; flex: 0 0 27%; }
  .sheet-cell.c-retired { order: 13; flex: 0 0 27%; }
  .sheet-cell.c-sort, .sheet-cell.c-site, .sheet-cell.c-added, .sheet-cell.c-retired { margin-top: 8px; }
  .sheet-cell.is-num::before, .sheet-cell.c-site::before, .sheet-cell.c-added::before, .sheet-cell.c-retired::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--ink-muted); white-space: nowrap; }
  .sheet-cell .sheet-val { color: var(--ink); font-weight: 500; }
  .sheet-cell .sheet-val.is-blank { color: var(--ink-muted); font-weight: 400; }
  .sheet-cell.c-area .sheet-val { color: var(--ink-soft); font-weight: 400; }
  .sheet-cell.c-site .sheet-val { white-space: nowrap; }
  .sheet-id { font-size: 13px; }
  .sheet-open { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }

  /* C1b-2a: the edit state on a card: each number is a 44 px box under its label; a refusal is a line inside the card */
  .sheet.is-edit .sheet-cell[data-edit] { padding: 8px 3px 0; }
  .sheet-num { justify-content: flex-start; margin-top: 4px; padding: 0 6px; }
  .sheet-input { margin-top: 4px; padding: 0 6px; text-align: left; }
  .sheet-cell.is-saved .sheet-val { color: var(--success-fg); }
  td.sheet-msg { display: block; order: 9; flex: 0 0 100%; margin-top: 10px; box-shadow: none; }
}
/* ================================ C2b-2b: Redundant (every layout) ================================ */
/* the badge family of 30_plan.css (.badge-active / .badge-retired): a calm amber, never the danger red */
.sheet .badge-redundant { background: var(--warning-bg); color: var(--warning-fg); border: 1px solid var(--warning-bg); }
.sheet-since { display: none; margin-top: 2px; font-size: 11px; line-height: 1.3; color: var(--ink-muted); white-space: nowrap; }
.sheet-row.is-redundant .sheet-cell { background-color: var(--surface-alt); }
@media screen and (min-width: 701px) and (max-width: 899px) and (min-height: 501px) {
  /* upright tablet: no Status column, so a Redundant machine says so beside its name (as a retired one does) */
  .sheet-row.is-redundant .sheet-cell.c-name .sheet-open { display: inline-block; width: calc(100% - 84px); vertical-align: middle; }
  .sheet-row.is-redundant .sheet-cell.c-name::after { content: "Redundant"; display: inline-block; box-sizing: border-box; width: 78px; margin-left: 6px; padding: 2px 0; border: 1px solid var(--warning-bg); border-radius: 999px; background: var(--warning-bg); color: var(--warning-fg); font-size: 11px; font-weight: 600; line-height: 1.3; text-align: center; vertical-align: middle; }
}
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .sheet-row.is-redundant { background: var(--surface-alt); box-shadow: none; }
  .sheet-row.is-redundant .sheet-cell { background-color: transparent; }
  .sheet-cell.c-status .sheet-since { display: block; white-space: normal; } /* the table keeps the date in the badge title (no room in Status) */
}
@media screen and (max-width: 479px) {
  /* a phone has no room for the words "Sort by" beside the list, the order and Edit numbers; the list keeps its name for screen readers */
  .sheet-bar .field-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@media screen and (max-width: 419px) {
  /* a narrow phone has no room for the mark beside three views (it already goes below 390 px) */
  .kp-bar .brand { display: none; }
  .kp-bar .view-btn { width: clamp(30px, calc((100vw - 272px) / 3), 44px); }
}

/* T89a: on a touch screen a card's name is the way into the record. Give it a 44 px tall touch area without making
 * the card taller (the table arm already has min-height 44px and clips this, so nothing changes there). */
html[data-input="touch"] .sheet-open { position: relative; }
html[data-input="touch"] .sheet-open::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }

/* ==== R30c begin: look fixes from the R30a walk. Presentation only.
 * 1. Header labels reach 12 px on tablet and PC (the tracking closes up so the columns keep their widths).
 * 2. A record open beside the sheet (tablet, small laptop): the name column keeps room for a normal name; the number
 *    columns scroll under the two pinned columns, as they already did.
 * 3. Phone cards: the column headers leave the page, so nothing unseen takes a tap or the keyboard focus. Sorting on a
 *    phone is the Sort by list and its direction button in the bar above the cards. */
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) {
  .sheet-th-sub { font-size: 12px; }
}
@media screen and (min-width: 701px) and (max-width: 1399px) and (min-height: 501px), screen and (min-width: 961px) and (max-width: 1399px) {
  .sheet-th { font-size: 12px; letter-spacing: 0; }
}
@media screen and (min-width: 701px) and (max-width: 899px) and (min-height: 501px) {
  body.is-sheet.drawer-open .sheet-table { min-width: 746px; }
}
@media screen and (min-width: 900px) and (max-width: 1099px) and (min-height: 501px) {
  body.is-sheet.drawer-open .sheet-table { min-width: 826px; }
}
@media screen and (min-width: 1100px) and (max-width: 1399px) {
  body.is-sheet.drawer-open .sheet-table { min-width: 1072px; }
}
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .sheet-table thead { display: none; }
}
/* R30c end ==== */

/* ==== R30e begin: generated labels reach 12 px (R30b read, N2). Presentation only, screen only: print is untouched.
 * 1. Upright tablet: the "Retired" and "Redundant" pills beside a name are 12 px; their boxes keep their widths.
 * 2. Phone cards: the field labels (C/week, DC hours ...) are 12 px in the words the columns already use. Capitals
 *    at 12 px do not fit a fifth of a card, so the labels drop the capitals and the tracking, not the size. */
@media screen and (min-width: 701px) and (max-width: 899px) and (min-height: 501px) {
  .sheet-row.is-retired .sheet-cell.c-name::after, .sheet-row.is-redundant .sheet-cell.c-name::after { font-size: 12px; }
}
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .sheet-cell.is-num::before, .sheet-cell.c-site::before, .sheet-cell.c-added::before, .sheet-cell.c-retired::before { font-size: 12px; letter-spacing: 0; text-transform: none; }
}
/* R30e end ==== */

/* ==== F9c-2 begin: two look fixes from the F9c-2 walk. Presentation only. Fix 1 has no media scope (a hidden button
 * stays hidden on paper too, as the script means); fix 2 is screen only.
 * 1. "Edit numbers" is hidden by the script outside Edit (its `hidden` attribute), but the button's own display rule
 *    kept it on screen wherever the bar showed (a phone in View). It now leaves the bar like the other hidden items.
 * 2. Tablet and PC: the hint could be squeezed down to 12em before the legend gave way, so on an upright tablet with
 *    both legend items it became a 157 px column of three or more lines. It now asks for room for two lines of its
 *    own words (24em; 38em from 1100 px, where the keyboard hint is added), so the legend drops to a row of its own,
 *    still at the right, before the hint is squeezed. This replaces the 12em set in the table arm above. The notice
 *    for a refused Undo / Redo (.sheet-hint.is-why) keeps its own size. */
.sheet-edit-btn[hidden] { display: none; }
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) {
  .sheet-hint { flex: 1 1 24em; }
}
@media screen and (min-width: 1100px) {
  .sheet-hint { flex: 1 1 38em; }
}
/* F9c-2 end ==== */

/* ==== F12c begin (Fable, 15/11/2026): the number headers no longer print over each other ====
 * "Cleans / week", "Deep cleans / week", "Clean hours", "Deep clean hours" and "Sort order" are wider than their
 * columns and each was held on one line, so at every table width they ran into the header beside them. A number
 * header may now take a second line (a third where a column is at its narrowest); the 48 px header row holds three.
 * 75_sheet.js sets white-space: nowrap on the label itself (VF-C F21), so the rule needs !important to win; if that
 * line of JS goes, the !important can go with it. The columns that need it take a few px from the name column, so
 * "Order" fits and, where the table is wide enough, the two "Deep" headers read on two lines like their neighbours.
 * Table arm only: the phone cards do not show these headers. */
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) {
  .sheet-h.is-num .sheet-th-main { white-space: normal !important; }
}
@media screen and (min-width: 1100px) and (max-width: 1399px) {
  .sheet-h.c-sort { width: 66px; }
  .sheet-h.c-cw, .sheet-h.c-ct { width: 74px; }
}
@media screen and (min-width: 1200px) and (max-width: 1399px) {
  .sheet-h.c-dcw { width: 104px; }
  .sheet-h.c-dct { width: 96px; }
}
@media screen and (min-width: 1400px) {
  .sheet-h.c-sort { width: 80px; }
  .sheet-h.c-cw { width: 88px; }
}
@media screen and (min-width: 1520px) {
  .sheet-h.c-dcw { width: 120px; }
  .sheet-h.c-dct { width: 112px; }
}
/* F12c end ==== */
/* ==== F12e begin (Fable, 15/11/2026): phone cards - the small labels no longer print over each other ====
 * On a card the five cleaning numbers share one row, about 55 px each at 360 px, and each label was held on one
 * line: "Cleans / week", "Deep cleans / week", "Clean hours", "Deep clean hours" and "Frequency (months)" ran into
 * the label beside them, and the last one pushed the card wider than the screen (the sheet scrolled sideways).
 * A label may now wrap. Every label in a row keeps the same height and sits on its bottom line, so the numbers
 * under them stay level: three lines for the number row and two for the row under it up to 519 px, two and one
 * above that. Frequency gets a little more of the row (its longest word is the widest). Cards only: the table arm
 * (F12c, above) is not touched. */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  .sheet-row .sheet-cell.c-cw, .sheet-row .sheet-cell.c-dcw, .sheet-row .sheet-cell.c-ct, .sheet-row .sheet-cell.c-dct { flex-basis: 19.4%; }
  .sheet-row .sheet-cell.c-freq { flex-basis: 22.3%; }
  .sheet-row .sheet-cell.is-num::before, .sheet-row .sheet-cell.c-site::before, .sheet-row .sheet-cell.c-added::before, .sheet-row .sheet-cell.c-retired::before { display: flex; align-items: flex-end; white-space: normal; line-height: 1.2; }
  .sheet-row .sheet-cell.c-cw::before, .sheet-row .sheet-cell.c-dcw::before, .sheet-row .sheet-cell.c-ct::before, .sheet-row .sheet-cell.c-dct::before, .sheet-row .sheet-cell.c-freq::before { min-height: 2.4em; }
}
@media screen and (max-width: 519px) {
  .sheet-row .sheet-cell.c-cw::before, .sheet-row .sheet-cell.c-dcw::before, .sheet-row .sheet-cell.c-ct::before, .sheet-row .sheet-cell.c-dct::before, .sheet-row .sheet-cell.c-freq::before { min-height: 3.6em; }
  .sheet-row .sheet-cell.c-sort::before, .sheet-row .sheet-cell.c-site::before, .sheet-row .sheet-cell.c-added::before, .sheet-row .sheet-cell.c-retired::before { min-height: 2.4em; }
}
/* F12e end ==== */

/* ==== H-A (Fable, 16/11/2026): on a phone the name that opens a record is a full 44 px press target ====
 * The button measured 21 px high (an unseen 44 px strip over it already caught the finger). Now the button itself is
 * at least 44 px, so what you see is what you press, and the rows space out to match. Phone only. */
html[data-device="phone"] .sheet-open { min-height: 44px; }
/* ==== end H-A ==== */

/* ==== R4a begin (Fable, 17/11/2026): on a phone a short name is a 44 px wide press target too ====
 * H-A made the name button 44 px tall. A short name ("LINE 1", "L 1 RT") still left it narrower than 44 px: 8 of
 * 152 names at 360, the narrowest 37 px. The button is now at least 44 px wide as well. The words stay where they
 * are (left aligned), so only the unseen press area grows. Phone only: the table rows on tablet and PC are untouched. */
html[data-device="phone"] .sheet-open { min-width: 44px; }
/* R4a end ==== */
