/* quality/quality.css — layout rules for Differ Quality that the design-system bundle
   does not carry (rails, the three-pane body, charts, pile table). Colours are written
   through the semantic tokens from ds/tokens.css so both palettes follow. */

.qc { font-family: var(--font-sans); background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; line-height: 1.4; }
.qc .shell { display: flex; flex-direction: column; min-height: 100vh; }
.qc.view-desktop .shell { height: 100vh; }
.qc .eyebrow { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.9px; color: var(--text-muted); }
.qc .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Three-pane body: 330 px rail · fluid centre · 288 px rail */
.qc .body { display: flex; flex: 1; min-height: 0; }
.qc .rail-l { width: var(--rail-left, 350px); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.qc .rail-r { width: var(--rail-right, 320px); flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.qc .center { flex: 1; min-width: 0; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.qc .railhead { padding: 16px 18px 12px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.qc .scroll { overflow: auto; flex: 1; min-height: 0; }

/* Mobile view: the 400 × 812 shell on --desk, panes stacked */
.qc.view-mobile { background: var(--desk); padding: 24px 0 40px; }
.qc.view-mobile .shell { width: 400px; max-width: 100%; margin: 0 auto; min-height: 812px; background: var(--bg); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-shell); }
.qc.view-mobile .body { flex-direction: column; }
.qc.view-mobile .rail-l, .qc.view-mobile .rail-r { width: auto; border: none; border-bottom: 1px solid var(--border); }
.qc.view-mobile .rail-l .scroll { max-height: 250px; }
.qc.view-mobile .center { padding: 14px; overflow: visible; }

/* Mobile header rows under MobileTopBar: full-width tab row, then the project chip row */
.qc .mtabs { background: var(--primary); padding: 0 8px; flex-shrink: 0; display: flex; }
.qc .mtabs button { flex: 1; justify-content: center; }
.qc .mchip { background: var(--primary); padding: 0 14px 10px; flex-shrink: 0; display: flex; align-items: center; }
.qc-chip:hover { background: var(--on-navy-fill-hover) !important; }
.qc-projrow:hover { border-color: var(--accent) !important; background: var(--sel-bg) !important; }

/* Narrow desktop viewports stack the same way */
@media (max-width: 900px) {
  .qc.view-desktop .shell { height: auto; }
  .qc.view-desktop .body { flex-direction: column; }
  .qc.view-desktop .rail-l, .qc.view-desktop .rail-r { width: auto; border: none; border-bottom: 1px solid var(--border); }
  .qc.view-desktop .rail-l .scroll { max-height: 250px; }
  .qc.view-desktop .center { overflow: visible; }
}

/* ── Piles / Screws tab ── */
.qc .trow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; width: 100%; padding: 12px 18px; border: none; border-bottom: 1px solid var(--border-soft); background: var(--surface); color: var(--text); text-align: left; font-family: inherit; cursor: pointer; transition: background .15s; }
.qc .trow:hover { background: var(--wash-50); }
.qc .trow.on { background: var(--row-sel); box-shadow: inset 3px 0 0 var(--accent); }
.qc .trow .sub { grid-column: 1 / -1; font-size: 12px; color: var(--text-subtle); }
.qc .seg-compact { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.qc .seg-compact button { border: none; background: none; color: var(--text-muted); font-family: inherit; font-size: 12.5px; font-weight: 700; padding: 7px 12px; white-space: nowrap; cursor: pointer; }
.qc .seg-compact button.on { background: var(--primary); color: var(--accent); }
.qc .field { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.qc .field > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.qc .field.stack { flex-direction: column; align-items: flex-start; gap: 5px; }
.qc .srcnote { font-size: 12px; line-height: 1.45; color: var(--text-subtle); margin: -4px 0 0; }
/* datasets compared: the rail card and the dialog */
.qc .ds-line { display: flex; justify-content: space-between; gap: 8px; }
.qc .ds-line .mono { color: var(--text-muted); font-size: 12px; }
.qc .ds-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.qc .ds-col { display: flex; flex-direction: column; gap: 11px; min-width: 0; }
.qc .ds-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.qc .ds-sub { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.qc .ds-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.qc .ds-list > div { background: var(--surface); padding: 9px 11px; display: flex; align-items: center; gap: 11px; }
.qc .ds-list > div > :first-child { flex-shrink: 0; }
.qc .ds-list > div.ds-wrap { flex-wrap: wrap; row-gap: 3px; }
.qc .ds-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin-left: auto; text-align: right; white-space: nowrap; }
.qc .ds-other { flex-basis: 100%; padding-left: 30px; font-size: 12px; line-height: 1.45; color: var(--text-subtle); }
.qc .ds-status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 13px; }
@media (max-width: 760px) { .qc .ds-grid, .qc .ds-status { grid-template-columns: minmax(0, 1fr); } }
.qc .field input { font-family: var(--font-mono); font-size: 13px; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); width: 84px; text-align: right; outline: none; }
.qc .field input:focus { border-color: var(--primary-ink); }
.qc .checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 10px; }
.qc .check { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 15px 16px; display: flex; flex-direction: column; gap: 5px; }
.qc .chart { padding: 4px 0 0; }
.qc .chart svg { display: block; width: 100%; height: auto; }
.qc .chart-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.qc .chart-note { font-size: 12.5px; color: var(--text-muted); }
.qc .piles { border-collapse: collapse; width: 100%; font-size: 13px; }
.qc .piles th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); text-align: right; padding: 9px 9px; line-height: 1.25; vertical-align: bottom; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); font-weight: 800; white-space: normal; }
.qc .piles td { padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--border-soft); font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.qc .piles th:first-child, .qc .piles td:first-child, .qc .piles th:nth-child(2), .qc .piles td:nth-child(2), .qc .piles th:last-child, .qc .piles td:last-child { text-align: left; }
.qc .piles td:first-child { font-family: var(--font-sans); font-weight: 700; }
/* Failing / near-limit values: the status tokens both palettes carry; the dark palette lifts them
   to the edge tints so 12 px digits stay above 4.5:1 on the navy surface */
