:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d8dee6;
  --primary: #b42318;
  --primary-dark: #8f1c13;
  --good: #067647;
  --warn: #b54708;
  --bad: #b42318;
  --shadow: 0 5px 18px rgba(16, 24, 40, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
img, svg, video, canvas { max-width: 100%; height: auto; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; overflow-wrap: break-word; }
body.has-topbar { padding-top: 64px; overflow-x: hidden; }
a { color: #175cd3; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin-top: 0; }
h1 { font-size: 1.8rem; margin-bottom: .25rem; }
h2 { font-size: 1.2rem; }
p { line-height: 1.5; }
.topbar { min-height: 64px; background: #182230; color: white; display: flex; align-items: center; gap: 24px; padding: 0 28px; position: fixed; top: 0; left: 0; right: 0; z-index: 20; box-shadow: var(--shadow); }
.topbar a { color: white; }
.menu-toggle { display: none; }
.menu-toggle-label { display: none; }
.brand { font-weight: 800; font-size: 1.1rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; border: 1px solid rgba(255,255,255,.4); padding: 6px 12px; border-radius: 6px; }
.brand img { height: 32px; width: auto; }
.topbar nav { display: flex; gap: 20px; flex: 1; }
.account { display: flex; align-items: center; gap: 13px; font-size: .9rem; white-space: nowrap; }
.department-pill { display: inline-flex; align-items: center; border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.08); padding: 6px 10px; border-radius: 999px; cursor: pointer; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.department-pill:hover { background: rgba(255,255,255,.18); }
.department-pill-empty { color: rgba(255,255,255,.72); font-style: italic; }
.container { max-width: 1500px; margin: 0 auto; padding: 28px; }
.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 22px; }
.page-heading p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.panel-heading h2 { margin: 0; }
.top-gap { margin-top: 22px; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .7fr); gap: 22px; }
.two-column.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(300px, .7fr); }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(155px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { background: white; border: 1px solid var(--line); border-left: 5px solid #344054; border-radius: 9px; padding: 18px; color: var(--text); box-shadow: var(--shadow); }
.metric:hover { text-decoration: none; transform: translateY(-1px); }
.metric strong { display: block; font-size: 1.8rem; }
.metric span { color: var(--muted); }
.metric.danger { border-left-color: var(--bad); }.metric.warning { border-left-color: var(--warn); }
.btn { appearance: none; border: 1px solid #98a2b3; background: #fff; color: #344054; padding: 9px 14px; border-radius: 7px; font: inherit; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; max-width: 100%; white-space: normal; }
.btn:hover { text-decoration: none; background: #f2f4f7; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.stack { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
label { display: grid; gap: 6px; font-weight: 600; color: #344054; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid #98a2b3; border-radius: 6px; padding: 9px 10px; background: white; color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(23, 92, 211, .16); border-color: #175cd3; }
input[type="radio"], input[type="checkbox"] { width: 24px; height: 24px; }
.import-date-options { display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 8px; }
.radio-cell { display: flex; align-items: center; }
.text-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.text-cell input[type="date"] { width: 100%; }
textarea { min-height: 90px; resize: vertical; }
.check-line { display: flex; align-items: center; gap: 9px; }
.check-line input { width: auto; }
.form-panel { max-width: 1200px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { background: #f9fafb; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; color: #475467; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.center { text-align: center; }
.narrow { min-width: 85px; }
.muted { color: var(--muted); }
.badge { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: .78rem; font-weight: 750; white-space: nowrap; }
.badge-good { background: #ecfdf3; color: var(--good); }.badge-warn { background: #fffaeb; color: var(--warn); }.badge-bad { background: #fef3f2; color: var(--bad); }.badge-muted { background: #f2f4f7; color: #475467; }
.alert { padding: 12px 14px; border-radius: 7px; margin-bottom: 16px; border: 1px solid; }
.alert-success { color: #05603a; background: #ecfdf3; border-color: #abefc6; }.alert-error { color: #912018; background: #fef3f2; border-color: #fecdca; }.alert-warning { color: #93370d; background: #fffaeb; border-color: #fedf89; }
.filter-bar { display: grid; grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(150px, .8fr)) auto; gap: 10px; margin-bottom: 14px; }
.selection-tools, .test-toolbar, .sticky-actions, .print-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.selection-tools { margin-bottom: 10px; border: 1px solid #111; padding: 10px; border-radius: 8px; }
.selection-count { font-weight: 650; white-space: nowrap; }
.bulk-action-target[hidden] { display: none; }
.test-toolbar { background: white; border: 1px solid var(--line); padding: 12px; border-radius: 8px 8px 0 0; }
.test-toolbar label { display: flex; align-items: center; gap: 8px; }
.test-toolbar input { width: auto; }
.scan-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.scan-tools input[type=search] { min-width: 200px; }
.scan-tools .btn { padding: 9px 12px; white-space: nowrap; }
.test-table input[type=checkbox] { width: 22px; height: 22px; }

/* Toggle switch, e.g. scanner mode */
.switch { position: relative; display: inline-flex; flex: 0 0 auto; width: 40px; height: 24px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .slider { position: absolute; inset: 0; background: #98a2b3; border-radius: 999px; transition: background .15s; }
.switch .slider::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: white; border-radius: 50%; transition: transform .15s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); outline-offset: 2px; }

.camera-scan-dialog { border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 16px; width: min(92vw, 480px); }
.camera-scan-dialog::backdrop { background: rgba(16, 24, 40, .55); }
.camera-scan-dialog video { display: block; width: 100%; border-radius: 8px; background: #111; aspect-ratio: 1 / 1; object-fit: cover; }
.camera-scan-dialog p { margin: 10px 0; }
.camera-scan-dialog .actions { justify-content: flex-end; }
.test-table td { min-width: 80px; }
.test-table td:last-child { min-width: 220px; }
.asset-cell { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.asset-meta { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.asset-meta-length { display: none; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244,246,248,.96); border-top: 1px solid var(--line); padding: 14px 0; justify-content: flex-end; }
.auth-card { max-width: 430px; margin: 8vh auto; background: white; padding: 32px; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.department-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.department-card { display: grid; gap: 10px; background: white; border: 1px solid var(--line); padding: 22px; border-radius: 10px; box-shadow: var(--shadow); }
.department-card strong { font-size: 1.2rem; }.department-card span { color: var(--muted); }

.inline-form { display: inline; margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 22px; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 11px 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: #475467; font-weight: 700; white-space: nowrap; }
.tabs a:hover { text-decoration: none; background: #f9fafb; }
.tabs a.active { background: white; border-color: var(--line); color: var(--primary); position: relative; top: 1px; }
.tab-count { display: inline-flex; min-width: 22px; height: 22px; align-items: center; justify-content: center; padding: 0 6px; border-radius: 999px; background: #f2f4f7; color: #475467; font-size: .78rem; }
.empty-state { background: white; border: 1px dashed #98a2b3; padding: 30px; border-radius: 10px; text-align: center; }
.session-list { display: grid; gap: 8px; }.session-list a { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); }.session-list a:hover { text-decoration: none; background: #f9fafb; }
.label-preview { text-align: center; }.label-preview img { display: block; width: 15.875mm; height: 15.875mm; max-width: 15.875mm; margin: 0 auto 12px; }.label-preview strong { display: block; font-family: ui-monospace, monospace; }
details summary { width: max-content; list-style: none; } details summary::-webkit-details-marker { display: none; }.repair-form { margin-top: 16px; }
.label-sheet { display: grid; grid-template-columns: repeat(4, 32mm); align-content: start; gap: 3mm; padding: 8mm; background: white; }
.hose-label { width: 32mm; height: 18mm; box-sizing: border-box; border: .25mm solid #111; display: grid; grid-template-columns: 14mm 1fr; align-items: center; gap: 1mm; padding: 1mm; break-inside: avoid; }
.hose-label img { width: 14mm; height: 14mm; object-fit: contain; }.hose-label strong { min-width: 0; display: block; font-size: 7.5pt; line-height: 1.05; overflow-wrap: anywhere; text-align: center; font-family: ui-monospace, monospace; }
.print-main { background: white; }.print-controls { padding: 14px 18px; background: #f2f4f7; position: sticky; top: 0; z-index: 30; }
.worksheet-page { width: 8.5in; min-height: 11in; margin: 12px auto; background: white; border: 2px solid #111; padding: 0; display: flex; flex-direction: column; page-break-after: always; }
.worksheet-page:last-child { page-break-after: auto; }.worksheet-header h1 { font-size: 27pt; text-align: center; margin: 8px 0; }.worksheet-meta { display: grid; grid-template-columns: 1fr 1fr; padding: 0 12px; gap: 4px 40px; }.worksheet-meta div { display: grid; grid-template-columns: 100px 1fr; }.worksheet-sub { display: flex; justify-content: space-between; padding: 3px 7px; border-bottom: 1px solid #111; font-size: 9pt; }
.worksheet-table { flex: 1; table-layout: fixed; font-size: 8.5pt; }.worksheet-table th,.worksheet-table td { border: 1px solid #111; padding: 2px 3px; text-align: center; vertical-align: middle; height: 20px; }.worksheet-table th { background: white; text-transform: none; letter-spacing: 0; color: #111; white-space: normal; font-size: 8pt; }.worksheet-table th:nth-child(1){width:4%}.worksheet-table th:nth-child(2){width:9%}.worksheet-table th:nth-child(3){width:8%}.worksheet-table th:nth-child(4){width:9%}.worksheet-table th:nth-child(5){width:10%}.worksheet-table th:nth-child(6){width:8%}.worksheet-table th:nth-child(7){width:8%}.worksheet-table th:nth-child(8){width:10%}.worksheet-table th:nth-child(9){width:10%}.worksheet-table th:nth-child(10){width:12%}.worksheet-table th:nth-child(11){width:12%}.worksheet-page footer { display: flex; justify-content: space-between; padding: 3px 7px; font-size: 7pt; }
.report-table th.report-title, .report-table tr.report-meta th, .report-table th.report-sub, .report-table td.report-footer { border: 0; width: auto; }
.report-table th.report-title h1 { font-size: 22pt; margin: 0; }
.report-table .repair-detail-cell { font-size: 7.5pt; background: #f9fafb; padding: 4px 8px; border-top: 0; }
.report-table tr.report-meta th { font-weight: normal; text-align: left; }
.report-table th.report-sub { font-weight: normal; text-align: left; }
.report-table th.report-sub span { border-bottom: 1px solid #111; display: block; padding-bottom: 2px; }
@media (max-width: 1000px) { .topbar { flex-wrap: wrap; padding: 12px 18px; }.topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; }.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }.two-column,.two-column.wide-left { grid-template-columns: minmax(0, 1fr); }.form-grid.three,.form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }.filter-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }.label-sheet { grid-template-columns: repeat(3, 32mm); } }
@media (max-width: 650px) { .container { padding: 18px 12px; }.page-heading { display: grid; }.account span { display: none; }.label-sheet { grid-template-columns: repeat(2, 32mm); }.hose-label { height: 18mm; }.selection-spacer { display: none; }.compact-label { width: 100%; align-items: stretch; flex-direction: column; }.compact-label select { width: 100%; } }
@media print {
  @page { size: letter portrait; margin: 0.4in; }
  body { background: white; margin: 0; padding: 0; }
  .no-print, .alert { display: none !important; }
  .worksheet-page { margin: 0; padding: 0; border: 0; width: 100%; height: auto; min-height: 0; box-shadow: none; }
  .report-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 8pt; }
  .report-table thead { display: table-header-group; }
  .report-table tfoot { display: table-footer-group; }
  .report-table thead tr, .report-table tfoot tr { page-break-inside: avoid; }
  .report-table tbody tr { page-break-inside: avoid; }
  .report-table th, .report-table td { border: 1px solid #111; padding: 2px 3px; text-align: center; vertical-align: top; height: auto; min-height: 16px; }
  .report-table td.repair-detail-cell { border-top: 0; background: #f2f4f7; text-align: left; padding: 3px 6px; }
  .report-table tr.repair-detail { page-break-before: avoid; }
  .report-table th { font-size: 7pt; background: white; text-transform: none; letter-spacing: 0; color: #111; }
  .report-table th.report-title { border: 0; padding: 0 0 4px; }
  .report-table th.report-title h1 { font-size: 18pt; margin: 0; text-align: center; }
  .report-table tr.report-meta th { font-weight: normal; text-align: left; border: 0; padding: 0 0 2px; font-size: 9pt; }
  .report-table th.report-sub { font-weight: normal; border: 0; padding: 0 0 4px; font-size: 8.5pt; }
  .report-table th.report-sub span { border-bottom: 1px solid #111; display: block; padding-bottom: 2px; }
  .report-table td { white-space: pre-wrap; word-break: break-word; font-size: 8pt; }
  .report-table .text-left { text-align: left; }
  .report-table .report-footer { font-size: 7pt; border: 0; padding: 4px 0 0; }
  .label-sheet { padding: 8mm; }
  .hose-label { break-inside: avoid; }
  body.label-print-view { width: 32mm; min-width: 32mm; margin: 0; padding: 0; }
  body.label-print-view .print-main { width: 32mm; min-width: 32mm; margin: 0; padding: 0; }
  body.label-print-view .label-sheet { display: block; width: 32mm; margin: 0; padding: 0; }
  body.label-print-view .hose-label {
    width: 32mm;
    height: 18mm;
    margin: 0;
    padding: 2mm 1mm;
    border: 0;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 14mm 1fr;
    gap: 1mm;
    align-items: center;
    overflow: hidden;
    break-inside: avoid;
    break-after: page;
    page-break-after: always;
  }
  body.label-print-view .hose-label:last-child { break-after: auto; page-break-after: auto; }
  body.label-print-view .hose-label img { width: 14mm; height: 14mm; }
  body.label-print-view .hose-label strong { font-size: 7.5pt; line-height: 1; }
}

.btn.danger { background: var(--bad); border-color: var(--bad); color: white; }
.btn.danger:hover { background: #912018; border-color: #912018; }
.quick-test-panel { margin-bottom: 22px; }
.quick-test-actions { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.quick-pass-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.result-actions { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.quick-pass { background: var(--good); border-color: var(--good); color: white; }
.quick-pass:hover { background: #05603a; border-color: #05603a; }
.quick-fail summary { list-style: none; }
.quick-fail summary::-webkit-details-marker { display: none; }
.collapsed-failure summary { list-style: none; cursor: pointer; }
.collapsed-failure summary::-webkit-details-marker { display: none; }
.test-table tbody tr { position: relative; }
.quick-fail { position: static; }
.quick-fail-form { position: absolute; left: 0; right: 0; top: 100%; width: 100%; max-width: none; margin-top: 2px; padding: 18px; border: 1px solid #fda29b; border-radius: 8px; background: #fffafa; box-sizing: border-box; z-index: 20; }
.failure-reasons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; border: 0; padding: 0; margin: 0; }
.failure-reasons .reason-group { display: flex; flex-direction: column; gap: 4px; }
.failure-reasons .reason-group strong { font-size: .85rem; color: #475467; margin-bottom: 2px; }
.failure-reasons .check-line { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.failure-reasons .jacket-leak-location { display: block; margin-top: 10px; font-size: .85rem; }
.failure-reasons .jacket-leak-location input { width: 100%; box-sizing: border-box; }
.danger-zone { border-color: #fda29b; background: #fffafa; }
.danger-zone.inset { border: 1px solid #fda29b; border-radius: 8px; padding: 16px; }
.danger-zone h2, .danger-zone h3 { color: #912018; }
.selection-spacer { flex: 1 1 auto; }
.compact-label { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.compact-label select { width: auto; min-width: 180px; }
.bulk-action-target input { width: auto; min-width: 160px; }
.label-guidance { margin: 12px 18px 0; max-width: 900px; color: #475467; }

/* Phone/tablet refinements */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.1rem; }
  table { font-size: .9rem; }
  table th { white-space: normal; }
  table td { overflow-wrap: break-word; }
  th, td { padding: 8px; }

  /* Topbar collapses behind a hamburger toggle */
  .topbar { justify-content: space-between; gap: 12px; }
  .menu-toggle-label { display: inline-flex; align-items: center; color: white; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
  .menu-toggle-label:hover { background: rgba(255,255,255,.12); }
  .topbar nav, .topbar .account { display: none; flex-basis: 100%; }
  .topbar nav { flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; order: 4; }
  .topbar .account { justify-content: center; gap: 12px; order: 5; }
  #menu-toggle:checked ~ nav, #menu-toggle:checked ~ .account { display: flex; }

  /* Grids stack to a single, non-overflowing column */
  .form-grid.two, .form-grid.three, .form-grid.four,
  .filter-bar, .two-column, .two-column.wide-left,
  .metric-grid, .session-list a { grid-template-columns: minmax(0, 1fr); }
  .session-list a { gap: 6px; padding: 14px; align-items: flex-start; }
  .session-list a .badge { justify-self: start; }

  /* Page/panel headings and action rows go full width */
  .page-heading { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-heading .actions { width: 100%; justify-content: flex-start; }
  .page-heading .actions .btn, .page-heading .actions form { flex: 1 1 auto; min-width: 120px; width: auto; }
  .panel-heading { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .panel form .btn { width: 100%; display: flex; }
  .actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .actions form, .actions .btn { flex: 1 1 auto; min-width: 120px; }

  /* Table cards: converts .stack-table into label/value rows instead of horizontal scroll */
  .table-wrap { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stack-table.table-wrap, .table-wrap:has(.stack-table) { overflow-x: visible; }
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 4px 12px; background: white; }
  .stack-table tr:last-child { margin-bottom: 0; }
  .stack-table td { border-bottom: 1px solid #f2f4f7; padding: 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right; }
  .stack-table td:last-child { border-bottom: 0; }
  .stack-table td[data-label]::before { content: attr(data-label); font-weight: 650; color: #475467; text-align: left; margin-right: auto; }
  .stack-table td[data-label=""]::before { content: none; }
  .stack-table td .btn { width: auto; }
  .inventory-table th:nth-child(3), .inventory-table td:nth-child(3), .inventory-table th:nth-child(4), .inventory-table td:nth-child(4), .inventory-table th:nth-child(5), .inventory-table td:nth-child(5), .inventory-table th:nth-child(6), .inventory-table td:nth-child(6) { display: none; }
  .asset-meta-length { display: block; }

  /* Test worksheet: convert .test-table rows into compact hose cards */
  .table-wrap:has(.test-table) { overflow-x: visible; }
  .test-table thead { display: none; }
  .test-table, .test-table tbody, .test-table tr { display: block; width: 100%; box-sizing: border-box; }
  .test-table tbody tr { position: relative; }
  .test-table tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 6px 12px; background: white; }
  .test-table tr:last-child { margin-bottom: 0; }
  .test-table td { border-bottom: 1px solid #f2f4f7; padding: 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: right; min-width: 0; }
  .test-table td:last-child { border-bottom: 0; }
  .test-table td[hidden] { display: none !important; }
  .test-table td[data-label]::before { content: attr(data-label); font-weight: 650; color: #475467; text-align: left; margin-right: auto; }
  .test-table td:nth-child(4), .test-table td:nth-child(5), .test-table td:nth-child(6) { display: inline-block; border: 0; padding: 0 12px 6px 0; vertical-align: middle; }
  .test-table td:nth-child(6) { padding-right: 0; }
  .test-table td:nth-child(4)::before, .test-table td:nth-child(5)::before, .test-table td:nth-child(6)::before { content: attr(data-label) ": "; }
  .test-table td:nth-child(7), .test-table td:nth-child(8) { flex-wrap: wrap; }
  .test-table td:nth-child(7) .result-actions, .test-table td:nth-child(8) .collapsed-failure { width: 100%; }

  /* Toolbars, tools, and result rows stack and stretch */
  .sticky-actions, .test-toolbar, .selection-tools,
  .quick-pass-form { flex-direction: column; align-items: stretch; }
  .sticky-actions { padding: 12px; }
  .sticky-actions .btn { width: 100%; }
  .test-toolbar { background: white; flex-direction: row; flex-wrap: wrap; }
  .test-toolbar label { flex: 1 1 auto; width: auto; min-width: 0; }
  .test-toolbar label input { width: 100%; }
  .scan-tools { flex: 1 1 100%; margin-left: 0; }
  .scan-tools input[type=search] { flex: 1 1 auto; min-width: 0; width: auto; }
  .test-toolbar .switch { flex: 0 0 auto; width: 40px; }
  .selection-tools { gap: 12px; }
  .selection-tools .compact-label,
  .selection-tools .btn { width: 100%; }
  .selection-tools .compact-label select,
  .selection-tools .compact-label input { width: 100%; }
  .quick-test-actions { flex-direction: row; align-items: flex-end; gap: 10px; }
  .quick-test-actions > .quick-pass-form, .quick-test-actions > .quick-fail { flex: 1 1 0; min-width: 0; }
  .quick-pass-form label, .quick-pass-form select, .quick-pass-form button { width: 100%; }
  .quick-fail { position: static; }
  .quick-fail-form { position: fixed; left: 4%; right: 4%; top: 4%; bottom: 4%; width: auto; max-width: none; margin: 0; overflow-y: auto; z-index: 100; }
  .quick-fail summary.btn { display: flex; width: 100%; }
  .failure-reasons { grid-template-columns: repeat(2, 1fr); }
  .result-actions { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 8px; }
  .result-actions > .btn, .result-actions > details { flex: 1 1 0; min-width: 0; width: auto; }
  .result-actions .btn { display: flex; }
  .result-actions > details > summary.btn { width: 100%; height: 100%; }

  /* Import/print controls and tabs */
  .import-date-options { grid-template-columns: auto 1fr; gap: 12px 8px; }
  .import-date-options .text-cell { align-items: flex-start; }
  .print-controls { justify-content: center; gap: 8px; }
  .print-controls .btn, .print-controls label, .print-controls select { flex: 1 1 auto; min-width: 120px; }
  .tabs a { padding: 10px 12px; font-size: .9rem; }
  .auth-card { margin: 4vh auto; padding: 22px; }
}
