/* The tool's screens: everything theme.css lacks. Same rules as the theme (DESIGN.md section 7):
   a 4px grid and the seven steps, hairline rules, nearly square corners, no shadow, nothing moves,
   a state is always a mark and a word, and customer text is never re-cased, cut or squeezed. */

/* ---- the ticket header: title, code, state, then Check a printed code -------------------------- */
.ticket { flex-wrap: wrap; row-gap: var(--s-2); }
.ticket .title { flex: 0 1 auto; }
.ticket .code { font-size: var(--t-18); line-height: var(--l-18); }
#check-code { display: flex; align-items: center; gap: var(--s-2); }
#check-code input { width: 132px; text-align: center; letter-spacing: 0.02em; }
.check-band { flex: 0 0 100%; }
.check { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--rule); border-left: 4px solid var(--idle); background: var(--sheet); }
.check p { flex: 1; min-width: 0; }
.check .code { font-size: inherit; line-height: inherit; }
td.sum { font: 400 var(--t-12)/var(--l-12) var(--mono); color: var(--ink-3); white-space: nowrap; }
.check > div { flex: 1; min-width: 0; }
.check ul { margin: var(--s-1) 0 0 var(--s-4); }
.check.ready { border-left-color: var(--ready); background: var(--ready-wash); }
.check.stop { border-left-color: var(--stop); background: var(--stop-wash); }

/* ---- shell: a rail of sections and the open sheet --------------------------------------------- */
#view { display: grid; gap: var(--s-6); min-width: 0; align-content: start; }
.foot { padding-top: 0; color: var(--ink-2); }
.rail { display: grid; gap: var(--s-4); position: sticky; top: calc(var(--bar) + var(--s-6)); }
.rail-list, .rail-order { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
.rail-item { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4); border: 0; border-bottom: 1px solid var(--rule-2); border-radius: 0; background: none; font-weight: 400; text-align: left; }
.rail-item:last-child { border-bottom: 0; }
.rail-item .num { color: var(--ink-3); font-size: var(--t-13); }
.rail-item[aria-current="page"] { font-weight: 600; box-shadow: inset 4px 0 0 var(--accent); background: var(--accent-wash); }
.rail-item.has-open .num { color: var(--attention); font-weight: 600; }
.rail-order { padding: var(--s-3) var(--s-4) var(--s-4); display: grid; gap: var(--s-2); }
.rail-act { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3); border: 1px solid var(--ink-3); border-radius: var(--radius); background: var(--sheet); color: var(--ink); font: 600 var(--t-13)/var(--l-13) var(--sans); text-align: left; cursor: pointer; }

/* ---- common pieces ---------------------------------------------------------------------------- */
.sheet > .body { display: grid; gap: var(--s-4); min-width: 0; }
.sheet > header { justify-content: space-between; }
.lead { font: 600 var(--t-18)/var(--l-18) var(--sans); overflow-wrap: anywhere; }
.acts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
table.rows td.do { text-align: right; white-space: nowrap; overflow-wrap: normal; width: 1%; }
td.do button { min-height: 24px; padding-block: 0; vertical-align: top; white-space: nowrap; }
.head-right { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-2) var(--s-3); }
.caption, td.num .caption { font-family: var(--sans); white-space: normal; }
.caption .as-written { white-space: pre; overflow-wrap: normal; }   /* "the file says 7.0": the value itself is never broken across lines */
.was { font-weight: 400; }
.lead .code { font-size: inherit; line-height: inherit; }
.acts label, .as-fields label, .typed label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); max-width: 100%; }
input[type="text"], select, textarea { max-width: 100%; min-width: 0; }
.sheet > .body > *, .step > *, .acts > *, .cards > * { min-width: 0; }   /* a wide control narrows with the sheet; it never widens the page */
button.quiet { border-color: transparent; color: var(--accent); font-weight: 600; padding-inline: var(--s-2); text-decoration: underline; text-underline-offset: 2px; background: none; }
button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.label { font: 600 var(--t-13)/var(--l-13) var(--sans); color: var(--ink-2); }
.need { color: var(--attention); }
.empty { color: var(--ink-3); font-size: var(--t-13); }
.sp { display: inline-block; min-width: 0.6em; margin: 0 1px; padding: 0 2px; border-radius: var(--radius); background: var(--attention-wash); color: var(--attention); font: 600 0.8em/1.3 var(--sans); text-align: center; vertical-align: 0.05em; }
.file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file:focus-visible + .button, label:has(+ .file:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { width: 100%; font: 400 var(--t-13)/var(--l-13) var(--mono); }
.group-title { display: flex; align-items: baseline; gap: var(--s-2); margin-top: var(--s-4); font: 600 var(--t-13)/var(--l-13) var(--sans); letter-spacing: 0.04em; color: var(--ink-2); }
.group-title .num { color: var(--ink-3); }
.group-title + * { margin-top: calc(-1 * var(--s-2)); }   /* a title sits with what it titles */
.cards { display: grid; gap: var(--s-3); }
ul.notes, ul.changes, ul.kept, ul.contains { list-style: none; display: grid; gap: 0; }
ul.notes li, ul.changes li, ul.kept li, ul.contains li { padding: var(--s-2) 0; border-bottom: 1px solid var(--rule-2); overflow-wrap: anywhere; }
u { text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--changed); }