.qc .piles td.t-fail { color: var(--fail); font-weight: 700; }
/* Civil Works map: zoom buttons and the Ctrl / ⌘ + scroll hint */
.qc .civil-zoom { position: absolute; left: 12px; top: 10px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-map-control, none); }
.qc .civil-zoom button { width: 32px; height: 30px; border: none; background: none; color: var(--text); font-family: inherit; font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; }
.qc .civil-zoom button + button { border-top: 1px solid var(--border-soft); }
.qc .civil-zoom button:hover:not(:disabled) { background: var(--wash-50); }
.qc .civil-zoom button:disabled { color: var(--text-subtle); cursor: default; }
.qc .civil-zoom-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 14px; border-radius: 9px; background: var(--surface); color: var(--text); border: 1px solid var(--border); font-size: 13px; font-weight: 600; pointer-events: none; }
.qc .ink-fail { color: var(--fail); }
.qc .ink-warn { color: var(--warn); }
.qc.theme-dark .ink-fail { color: var(--fail-edge); }
.qc.theme-dark .ink-warn { color: var(--warn-border); }
.qc .piles td.t-warn { color: var(--warn); font-weight: 700; }
.qc.theme-dark .piles td.t-fail { color: var(--fail-edge); }
.qc.theme-dark .piles td.t-warn { color: var(--warn-border); }
.qc .piles tr.hl td { background: var(--row-sel); }
.qc .piles.cmp th:nth-child(2), .qc .piles.cmp td:nth-child(2), .qc .piles.cmp th:last-child, .qc .piles.cmp td:last-child { text-align: right; }
.qc.theme-dark .piles tr.hl td { background: var(--sel-bg); }
.qc .map-wrap { background: var(--map-canvas); position: relative; border-radius: 13px; overflow: hidden; }
.qc .map-wrap svg { display: block; width: 100%; height: auto; }
.qc .note-warn { color: var(--warn-deep); }
.qc.theme-dark .note-warn { color: var(--warn-border); }
.qc .civil-panel { background: var(--surface-sunken); min-height: 300px; display: flex; align-items: center; justify-content: center; padding: 24px; border-radius: 13px; }
.qc.theme-dark .civil-panel { background: var(--map-canvas); }
.qc .map-wrap .hud { position: absolute; top: 14px; left: 14px; min-width: 220px; display: flex; flex-direction: column; gap: 6px; }
.qc .hud-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #cfe0ee; }
.qc .hud-row .sw { width: 14px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.qc .hud-row .v { font-family: var(--font-mono); color: #fff; margin-left: auto; }
.qc .detail-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.qc .big-id { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; line-height: 1; }
.qc .rail-block { display: flex; flex-direction: column; gap: 11px; }
.qc .srclabel { display: flex; flex-direction: column; align-items: stretch; gap: 4px; line-height: 1.25; width: 100%; min-width: 0; text-align: left; }
.qc .srclabel .t { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qc .srclabel .m { white-space: normal; font-family: var(--font-mono); font-size: 11px; font-weight: 400; color: var(--text-subtle); }
.qc .srcstats { font-family: var(--font-mono); font-size: 12px; color: var(--text-subtle); line-height: 1.4; margin-top: -4px; }
.qc .srcstats.has-issues { color: var(--text-muted); }
.qc .crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); flex-wrap: wrap; }
.qc .crumb b { color: var(--text); font-weight: 700; }
.qc .frm { display: flex; flex-direction: column; gap: 5px; }
.qc .frm textarea, .qc .frm input[type=text] { font-family: inherit; font-size: 15px; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); outline: none; width: 100%; }
.qc .frm textarea:focus, .qc .frm input[type=text]:focus { border-color: var(--primary-ink); }
.qc .frm textarea::placeholder, .qc .frm input::placeholder { color: var(--text-subtle); opacity: 1; }
.qc .modal-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.qc .filerow { display: flex; align-items: center; gap: 11px; padding: 10px 16px; border: none; border-bottom: 1px solid var(--border-soft); width: 100%; background: var(--surface); color: var(--text); text-align: left; font-family: inherit; cursor: pointer; }
.qc .filerow:hover { background: var(--wash-50); }
.qc .cb { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--primary); font-size: 12.5px; font-weight: 800; }
.qc .cb.on { background: var(--accent); border-color: var(--accent); }
.qc.view-mobile .detail-head { padding: 12px 14px; }
.qc.view-mobile .big-id { font-size: 26px; }
.qc.view-mobile .map-wrap .hud { min-width: 150px; }
/* plan too narrow for the HUD beside the drawing: the HUD sits below it */
.qc .map-wrap.hud-below .hud { position: static; min-width: 0; margin: 0 10px 10px; }

