/* hdr — the ONE stylesheet for the whole app.
 *
 * CSP is `style-src 'self'`: no inline style="" anywhere, no <style> blocks, no web fonts, no
 * images. Widths that vary with data (bar charts) come from the .w-0 … .w-100 classes below.
 *
 * Built for a call-centre agent on a 1366×768 laptop for eight hours: calm, dense, high contrast,
 * WCAG AA (text ≥ 4.5:1, control borders ≥ 3:1), visible keyboard focus, usable at 360px wide.
 *
 * Class vocabulary shared by every page (expected markup in brackets):
 *   Layout    .page  .page-wide  .card  .narrow  .row  .inline
 *   Type      h1 h2  .eyebrow  .muted  .small  .strong  .mono  .ref
 *   Messages  .notice  .error-box  .field-error
 *   Forms     .field [label.field > span + input|select|textarea]  .field-sm  .field-wide
 *             .btn  .btn-primary  .btn-danger  .linkish [button styled as a link]
 *             .filters [form.filters > label.field… + button.btn]
 *   Data      .table [+ th.num / td.num, tr.superseded]  .facts [dl > dt + dd]
 *             .tag  .tag-muted  .tag-warn  .tag-ok  .tag-danger
 *             .chips / .chip [fieldset.chips > legend + label.chip > input]
 *             .pager [nav.pager > a | span]
 *             .kpis [div.kpis > div.kpi > strong + span]  (ul.kpi > li and dl.kpi > div also work)
 *             .bars [ul.bars > li > span(label) + span.bar.w-35 + span(count)]
 *   Chrome    .topbar  .brand  .nav  .who  .skip
 *   Bands     .band-fabric  .band-services  .band-hazard  .band-consequence  (set --band/--tint/--soft)
 */