.notebox { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--rule); border-left: 4px solid var(--idle); border-radius: var(--radius); background: var(--sheet); }
.notebox > div { display: grid; gap: var(--s-2); min-width: 0; flex: 1; }
.notebox.ok { border-left-color: var(--ready); }
.notebox.refused { border-left-color: var(--stop); background: var(--stop-wash); }
.notebox.changed-note { border-left-color: var(--changed); background: var(--changed-wash); }

/* ---- the open area on the empty desk ---------------------------------------------------------- */
.drop { display: grid; gap: var(--s-1); justify-items: center; padding: var(--s-12) var(--s-6); border: 1px dashed var(--ink-3); border-radius: var(--radius); background: var(--desk); color: var(--ink); cursor: pointer; text-align: center; }
.drop strong { font: 600 var(--t-18)/var(--l-18) var(--sans); }
.drop span { font: 400 var(--t-15)/var(--l-15) var(--sans); color: var(--ink-2); }

/* ---- import and mapping ----------------------------------------------------------------------- */
.step { display: grid; gap: var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--rule); min-width: 0; }
.step:first-child { padding-top: 0; border-top: 0; }
.step > h4, .card h4, .as h4, .edit h4, .another-way h4 { font: 600 var(--t-15)/var(--l-15) var(--sans); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.step > h4 > .num { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--ink); border-radius: var(--radius); font-size: var(--t-13); font-weight: 600; }
.choices { display: grid; gap: var(--s-2); }
.choice { display: inline-flex; align-items: center; gap: var(--s-2); font: 400 var(--t-15)/var(--l-15) var(--sans); color: var(--ink); }
.grid-scroll { overflow-x: auto; border: 1px solid var(--rule); }
table.grid { width: max-content; min-width: 100%; font-size: var(--t-13); line-height: var(--l-13); }
table.grid th, table.grid td { padding: var(--s-1) var(--s-2); border: 1px solid var(--rule-2); white-space: nowrap; }
table.grid td .as-written { display: inline-block; width: max-content; max-width: 44ch; overflow-wrap: normal; vertical-align: top; }   /* a long cell wraps at its spaces; a short one is never broken */
table.grid th { background: var(--desk); border-bottom: 1px solid var(--ink); }
table.grid tbody tr { cursor: pointer; }
table.grid .mapped { background: var(--accent-wash); }
table.grid tr.is-suggested td { border-top: 1px dashed var(--accent); border-bottom: 1px dashed var(--accent); }
table.grid tr.is-header td { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-color: var(--accent); }
table.grid tr.is-header .caption, table.grid tr.is-header .sp { color: var(--accent-ink); background: none; }
.map { display: grid; gap: var(--s-3); }
.map-row { display: grid; grid-template-columns: 120px minmax(0, 320px) minmax(0, 1fr); gap: var(--s-2) var(--s-4); align-items: center; }
.map-row select, .map-row input[type="text"] { width: 100%; }
.layouts { display: flex; flex-wrap: wrap; gap: var(--s-3); grid-column: 2 / 4; }
.map-row > .layouts + p { grid-column: 2 / 4; }
.layout-card { display: grid; justify-items: center; gap: var(--s-2); width: 208px; padding: var(--s-3); border: 1px solid var(--ink-3); border-radius: var(--radius); background: var(--sheet); font: 600 var(--t-13)/var(--l-13) var(--sans); color: var(--ink); text-align: center; cursor: pointer; }
.layout-card input { position: absolute; opacity: 0; }
.layout-card:has(input:checked) { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-wash); }
.layout-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumb text { font-family: var(--display); font-weight: 700; fill: currentColor; }
.confirm { display: grid; gap: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--ink); }
.demo-note { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

/* ---- whose answer, and the cards -------------------------------------------------------------- */
.as { display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-4); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--desk); }
.as.need-box { border-color: var(--attention); }
.as-fields { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-6); }
.card { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--rule); border-left: 4px solid var(--attention); border-radius: var(--radius); background: var(--sheet); min-width: 0; }
.cells td.asked { background: var(--attention-wash); font-weight: 600; }
.answers { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.typed { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding-left: var(--s-3); border-left: 1px solid var(--rule); }

/* ---- tables of the order ---------------------------------------------------------------------- */
table.rows td { overflow-wrap: anywhere; }
table.rows td.num { white-space: nowrap; }
table.cells { table-layout: fixed; }   /* the same five columns in every card, so the cards read as one list */
table.cells th:nth-child(1) { width: 136px; } table.cells th:nth-child(3) { width: 120px; } table.cells th:nth-child(4) { width: 136px; } table.cells th:nth-child(5) { width: 136px; }
/* An order that keeps production details (R4.7): the same columns again in every card. The four fields give up width
   they did not use, so a name still has room and each detail has a column of its own. */
table.cells.has-details th:nth-child(1) { width: 128px; } table.cells.has-details th:nth-child(3) { width: 80px; } table.cells.has-details th:nth-child(4) { width: 96px; } table.cells.has-details th:nth-child(5) { width: 56px; }
table.cells.has-details th.detail { width: 112px; }
table.cells td.from { color: var(--ink-2); }
#findings { display: grid; gap: var(--s-3); }
.roster td.name { font-weight: 600; }
tr.edit-row > td { padding: 0; }
.edit { display: grid; gap: var(--s-3); padding: var(--s-4); border-left: 4px solid var(--accent); background: var(--desk); }
.details { display: grid; gap: var(--s-2); padding-bottom: var(--s-4); border-bottom: 1px solid var(--rule); }
.details > div { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
table.sizes { width: auto; min-width: 280px; justify-self: start; }
table.sizes tr.total td { font-weight: 600; border-top: 1px solid var(--ink); border-bottom: 0; }
table.rows td.when { white-space: nowrap; color: var(--ink-2); }
.another-way { display: grid; gap: var(--s-3); margin-top: var(--s-2); padding-top: var(--s-4); border-top: 1px dashed var(--ink-3); }

/* ---- proofs ----------------------------------------------------------------------------------- */
.proof-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
@media (min-width: 1200px) { .proof-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.proof { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); min-width: 0; }
.proof.is-changed { box-shadow: inset 4px 0 0 var(--changed); }
.proof > svg { display: block; width: 100%; height: auto; border-bottom: 1px solid var(--rule-2); }
.proof figcaption { display: grid; gap: var(--s-2); padding: var(--s-3); }
.proof dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px var(--s-3); }
.proof dt { font: 600 var(--t-12)/var(--l-15) var(--sans); letter-spacing: 0.04em; color: var(--ink-3); }
.proof dd { overflow-wrap: anywhere; }
.plain-proof, .no-proof { display: grid; align-content: center; justify-items: center; gap: var(--s-2); aspect-ratio: 264 / 240; padding: var(--s-4); border-bottom: 1px solid var(--rule-2); text-align: center; }
.plain-proof > .caption { justify-self: start; align-self: start; }
.pp-name { font: 700 26px/1.2 var(--display); overflow-wrap: anywhere; }
.pp-number { font: 700 80px/1 var(--display); }

/* ---- narrow screens: the rail folds above the content and tables become two-line rows ---------- */
@media (max-width: 760px) {
  .head-right { justify-content: flex-start; }
  .state { white-space: normal; text-align: left; max-width: 100%; }   /* a long state wraps under its mark; it is never cut */
  .ticket .title { flex-basis: 100%; }
  #check-code { flex: 1 1 100%; flex-wrap: wrap; }
  #check-code input { flex: 1; min-width: 0; }
  .check { flex-direction: column; align-items: flex-start; gap: var(--s-2); }
  .check p, .check > div { flex: none; }
  /* the sections first, then the open sheet, then the order's own actions: the three facts stay near the top */
  #shell { display: flex; flex-direction: column; align-items: stretch; }
  #rail:not([hidden]), .rail { display: contents; }
  .rail-list { order: 1; }
  #view { order: 2; }
  .rail-order { order: 3; }
  .rail-list { display: grid; grid-template-columns: 1fr 1fr; }
  .rail-item { border-right: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); padding-left: var(--s-3); }
  .rail-item:last-child { border-bottom: 1px solid var(--rule-2); }
  .map-row { grid-template-columns: minmax(0, 1fr); gap: var(--s-1); }
  .layouts, .map-row > .layouts + p { grid-column: auto; }
  .layout-card { width: calc(50% - var(--s-2)); }
  .proof-grid { grid-template-columns: minmax(0, 1fr); }
  .notebox { flex-direction: column; align-items: stretch; gap: var(--s-2); }
  .notebox > button { align-self: flex-start; }
  .typed { padding-left: 0; border-left: 0; }
  .drop { padding: var(--s-8) var(--s-4); }
  table.rows thead { display: none; }
  table.rows, table.rows tbody { display: block; }
  table.rows tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-1) var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--rule); }
  table.rows td { display: block; padding: 0; border: 0; text-align: left; }
  table.rows td[data-label]::before { content: attr(data-label); display: block; font: 600 var(--t-12)/var(--l-12) var(--sans); letter-spacing: 0.04em; color: var(--ink-3); }
  table.rows td.name, table.rows td.do, table.rows tr.edit-row > td, table.rows td:only-child { grid-column: 1 / -1; }
  table.rows td.do { width: auto; text-align: left; white-space: normal; }
  table.rows td:empty { display: none; }
  table.roster td[data-label="LINE"] { order: -2; }
  table.roster td.mark { order: -1; justify-self: end; }
  table.roster td.mark::before { content: none; }
  table.rows tr.changed-row { padding-left: var(--s-3); }
  table.rows tr.edit-row { display: block; padding: 0; }
  table.sizes tr { grid-template-columns: 1fr auto; }
  table.sizes tr.total { border-top: 1px solid var(--ink); border-bottom: 0; }
  table.sizes tr.total td { border-top: 0; }
}