/* The centre column is a flex column: cards must keep their content height, not shrink to the
   SVG's intrinsic 150 px */
.qc .center > * { flex-shrink: 0; }

/* Download PDF (quality/print.js): only the copied part is printed, in the light palette */
#qc-print { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm 11mm; }
  body.qc-printing > *:not(#qc-print) { display: none !important; }
  body.qc-printing #qc-print { display: block !important; }
  #qc-print.qc { min-height: 0; background: var(--surface); font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #qc-print .no-print, #qc-print .civil-zoom, #qc-print .civil-zoom-hint { display: none !important; }
  #qc-print [style*="max-height"], #qc-print [style*="overflow"] { max-height: none !important; overflow: visible !important; }
  #qc-print .piles th { position: static; }
  #qc-print .piles td, #qc-print .piles th { padding: 4px 6px; font-size: 10.5px; }
  #qc-print .checks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #qc-print .check { padding: 10px 12px; }
  /* a flex column does not split well across pages: print it as blocks with the same spacing */
  #qc-print [style*="flex-direction: column"] { display: block !important; }
  #qc-print [style*="flex-direction: column"] > * + * { margin-top: 12px; }
  #qc-print .chart, #qc-print .check, #qc-print tr, #qc-print img, #qc-print .map-wrap { break-inside: avoid; }
  #qc-print .qc-print-part + .qc-print-part { margin-top: 12px; }
  #qc-print .qc-print-head { display: flex; flex-direction: column; gap: 3px; padding: 0 0 10px; margin: 0 0 12px; border-bottom: 2px solid var(--primary-ink); }
  #qc-print .qc-print-brand { font-size: 10.5px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--text-muted); }
  #qc-print .qc-print-title { font-size: 17px; font-weight: 800; color: var(--primary-ink); }
  #qc-print .qc-print-line { font-size: 11.5px; color: var(--text-muted); }
}