/* ---- tokens ---------------------------------------------------------------------------------- */
:root {
  --desk: #E8ECF0;          /* page background */
  --sheet: #FFFFFF;         /* surfaces */
  --ink: #15202B;           /* body text: 16.5:1 on white */
  --ink-2: #3B4957;         /* secondary text: 9.2:1 */
  --muted: #5B6877;         /* quiet text: 5.7:1 on white, 4.8:1 on the desk */
  --rule: #D3DAE2;          /* hairlines between things (decorative) */
  --line-input: #7A8795;    /* control borders: 3.7:1, meets 1.4.11 */
  --hover: #F3F6F9;
  --wash: #EEF2F6;
  --focus: #1B5FD0;

  --go: #0E6A48;  --go-dark: #0B5A3C;  --go-tint: #E3F3EA;
  --danger: #B3261E;  --danger-tint: #FCEBEA;
  --warn: #8A4B00;  --warn-tint: #FFF4DB;  --amber: #B87700;
  --info: #1D4F91;  --info-tint: #EAF1FB;

  /* Issue bands: the 4px bar on each row. Solid when ticked, soft when not. */
  --fabric: #A34A28;       --fabric-tint: #FBEEE8;       --fabric-soft: #D9A792;
  --services: #1F6FB5;     --services-tint: #E8F1FA;     --services-soft: #93BCE3;
  --hazard: #A36A00;       --hazard-tint: #FCF2DE;       --hazard-soft: #DDB765;
  --consequence: #7D3C98;  --consequence-tint: #F3E9F7;  --consequence-soft: #C39AD6;

  /* Tuning knobs for the one-agent trial (build step 15). CSS cannot read var() inside @media, so
     the two media queries marked "= --issue-cols-bp" below repeat 900px literally: change all three
     together. (call.js reads the live grid, not this variable, for the keyboard cursor.) */
  --issue-row-h: 34px;
  --issue-cols-bp: 900px;
  --hint-h: 22px;

  --gutter: 84px;           /* the margin index column on the survey sheet */
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---- base ------------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
img, svg { max-width: 100%; }
p { margin: 0 0 10px; }
code, kbd { font-family: var(--mono); font-size: .92em; }
code { background: var(--wash); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
kbd { border: 1px solid var(--line-input); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--sheet); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.vh {                     /* visually hidden, still read by screen readers */
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--sheet); color: var(--ink);
  padding: 8px 12px; border-radius: var(--radius); font-weight: 600; }
.skip:focus { top: 8px; }

/* ---- app chrome ------------------------------------------------------------------------------ */
.topbar {
  display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap;
  min-height: 44px; padding: 0 16px;
  background: var(--ink); color: #FFFFFF;
}
.brand { color: #FFFFFF; font-weight: 700; text-decoration: none; white-space: nowrap; padding: 10px 0; }
.brand:hover { color: #FFFFFF; }
.topbar :focus-visible { outline-color: #FFFFFF; }
.nav { display: flex; align-items: stretch; gap: 2px; min-width: 0; }
.nav a {
  display: flex; align-items: center; padding: 0 10px; min-height: 44px;
  color: #C9D5E1; text-decoration: none; white-space: nowrap;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.nav a:hover { color: #FFFFFF; }
.nav a.on { color: #FFFFFF; border-bottom-color: #FFFFFF; font-weight: 600; }
.who { margin-left: auto; display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; font-size: 13px; padding: 6px 0; }
.who-name { font-weight: 600; }
.who-role { color: #AFC0D0; }
.who a, .who .linkish { color: #C9D5E1; }
.who a:hover, .who .linkish:hover { color: #FFFFFF; }

/* ---- page containers --------------------------------------------------------------------------- */
main.page { max-width: 1120px; margin: 0 auto; padding: 16px 16px 40px; }
main.page.page-wide { max-width: 1280px; }
.card {
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px;
  padding: 20px 24px; min-width: 0;
}
.card + .card, .card + section, section + .card { margin-top: 16px; }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
body.auth main.page { padding-top: 7vh; }

/* ---- type ------------------------------------------------------------------------------------ */
h1 { font-size: 20px; line-height: 1.25; margin: 0 0 10px; font-weight: 700; }
h2 { font-size: 16px; line-height: 1.3; margin: 22px 0 8px; font-weight: 700; }
h1:first-child, h2:first-child { margin-top: 0; }
h3 { font-size: 14px; margin: 16px 0 6px; }
.eyebrow { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.mono { font-family: var(--mono); font-size: .93em; }
.ref { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }
h1.ref { font-size: 20px; }

/* ---- messages -------------------------------------------------------------------------------- */
.notice, .error-box {
  margin: 0 0 12px; padding: 9px 14px; border-radius: 4px; color: var(--ink);
}
.notice { background: var(--info-tint); box-shadow: inset 4px 0 0 var(--info); }
.error-box { background: var(--danger-tint); box-shadow: inset 4px 0 0 var(--danger); }
.error-box ul, .notice ul { margin: 4px 0 0; padding-left: 20px; }
.error-box p, .notice p { margin: 0; }
.error-box a { color: var(--danger); font-weight: 600; }
.error-box:focus { outline: 2px solid var(--danger); outline-offset: 2px; }
.field-error { color: var(--danger); font-weight: 600; font-size: 13px; margin: 5px 0 0; }
.field-hint { color: var(--warn); font-size: 13px; margin: 5px 0 0; }

/* ---- forms ----------------------------------------------------------------------------------- */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; margin: 0 0 12px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field > span .muted { font-weight: 400; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="password"], input[type="search"], input[type="tel"], input[type="date"],
input[type="number"], input[type="email"], input:not([type]), select, textarea {
  width: 100%; min-height: 34px; padding: 5px 9px;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--line-input); border-radius: 5px;
}
textarea { min-height: 0; line-height: 1.4; resize: vertical; }
select { padding-right: 6px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: inset 0 0 0 1px var(--danger); }
input::placeholder, textarea::placeholder { color: #6B7785; opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin: 6px 0 0; cursor: pointer; }
.check-inline.warn { color: var(--warn); background: var(--warn-tint); padding: 4px 10px; border-radius: 4px; }

.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.row > .field { flex: 1 1 170px; margin: 0; }
.row > .field-sm { flex: 0 1 140px; }
.row > .field-sm:has(> select) { flex-basis: 190px; }
.row > .field-wide { flex: 3 1 300px; }
.row > .field-md { flex: 0 1 300px; }
.q-identity .row > .field-sm { flex: 0 1 170px; }
.inline { display: inline; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 5px 14px;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--line-input); border-radius: var(--radius);
  font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--hover); color: var(--ink); }
.btn-primary { background: var(--go); border-color: var(--go); color: #FFFFFF; }
.btn-primary:hover { background: var(--go-dark); border-color: var(--go-dark); color: #FFFFFF; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #FFFFFF; }
.btn-danger:hover { background: #8F1E18; border-color: #8F1E18; color: #FFFFFF; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .65; cursor: progress; }
.linkish {
  background: none; border: 0; padding: 0; margin: 0; min-height: 0;
  color: var(--info); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit;
}
.linkish:hover { color: var(--ink); }

/* Radio chips (Yes / No, Same / Changed). The real radio stays visible: it is the state, with or
   without JavaScript, and it keeps Windows high-contrast mode honest. */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.chips > legend { float: left; margin: 0 4px 0 0; padding: 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 32px; padding: 3px 14px 3px 10px;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--line-input); border-radius: 999px;
  font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none;
}
.chip:hover { background: var(--hover); }
label.chip.on { background: #DDE6EF; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
label.chip:has(> input:checked) { background: #DDE6EF; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
label.chip:has(> input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
span.chip, button.chip { cursor: default; font-size: 12.5px; min-height: 24px; padding: 1px 10px; font-weight: 600; }
button.chip { cursor: pointer; }

/* ---- tables ---------------------------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; background: var(--sheet); font-size: 13.5px; }
.table th, .table td { padding: 6px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.table thead th {
  vertical-align: bottom; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  border-bottom: 2px solid var(--line-input); background: var(--sheet);
}
.table tbody th, .table tfoot th { font-weight: 600; }
.table tbody tr:hover { background: var(--hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.superseded td { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.table tr.superseded td a { color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* ---- tags ------------------------------------------------------------------------------------ */
.tag {
  display: inline-block; vertical-align: middle; white-space: nowrap;
  font-size: 12px; font-weight: 600; line-height: 1.5; padding: 0 8px; border-radius: 999px;
  background: var(--wash); color: var(--ink-2); border: 1px solid transparent;
  font-family: var(--font); letter-spacing: 0;
}
.tag-muted { background: transparent; color: var(--muted); border-color: var(--line-input); }
.tag-warn { background: var(--warn-tint); color: var(--warn); border-color: #EBCB8B; }
.tag-ok { background: var(--go-tint); color: var(--go-dark); border-color: #A9D8BF; }
.tag-danger { background: var(--danger-tint); color: var(--danger); border-color: #EFB2AE; }

/* ---- facts (dl) ------------------------------------------------------------------------------ */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 18px; margin: 12px 0; }
.facts dt { color: var(--muted); font-weight: 600; font-size: 13px; padding-top: 1px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dd.notes { white-space: pre-wrap; background: var(--wash); padding: 6px 10px; border-radius: 4px; }

/* ---- filters, pager -------------------------------------------------------------------------- */
.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px;
  margin: 0 0 14px; padding: 10px 12px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px;
}
.filters .field { flex: 0 1 160px; margin: 0; }
.filters .btn, .filters .linkish { align-self: flex-end; }
.filters .linkish { min-height: 34px; display: inline-flex; align-items: center; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin: 14px 0 0; font-size: 13px; }
.pager a, .pager .btn {
  display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px;
  border: 1px solid var(--line-input); border-radius: var(--radius); background: var(--sheet);
  color: var(--ink); text-decoration: none; font-weight: 600;
}
.pager a:hover { background: var(--hover); }
.pager .muted, .pager span { color: var(--muted); }

/* ---- kpi tiles ------------------------------------------------------------------------------- */
.kpis, ul.kpi, ol.kpi, dl.kpi { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
div.kpi, .kpis > .kpi, ul.kpi > li, ol.kpi > li, dl.kpi > div {
  display: inline-flex; flex-direction: column; gap: 2px; min-width: 128px; margin: 0;
  padding: 10px 14px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px;
}
.kpi strong, .kpi b, .kpi .n, .kpi .kpi-n, .kpi dd {
  order: -1; margin: 0; font-size: 22px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums;
}
.kpi span, .kpi small, .kpi dt, .kpi .l, .kpi .kpi-l { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---- horizontal bar list (no inline style: widths are .w-N classes) ---------------------------- */
.bars { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 3px; }
.bars li {
  display: grid; grid-template-columns: minmax(7em, 14em) minmax(0, 1fr) minmax(3.5em, auto);
  align-items: center; gap: 12px; min-height: 24px; font-size: 13px;
}
.bars li::before {                       /* the track behind the bar */
  content: ""; grid-column: 2; grid-row: 1; height: 12px; border-radius: 2px; background: var(--wash);
}
.bars .bar {
  grid-column: 2; grid-row: 1; justify-self: start; z-index: 1;
  display: block; height: 12px; min-width: 0; border-radius: 2px; background: var(--services);
}
.bars .bar.w-0 { min-width: 2px; background: var(--line-input); }
.bars .bar-alt { background: var(--line-input); }
.bars .bar-warn { background: var(--amber); }
.bars .bar[class*="band-"] { background: var(--band); }
.bars .num, .bars li > :last-child { font-variant-numeric: tabular-nums; }
.bars li > :last-child:not(.bar) { text-align: right; }

.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }

/* ---- admin / manager page furniture ----------------------------------------------------------- */
.nowrap { white-space: nowrap; }
.table tr.total th, .table tr.total td { border-top: 2px solid var(--line-input); background: var(--wash); font-weight: 700; }
.table tr.quiet td { color: var(--muted); }
.table tr.inactive td { color: var(--muted); }
.table tr.locked td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.table td.detail { font-family: var(--mono); font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; min-width: 16em; }
.table.counts { max-width: 620px; }
.table.counts th { font-size: 13.5px; font-weight: 400; color: var(--ink); white-space: normal; border-bottom: 1px solid var(--rule); vertical-align: top; }
.row-actions .btn, .actions .btn { min-height: 28px; padding: 3px 10px; font-size: 13px; white-space: nowrap; }
.row-actions > *, .actions > * { margin: 0 6px 4px 0; }
pre.cmd {
  margin: 6px 0 12px; padding: 10px 14px; overflow-x: auto; white-space: pre;
  background: var(--ink); color: #E6EDF3; border-radius: 6px; font: 12.5px/1.5 var(--mono);
}
.pw-once {
  display: inline-block; margin: 6px 0 12px; padding: 8px 14px; border-radius: 6px;
  background: var(--warn-tint); box-shadow: inset 4px 0 0 var(--amber);
  font-size: 18px; letter-spacing: .04em; user-select: all; overflow-wrap: anywhere;
}
label.check { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 12px; cursor: pointer; }
label.check > input { margin-top: 3px; flex: none; }
.erase-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 12px 0; }
.erase-form { padding: 14px 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; }
.erase-form h2 { margin-top: 0; font-size: 15px; }
.confirm-form { margin-top: 14px; }
.survives { margin: 16px 0 0; padding: 12px 16px; background: var(--wash); border-radius: 8px; }
.survives h2 { margin-top: 0; font-size: 15px; }
.survives ul { margin: 6px 0 0; padding-left: 20px; }
.export-tier h2:first-child, .export-tier h1:first-child { margin-top: 0; }
.filters .field-wide { flex: 1 1 320px; }
.bars li:has(> .bar-alt) { min-height: 16px; margin-bottom: 7px; }
.bars li:has(> .bar-alt)::before { height: 7px; }
.bars .bar-alt { height: 7px; }

/* ---- bands ----------------------------------------------------------------------------------- */
.band-fabric      { --band: var(--fabric);      --tint: var(--fabric-tint);      --soft: var(--fabric-soft); }
.band-services    { --band: var(--services);    --tint: var(--services-tint);    --soft: var(--services-soft); }
.band-hazard      { --band: var(--hazard);      --tint: var(--hazard-tint);      --soft: var(--hazard-soft); }
.band-consequence { --band: var(--consequence); --tint: var(--consequence-tint); --soft: var(--consequence-soft); }

/* =============================================================================================== */
/* THE SURVEY SHEET (/call, /call/<ref>/correct)                                                  */
/* =============================================================================================== */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; }
.sheet-head {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px 16px;
  flex-wrap: wrap; min-height: 44px; padding: 8px 20px;
  border-bottom: 1px solid var(--rule); border-radius: 8px 8px 0 0; background: #F7F9FB;
}
.sheet-title { margin: 0; font-weight: 700; font-size: 15px; }
.sheet-tools { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }

/* Saved bar: laid OVER the sheet head, so hiding it after 4 s moves nothing on the page. */
.saved-bar {
  position: absolute; inset: -1px -1px 0 -1px; z-index: 3;
  display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; padding: 6px 20px;
  background: var(--go); color: #FFFFFF; border-radius: 8px 8px 0 0; font-weight: 600;
  transition: opacity .35s ease, visibility .35s;
}
.saved-bar a { color: #FFFFFF; text-decoration: underline; }
.saved-bar a:focus-visible { outline-color: #FFFFFF; }
.saved-bar .ref { font-weight: 700; }
.saved-bar.is-hidden { opacity: 0; visibility: hidden; }
.correction-bar {
  margin: 0; padding: 10px 20px; background: var(--warn-tint); color: var(--ink);
  border-bottom: 1px solid #EBCB8B; box-shadow: inset 4px 0 0 var(--amber);
}
.sheet > .error-box { margin: 12px 20px 0; }

.call-form { margin: 0; }
.form-error { margin: 12px 20px 0; }

/* A script section: margin index word on the left, spoken line + controls on the right. */
.q {
  display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); column-gap: 18px; align-content: start;
  padding: 12px 20px 14px; border-top: 1px solid var(--rule);
}
.call-form > .q:first-of-type { border-top: 0; }
.q-tag { grid-column: 1; margin: 0; padding-top: 2px; font-size: 12.5px; line-height: 1.5; font-weight: 700; color: var(--muted); }
.q-body { grid-column: 2; min-width: 0; }
.q-note { margin: -4px 0 8px; font-size: 12.5px; color: var(--muted); }
.q-note:last-child { margin-bottom: 0; }

/* Spoken words. The hanging open-quote sits in the gutter gap: "say this aloud". */
.say { position: relative; margin: 0 0 8px; max-width: 96ch; font-size: 15px; line-height: 1.45; color: var(--ink); }
.say::before {
  content: "\201C"; content: "\201C" / "";
  position: absolute; left: -.62em; top: -.08em;
  font-size: 1.3em; font-weight: 700; line-height: 1.4; color: #8E9AA7;
}
.say + .say { margin-top: -2px; }
.field > .say-label { font-size: 14px; font-weight: 400; color: var(--ink); }

/* Two short sections side by side (Landlord + Arrears) on wide screens. */
.q-pair { border-top: 1px solid var(--rule); }
.q-pair > .q { border-top: 0; }

/* Follow-up boxes. With JS dead every one is visible (and the server enforces the rules); html.js is
   set by app.js before first paint, and call.js keeps .is-open in step with the answers. */
html.js .reveal:not(.is-open) { display: none; }
.row > .reveal { flex: 1 1 220px; }
.q-tenure .row > .reveal { flex: 0 1 300px; }

.dupe-hint {
  display: inline-block; margin: 8px 0 0; padding: 3px 10px; border-radius: 4px;
  background: var(--warn-tint); color: var(--warn); font-size: 13px; font-weight: 600;
}
/* Address finder (Ideal Postcodes, via our server). The Find button exists in the markup but shows
   ONLY when html.js is set — with JS dead (or call.js failing, when app.js drops html.js after 3 s)
   the agent types the address and never sees a button that does nothing. Gated in CSS, not with the
   `hidden` attribute, so the row does not jump sideways when call.js arrives on every new call. */
.btn.addr-find { display: none; align-self: flex-end; white-space: nowrap; }
html.js .btn.addr-find { display: inline-flex; }
.field > span .addr-tag { margin-left: 4px; font-size: 11.5px; line-height: 1.4; vertical-align: 1px; }
.addr-msg {
  display: block; width: fit-content; max-width: 100%; margin: 8px 0 0; padding: 3px 10px; border-radius: 4px;
  background: var(--info-tint); color: var(--ink-2); font-size: 13px;
}
.addr-pick-wrap { max-width: 640px; margin: 8px 0 0; }
.q-identity .row + .row, .q-address .row + .row, .q-address .addr-pick-wrap + .row { margin-top: 8px; }
.addr-lines > span { display: block; }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }

.field-count { position: relative; }
.field-count > .count {
  position: absolute; top: 0; right: 0; margin: 0;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.field-count > .count.is-near { color: var(--warn); font-weight: 700; }
.field-count > .field > span { padding-right: 90px; }
.q-notes .field-count { max-width: 820px; }
.q-close .q-note { margin: 6px 0 0; }

/* ---- the 19 issues ----------------------------------------------------------------------------- */
.hint-strip {
  position: sticky; top: 0; z-index: 2;
  height: var(--hint-h); line-height: var(--hint-h); margin: 0; padding: 0 10px 0 14px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 13px; color: var(--ink-2); background: var(--wash); border-radius: 4px;
  box-shadow: inset 4px 0 0 var(--line-input);
}
.hint-strip.is-live { color: var(--ink); background: var(--tint, var(--wash)); box-shadow: inset 4px 0 0 var(--band, var(--line-input)); }

.issues {
  display: grid;
  grid-template-rows: repeat(10, auto);  /* DOM order = script order: down column 1, then column 2 */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px 16px; margin-top: 6px;
  /* Rows in the two columns share track heights; start-aligned so the three rows beside the
     injury rows (whose guidance runs to extra lines) keep their own one-line height. */
  align-items: start;
}
.issue {
  --band: var(--fabric); --tint: var(--fabric-tint); --soft: var(--fabric-soft);
  --bar: var(--soft); --bg: transparent; --ring: 0 0 0 0 transparent;
  display: grid; grid-template-columns: 18px 20px minmax(0, 1fr); column-gap: 8px; align-items: center;
  align-content: start;
  min-height: var(--issue-row-h); padding: 6px 10px 6px 14px; border-radius: 4px;
  background: var(--bg); box-shadow: inset 4px 0 0 var(--bar), var(--ring);
  cursor: pointer; user-select: none;
}
.issue.band-services    { --band: var(--services);    --tint: var(--services-tint);    --soft: var(--services-soft); }
.issue.band-hazard      { --band: var(--hazard);      --tint: var(--hazard-tint);      --soft: var(--hazard-soft); }
.issue.band-consequence { --band: var(--consequence); --tint: var(--consequence-tint); --soft: var(--consequence-soft); }
.issue:hover { --bg: var(--hover); }
/* Ticked: solid bar + tint (+ the native check). Two rules, because one old browser that cannot
   parse :has() would otherwise drop both selectors. */
.issue.on { --bg: var(--tint); --bar: var(--band); }
.issue:has(> input:checked) { --bg: var(--tint); --bar: var(--band); }
.issue.special { --ring: inset 0 0 0 1px var(--amber); }
.issue:has(> input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.issue > input { width: 18px; height: 18px; accent-color: var(--band); cursor: pointer; }
.issue > input:focus-visible { outline-offset: 1px; }
.issue .n { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.issue .line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; min-width: 0; }
.issue .lbl { font-weight: 700; }
.issue .special-note { color: var(--danger); font-size: 12px; font-weight: 600; }
.issue .clause, .issue .guidance { grid-column: 3; font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.issue .clause { color: var(--ink-2); }
.issue .guidance { color: var(--ink-2); font-size: 12px; }
.guidance-tag {
  display: inline-block; margin-right: 5px; padding: 0 5px; border-radius: 3px;
  font-style: normal; font-weight: 700; font-size: 11px; line-height: 1.5;
  color: var(--info); background: var(--info-tint); border: 1px solid #B9CDEA;
}
/* JS present: the long script clause moves to the hint strip, so rows stay one line tall. */
html.js .issues .clause, .issues.hints-on .clause { display: none; }

/* ---- sticky bar ------------------------------------------------------------------------------ */
.sticky-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  min-height: 58px; padding: 8px 20px;
  background: var(--sheet); border-top: 2px solid var(--ink); border-radius: 0 0 8px 8px;
  box-shadow: 0 -6px 14px rgba(21, 32, 43, .08);
}
.sb-group { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.sb-ticked { flex: 3 1 420px; }
.sb-missing { flex: 1 1 240px; }
.sb-label { flex: none; padding-top: 3px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
/* The ticked list is the read-back: never clipped or scrolled, the bar grows instead. */
.ticked, .missing { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; }
.chip-issue { border-radius: 4px; border-color: transparent; background: var(--tint, var(--wash)); box-shadow: inset 3px 0 0 var(--band, var(--line-input)); padding-left: 9px; }
.chip-missing { border-style: dashed; background: var(--sheet); color: var(--ink-2); font-weight: 600; }
.chip-missing:hover { border-style: solid; background: var(--hover); color: var(--ink); }
.chip-missing.is-urgent { border-color: var(--danger); color: var(--danger); border-style: solid; }
.sb-none { font-size: 13px; color: var(--muted); }
.sb-ready { font-size: 13px; color: var(--go-dark); font-weight: 700; }
.btn-save { margin-left: auto; min-width: 290px; min-height: 42px; font-size: 15px; padding: 6px 18px; }
.sb-alert { flex: 1 0 100%; margin: 0; order: -1; }
.cursor-legend { flex: 1 0 100%; margin: 0; font-size: 12px; color: var(--muted); order: 5; }

/* ---- opt-in keyboard reading cursor --------------------------------------------------------------- */
.cursor-mode .issue.cursor { outline: 2px solid var(--focus); outline-offset: 1px; --bg: var(--info-tint); }
.cursor-mode .issue.cursor.on { --bg: var(--tint); }

/* =============================================================================================== */
/* SURVEY DETAIL (/call/<ref>)                                                                     */
/* =============================================================================================== */
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 20px; }
.detail-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 8px 32px; align-items: start; margin-top: 8px; }
.detail-grid h2 { margin-top: 12px; }
.issue-list {
  list-style: none; margin: 8px 0 0; padding: 0;
  display: grid; grid-template-rows: repeat(10, auto); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  gap: 2px 12px; align-items: start;
}
.issue-list li {
  display: flex; gap: 8px; align-items: baseline;
  padding: 4px 10px 4px 12px; border-radius: 3px; font-size: 13.5px;
  box-shadow: inset 4px 0 0 var(--soft, var(--rule));
}
.issue-list li.yes { background: var(--tint); box-shadow: inset 4px 0 0 var(--band); font-weight: 700; }
.issue-list li.no { color: var(--muted); }
.issue-list .yn { flex: none; width: 14px; font-weight: 700; text-align: center; }
.issue-list li.yes .yn { color: var(--band); }
.issue-list .sc { font-size: 12px; font-weight: 600; color: var(--danger); white-space: nowrap; }
.chain { margin: 6px 0 0; padding-left: 22px; }
.chain li { margin: 3px 0; }
.chain .this { font-weight: 700; }
.detail-actions { display: flex; gap: 8px; align-items: center; }

/* =============================================================================================== */
/* CUSTOMER UPLOADS — the STAFF pages (/uploads…, /admin/uploads/settings). The customer's own page   */
/* (/u/…) never loads this file: it has static/css/upload.css.                                      */
/* =============================================================================================== */
.up-shows { margin: 12px 0 0; }
a.chip { text-decoration: none; color: var(--ink); }
span.chip.on { background: #DDE6EF; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.up-test-mode { background: var(--warn-tint); box-shadow: inset 4px 0 0 var(--amber); }
.up-new { max-width: 760px; }
.up-new .row + .row { margin-top: 10px; }
.up-new .row + .muted { margin-top: 6px; }
.up-repeat { margin: 4px 0 14px; background: var(--warn-tint); box-shadow: inset 4px 0 0 var(--amber); }
.up-repeat .check-inline { margin-top: 8px; }
.up-status { margin: 12px 0 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--wash);
             box-shadow: inset 4px 0 0 var(--line-input); }
.up-status p { margin: 0 0 8px; }
.up-status p:last-child { margin-bottom: 0; }
.up-status-ok { background: var(--go-tint); box-shadow: inset 4px 0 0 var(--go); }
.up-status-bad { background: var(--danger-tint); box-shadow: inset 4px 0 0 var(--danger); }
.up-status-test { background: var(--warn-tint); box-shadow: inset 4px 0 0 var(--amber); }
.up-status .actions { margin-top: 4px; }
.up-reveal { margin: 0 0 14px; padding: 12px 14px; border: 2px solid var(--focus); border-radius: var(--radius); background: var(--info-tint); }
.up-reveal input { width: 100%; font-size: 15px; user-select: all; }
.up-reveal p { margin: 6px 0 0; }
.up-reveal .up-copy { margin-top: 8px; }
.up-admin-actions { margin: 4px 0 8px; }
/* Close cannot be undone: its own box, a clear gap away from Extend, and a tick before the button */
.up-close { margin: 18px 0 8px; padding: 10px 14px; border: 1px solid var(--danger); border-radius: var(--radius);
            background: var(--danger-tint); max-width: 640px; }
.up-close p { margin: 0 0 6px; }
.up-close .check-inline { margin: 0 12px 0 0; }
.up-files { list-style: none; margin: 6px 0 14px; padding: 0; display: grid; gap: 12px;
            grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.up-file { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--sheet);
           border: 1px solid var(--rule); border-radius: var(--radius); min-width: 0; }
.up-file .btn { align-self: flex-start; min-height: 28px; padding: 3px 10px; font-size: 13px; }
.up-thumb { display: block; height: 150px; border-radius: 4px; overflow: hidden; background: var(--wash); }
.up-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.up-thumb:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.up-tile { display: flex; align-items: center; justify-content: center; height: 150px; border-radius: 4px;
           background: var(--wash); color: var(--ink-2); font-family: var(--mono); font-size: 22px; font-weight: 700;
           letter-spacing: .06em; }
.up-file-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.up-settings { max-width: 820px; }
.up-settings textarea { width: 100%; }
.up-example { margin: 4px 0 12px; padding: 10px 14px; background: var(--wash); border-radius: var(--radius); }
.up-example-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; margin: 4px 0 6px; }
.up-default { margin: 0 0 12px; font-size: 13px; }
.up-default summary { cursor: pointer; color: var(--info); }
.up-default p { margin: 6px 0 0; overflow-wrap: anywhere; }

/* =============================================================================================== */
/* SIGN-IN PAGES                                                                                   */
/* =============================================================================================== */
.auth .card h1 { font-size: 22px; }
.auth .card .btn-primary { width: 100%; min-height: 40px; margin-top: 4px; }
.auth .card form + form, .auth .card form + p { margin-top: 14px; }
.steps { margin: 0 0 10px; padding-left: 22px; }
.steps li { margin: 4px 0; }
.qr { margin: 8px 0 12px; }
.qr img { display: block; width: 232px; height: 232px; padding: 8px; background: #FFFFFF; border: 1px solid var(--rule); border-radius: 6px; }
.secret { display: inline-block; font-size: 14px; letter-spacing: .06em; user-select: all; }
.error-page h1 { font-size: 22px; }

/* =============================================================================================== */
/* RESPONSIVE                                                                                      */
/* =============================================================================================== */
@media (min-width: 900px) {  /* = --issue-cols-bp */
  .q-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .q-pair > .q + .q { border-left: 1px solid var(--rule); }
}

@media (max-width: 899.98px) {  /* = --issue-cols-bp */
  .issues, .issue-list { grid-template-rows: none; grid-auto-flow: row; grid-auto-columns: auto; }
  :root { --hint-h: 38px; }
  .hint-strip {
    white-space: normal; line-height: 1.35; padding-top: 2px; padding-bottom: 2px;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Condensed: a 1366×768 laptop leaves ~650px of browser viewport. Tighter rhythm, and the tenant and
   address sections share one row. */
@media (max-height: 700px) and (min-width: 900px) {
  :root { --issue-row-h: 30px; }
  .q { padding: 8px 18px 10px; }
  .sheet-head { min-height: 38px; padding: 5px 18px; }
  .say { font-size: 14.5px; margin-bottom: 6px; }
  .q-open .say { display: inline; }
  .q-open .say + .say::before { content: none; }
  .issue { padding-top: 4px; padding-bottom: 4px; }
  .q-pair-short { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .q-pair-short > .q { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
  .q-pair-short > .q > .q-tag, .q-pair-short > .q > .q-body { grid-column: 1; }
  .q-pair-short > .q .say::before { content: none; }
  .q-pair-short > .q + .q { border-left: 1px solid var(--rule); }
  .q-pair-short .row > .field { flex-basis: 120px; }
  .q-pair-short .row > .field-sm { flex-basis: 118px; }
  .sticky-bar { min-height: 52px; padding: 6px 18px; }
  .btn-save { min-height: 38px; }
}

@media (max-width: 700px) {
  main.page { padding: 12px 10px 32px; }
  .card { padding: 16px; }
  .topbar { padding: 0 12px; }
  .nav { order: 3; flex: 1 0 100%; overflow-x: auto; margin: 0 -12px; padding: 0 6px; scrollbar-width: none; }
  .nav a { min-height: 40px; }
  .who { font-size: 12.5px; }
  .who-role { display: none; }
  .q { grid-template-columns: minmax(0, 1fr); row-gap: 4px; padding: 10px 14px 12px; }
  .q-tag, .q-body { grid-column: 1; }
  .say::before { content: none; }
  .sheet-head { padding: 8px 14px; }
  .saved-bar { padding: 6px 14px; }
  .sticky-bar { padding: 8px 14px; gap: 6px 10px; }
  .btn-save { flex: 1 0 100%; min-width: 0; margin-left: 0; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .facts dd { margin-bottom: 8px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .bars li { grid-template-columns: minmax(6em, 9em) minmax(0, 1fr) auto; gap: 8px; }
  .field-count > .field > span { padding-right: 0; }
  .field-count > .count { position: static; display: block; text-align: right; }
  .sheet-tools { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .row > .field, .row > .field-sm { flex-basis: 100%; }
  .chips > legend { float: none; display: block; width: 100%; margin-bottom: 2px; }
  .kpis > .kpi, div.kpi { min-width: 0; flex: 1 1 40%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Windows high contrast: backgrounds and box-shadows vanish, so draw what matters with borders. */
@media (forced-colors: active) {
  .issue { border: 1px solid CanvasText; }
  .issue.on { border-left: 6px solid Highlight; }
  .issue:has(> input:checked) { border-left: 6px solid Highlight; }
  .saved-bar, .sticky-bar, .hint-strip { border: 1px solid CanvasText; }
  .chip-issue, .chip-missing { border: 1px solid CanvasText; }
}
