/* Saki - Smart Checker. Light and plain: the logo's blue and red on white, thin borders, no gradients.
   Big clear buttons stay big: staff use this on the shop floor. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #1b2533;
  --muted: #5f6b7c;
  --border: #dde2e9;
  --border-strong: #c7ced8;
  --accent: #24406f;       /* logo blue */
  --accent-dark: #1a3157;
  --accent-soft: #edf1f8;
  --brand-red: #b85a5a;    /* logo red lines */
  --pass: #157f3b;
  --pass-bg: #e6f4ea;
  --fail: #b42318;
  --fail-bg: #fdebe9;
  --amber: #8a5a00;
  --amber-bg: #fff3d6;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
}

/* --- header: white, logo blue text, red rule like the logo's lines --- */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 32px;
  padding: 0 max(16px, calc((100vw - 1100px) / 2 + 16px));
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 -3px 0 var(--brand-red);
}
header a { color: var(--accent); text-decoration: none; }
header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--accent); }
header .brand img { height: 38px; width: auto; }
header nav { display: flex; flex-wrap: wrap; align-self: stretch; gap: 4px; font-size: 15px; }
header nav a { display: flex; align-items: center; padding: 0 12px; color: var(--text); font-weight: 500; border-bottom: 3px solid transparent; }
header nav a:hover { color: var(--accent); background: var(--surface-2); }
header nav a.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
header .new-part { margin-left: auto; padding: 8px 16px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 26px; line-height: 1.25; font-weight: 700; color: var(--accent); margin: 4px 0 18px; }
h2 { font-size: 18px; font-weight: 600; color: var(--text); margin: 28px 0 10px; }
h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 18px 0 8px; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row label { flex: 1 1 160px; }

label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 64, 111, 0.15); }
input[type=file] { padding: 7px; background: var(--surface-2); cursor: pointer; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; margin-right: 10px; padding: 5px 12px; color: var(--accent);
  background: var(--surface); border: 1px solid var(--accent); border-radius: 5px; cursor: pointer; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }
input.good { border-color: var(--pass); background: var(--pass-bg); }
input.bad { border-color: var(--fail); background: var(--fail-bg); }

button, .button {
  display: inline-block;
  padding: 9px 18px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
button:focus-visible, .button:focus-visible { outline: 3px solid rgba(36, 64, 111, 0.3); outline-offset: 2px; }
button.link { padding: 0; background: none; border: 0; color: var(--fail); font-weight: 400; }
button.link:hover { background: none; color: var(--fail); text-decoration: underline; }
.row button { margin-bottom: 12px; }
button.secondary, .button.secondary { color: var(--accent); background: var(--surface); border-color: var(--accent); }
button.secondary:hover, .button.secondary:hover { background: var(--accent-soft); color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.danger { background: var(--fail); border-color: var(--fail); }
button.danger:hover { background: #8f1c13; border-color: #8f1c13; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td input { margin: 0; max-width: 160px; }
td form { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
}
.stat span { display: block; font-size: 28px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.badge.pass { color: var(--pass); background: var(--pass-bg); }
.badge.fail { color: var(--fail); background: var(--fail-bg); }
.badge.training { color: var(--amber); background: var(--amber-bg); }
.learning-note { background: var(--amber-bg); border-color: #f0d9a0; color: #4a3500; }
.badge.todo { color: #475467; background: #eaecf0; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.ok { color: var(--pass); background: var(--pass-bg); border-color: #bfe3cb; }
.flash.error { color: var(--fail); background: var(--fail-bg); border-color: #f5c2bc; }
.flash.training { color: var(--amber); background: var(--amber-bg); border-color: #f0dca6; }

.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px; text-align: center; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; display: block; margin-bottom: 4px; }
.gallery form { margin: 0; }

.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.compare figure { margin: 0; }
.compare img { width: 100%; border-radius: 6px; border: 1px solid var(--border); display: block; }
.compare figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }

label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
label.check input { width: auto; margin: 0; }
.findings { margin: 0 0 12px; padding-left: 20px; }
.findings li { margin-bottom: 4px; }
.card > h2 .badge { vertical-align: middle; }

.verdict { text-align: center; }
.verdict-label { font-size: 44px; font-weight: 800; letter-spacing: 0.5px; line-height: 1.15; }
.verdict.pass { border-color: var(--pass); background: var(--pass-bg); color: var(--pass); }
.verdict.fail { border-color: var(--fail); background: var(--fail-bg); color: var(--fail); }
.verdict p { color: var(--text); margin: 6px 0 0; }
figure.single { margin: 0 0 16px; }
figure.single img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); display: block; }
figure.single figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.small { font-size: 13px; }

.danger-zone { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.ai-summary { border-left: 4px solid var(--accent); }
.ai-summary h2 { margin-bottom: 4px; }
.ai-summary ul { margin: 6px 0; padding-left: 20px; }
.ai-summary li { margin-bottom: 4px; }
.ai-summary.inline { background: var(--surface-2); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.ai-summary p { margin: 4px 0; }

.side-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 12px 0; border-bottom: 1px solid var(--border); }
.side-row label { flex: 1 1 200px; margin-bottom: 0; }
.side-row label.check { flex: 0 0 auto; padding-bottom: 8px; }
.side-row .remove-side { padding-bottom: 10px; }

/* --- layout helpers --- */
.crumbs { margin: 0; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.title-row h1 { margin-bottom: 8px; }
.title-row h1 .badge { vertical-align: middle; margin-left: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.title-row .actions { margin-bottom: 0; }
button.big, .button.big { padding: 12px 24px; font-size: 16px; }
.warn { color: var(--amber); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
.card.empty { text-align: center; padding: 32px 16px; }

/* collapsible sections */
details > summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 12px; }
details.danger-zone { display: block; }
details.danger-zone > summary { color: var(--fail); font-weight: 500; }

/* sides on the part page */
.side .side-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.side h3 { margin: 0; font-size: 17px; }
.side-link { margin-left: auto; font-size: 14px; }
.meter { height: 8px; background: #e8ebf0; border-radius: 4px; overflow: hidden; margin: 4px 0; }
.meter div { height: 100%; background: var(--pass); }
.thumbs { display: flex; gap: 6px; margin: 10px 0 4px; overflow: hidden; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.side-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.side-actions form { margin: 0; }
form.upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.upload input[type=file] { width: auto; margin: 0; }

/* new-part form */
.step { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-right: 6px;
        border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 8px; }
.picked { display: block; margin-top: 4px; font-size: 13px; }

/* check page */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius);
        padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile:hover { border-color: var(--border-strong); border-top-color: var(--accent); }
.tile.disabled { opacity: 0.7; }
.tile.quick { border-top-color: var(--brand-red); }
.tile-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.tile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 10px; }
label.photo-pick { color: var(--text); font-size: 15px; font-weight: 600; }
label.photo-pick .muted { font-weight: 400; font-size: 13px; }

/* Identify part */
.verdict.unsure { border-color: var(--border); }
.match-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.match-photo { margin: 0; }
.match-photo img, .tile.match img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.match-photo figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.confirm-actions form { margin: 0; }
.inline-pick { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-pick select { max-width: 100%; }

/* Part recognition */
.meter.wide { width: 100%; max-width: none; }

/* CAD inspection */
.side-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.side-pick { display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.side-pick img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #f1f3f6; }
.side-pick input[type=file] { width: 100%; margin: 4px 0 0; }
.verdict.outcome-ok { border-color: var(--pass); background: var(--pass-bg); color: var(--pass); }
.verdict.outcome-rework { border-color: #b7791f; background: var(--amber-bg); color: var(--amber); }
.verdict.outcome-hold { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.verdict.outcome-scrap { border-color: var(--fail); background: var(--fail-bg); color: var(--fail); }
.report-points li { margin-bottom: 8px; }
table.rules td { vertical-align: top; }
table.rules textarea { width: 100%; min-width: 220px; }
.weld-crops { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.weld-crop { margin: 0; border: 2px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.weld-crop img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.weld-crop figcaption { padding: 6px 8px; font-size: 13px; }
.weld-crop.bad { border-color: var(--fail); }
.weld-crop.bad figcaption strong { color: var(--fail); }
.weld-crop.good figcaption strong { color: var(--pass); }
.review-row { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.review-text { flex: 1 1 280px; }
.choice { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: normal; }
.choice input { width: auto; margin: 0; }
.review .row { margin-top: 12px; }

/* Full-screen photo viewer (base.html) */
main img:not(.no-zoom) { cursor: zoom-in; }
label img, a img { cursor: default; }
.viewer { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 16, 0.92); display: flex; flex-direction: column; }
.viewer[hidden] { display: none; }
.viewer-bar { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; }
.viewer-bar button { min-width: 44px; background: rgba(255, 255, 255, 0.14); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25); }
.viewer-stage { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-drag: none; cursor: zoom-in; }
.delete-inspection { margin: 24px 0 8px; }
.delete-inspection button { width: 100%; max-width: 360px; }

/* 3D CAD viewer (static/viewer3d.js) */
.viewer3d { display: grid; grid-template-columns: 1fr 300px; gap: 12px; align-items: start; margin-bottom: 16px; }
.viewer3d-solo { grid-template-columns: 1fr; }
.viewer3d-stage { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #eef1f5; }
.viewer3d-canvas { height: 70vh; min-height: 360px; touch-action: none; }
.viewer3d-canvas canvas { display: block; }
.viewer3d-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.viewer3d-msg[hidden], .viewer3d-picked[hidden], .viewer3d-explode[hidden] { display: none; }
.viewer3d-picked { position: absolute; top: 10px; left: 10px; max-width: 70%; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
.viewer3d-tools { position: absolute; bottom: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.viewer3d-tools button { padding: 6px 12px; }
.viewer3d-explode { display: flex; align-items: center; gap: 6px; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; color: var(--text); }
.viewer3d-explode input { width: 120px; margin: 0; }
.viewer3d-list { max-height: 70vh; overflow: auto; margin: 0; }
.viewer3d-list ul { list-style: none; padding: 0; margin: 0; }
.viewer3d-list li { display: flex; align-items: baseline; gap: 6px; padding: 3px 4px; border-radius: 4px; }
.viewer3d-list li.on { background: #f8e9e9; }
.viewer3d-list li input[type=checkbox] { width: auto; margin: 0; flex: none; }
.viewer3d-list .comp-name { flex: 1; min-width: 0; }
.viewer3d-list li .small { flex: none; }
.viewer3d-list .swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; background: var(--border); }
.viewer3d.short .viewer3d-canvas { height: 50vh; }
.tile.pickable { cursor: pointer; }
.tile.pickable.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.fault-link { white-space: nowrap; }
@media (max-width: 800px) {
  .viewer3d { grid-template-columns: 1fr; }
  .viewer3d-canvas { height: 60vh; }
  .viewer3d-list { max-height: 50vh; }
}

/* QUICK INSPECT: teaching the model (quick.html) */
.teach h3 { margin: 18px 0 6px; font-size: 16px; }
.teach .weld-crop select { width: 100%; margin-top: 6px; font-size: 13px; }
.draw-photo { position: relative; display: inline-block; max-width: 100%; line-height: 0; user-select: none; }
.draw-photo img { max-width: 100%; display: block; }
.draw-photo.drawing { cursor: crosshair; touch-action: none; outline: 3px solid #1f6feb; }
.drawn-box { position: absolute; border: 3px solid #1f6feb; background: rgba(31, 111, 235, 0.12); color: #1f6feb;
  font: bold 15px/1 sans-serif; padding: 2px 4px; pointer-events: none; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.missed-list li { margin: 6px 0; }
.missed-list select { width: auto; display: inline-block; margin-right: 6px; }
.small-button { padding: 4px 10px; font-size: 13px; }

/* QUICK INSPECT analysing screen */
.analysing { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(244, 246, 249, 0.94); padding: 16px; }
.analysing[hidden] { display: none; }
.analysing-box { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--brand-red);
  border-radius: var(--radius); padding: 28px 24px; max-width: 420px; width: 100%; text-align: center; }
.analysing-box img { display: block; max-width: 100%; max-height: 220px; margin: 0 auto 18px; border-radius: 4px; }
.analysing-spinner { width: 40px; height: 40px; margin: 0 auto 14px; border: 4px solid var(--accent-soft);
  border-top-color: var(--accent); border-radius: 50%; animation: analysing-spin 0.9s linear infinite; }
.analysing-title { font-size: 20px; font-weight: 600; color: var(--accent); margin: 0 0 6px; }
.analysing-box p { margin: 4px 0; }
@keyframes analysing-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .analysing-spinner { animation-duration: 3s; } }

/* Camera station (station_run.html): live cameras with marks drawn over the video */
.station-bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; padding: 14px; }
.station-verdict { flex: 1 1 280px; margin: 0; padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius); }
.station-verdict .verdict-label { font-size: 36px; }
.station-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; align-content: center; }
.station-actions .big { padding: 16px 28px; font-size: 18px; }
.inline-check { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; color: var(--text); }
.inline-check input { width: auto; margin: 0; }
.slot-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.slot-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.slot-row select { width: auto; flex: 1 1 200px; margin: 0; }
.live-grid { margin-bottom: 16px; }
.live-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.live-tile.broken { border-color: var(--fail); }
.live-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.live-guide { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); cursor: zoom-in; }
.live-status { margin-left: auto; text-align: right; }
.live-stage { position: relative; aspect-ratio: 16 / 9; background: #11161d; }
.live-stage video, .live-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.live-stage video { object-fit: contain; }
.live-stage canvas { pointer-events: none; }
.live-badge { position: absolute; top: 8px; right: 8px; padding: 3px 10px; border-radius: 5px; font-weight: 700; font-size: 14px; color: #fff; }
.live-badge:empty { display: none; }
.live-badge.ok { background: var(--pass); }
.live-badge.rework { background: #b7791f; }
.live-badge.hold { background: var(--accent); }
.live-badge.scrap { background: var(--fail); }
.live-badge.none { background: rgba(17, 22, 29, 0.7); }
.findings-list { margin: 0; padding-left: 20px; }
.findings-list li { margin: 6px 0; }
figure.side-pick { margin: 0; }
/* Station setup: number of cameras and a preview of the layout it gives */
.count-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.count-option { margin: 0; cursor: pointer; }
.count-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.count-option span { display: flex; align-items: center; justify-content: center; width: 64px; height: 56px; font-size: 24px;
  font-weight: 700; color: var(--accent); background: var(--surface); border: 2px solid var(--border-strong); border-radius: var(--radius); }
.count-option input:checked + span { color: #fff; background: var(--accent); border-color: var(--accent); }
.count-option input:focus-visible + span { outline: 3px solid rgba(36, 64, 111, 0.3); outline-offset: 2px; }
.count-option.off { cursor: not-allowed; opacity: 0.35; }
.count-mode { font-size: 15px; color: var(--text); margin: 4px 0 10px; }
.layout-preview, .live-grid { display: grid; gap: 12px; }
.layout-preview { margin-bottom: 20px; max-width: 760px; }
.layout-cam { display: flex; flex-direction: column; gap: 4px; justify-content: center; align-items: center; text-align: center;
  aspect-ratio: 16 / 9; padding: 8px; background: var(--surface-2); border: 2px dashed var(--border-strong); border-radius: var(--radius); }
.layout-cam img { max-height: 55%; max-width: 70%; object-fit: contain; border-radius: 4px; }
/* Same arrangement on the setup preview and the live page: 1 large, 2 side by side, 3 in a row, 4 as 2x2, 5 as 3 + 2 */
.layout-preview[data-count="1"], .live-grid[data-count="1"] { grid-template-columns: 1fr; }
.layout-preview[data-count="2"], .live-grid[data-count="2"],
.layout-preview[data-count="4"], .live-grid[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.layout-preview[data-count="3"], .live-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.layout-preview[data-count="5"], .live-grid[data-count="5"] { grid-template-columns: repeat(6, 1fr); }
.layout-preview[data-count="5"] > *, .live-grid[data-count="5"] > * { grid-column: span 2; }
.layout-preview[data-count="5"] > :nth-child(4), .live-grid[data-count="5"] > :nth-child(4) { grid-column: 2 / span 2; }
.live-grid[data-count="1"] .live-stage { max-height: 72vh; }
.live-grid[data-count="1"] { max-width: calc(72vh * 16 / 9); margin-left: auto; margin-right: auto; width: 100%; }
/* One camera, several sides: side buttons on the camera and the kept sides */
.live-sides { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.live-sides[hidden], .live-foot[hidden] { display: none; }
.live-sides button { padding: 8px 14px; font-size: 15px; }
.live-foot { padding: 8px 10px; border-top: 1px solid var(--border); }
.live-foot .keep-btn { width: 100%; padding: 12px; font-size: 16px; }
.kept-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.kept { margin: 0; padding: 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.kept.done { border-style: solid; border-color: var(--pass); background: var(--pass-bg); }
.kept img, .kept-empty { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; }
.kept-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; background: var(--surface); }
.kept figcaption { margin-top: 6px; }
@media (max-width: 760px) {
  .live-grid[data-count] { grid-template-columns: 1fr; }
  .live-grid[data-count] > * { grid-column: auto !important; }
}
@media (max-width: 600px) {
  .station-verdict .verdict-label { font-size: 28px; }
}

/* footer (base.html) */
.site-foot { max-width: 1068px; margin: 0 auto; padding: 16px 0 28px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

@media (max-width: 1100px) { .site-foot { margin: 0 16px; } }
@media (max-width: 600px) {
  table { display: block; overflow-x: auto; }
  header { padding-top: 8px; gap: 4px 12px; }
  header nav { order: 3; width: 100%; min-height: 44px; }
  header .new-part { padding: 6px 12px; font-size: 14px; }
  h1 { font-size: 22px; }
  .verdict-label { font-size: 32px; overflow-wrap: anywhere; }
  .card { padding: 16px; }
  main { overflow-wrap: anywhere; }
}

/* --- phone check (/mobile): one phone camera, the user picks the side ------------------------------------- */
.m-body { margin: 0; background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
.m-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.m-brand img { height: 30px; display: block; }
.m-part { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; margin: 0; }
.m-part-label { font-size: 13px; color: var(--muted); }
.m-part select { flex: 1; min-width: 0; font-size: 15px; padding: 8px; margin: 0; }
.m-verdict { margin: 8px 12px; padding: 8px 12px; border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-align: center; }
.m-verdict-label { font-size: 28px; font-weight: 800; line-height: 1.1; }
.m-verdict-note { font-size: 13px; margin-top: 2px; opacity: 0.85; }
.m-stage { position: relative; background: #000; height: 56svh; min-height: 260px; }
.m-stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.m-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.m-guide { position: absolute; top: 8px; right: 8px; width: 68px; opacity: 0.9; padding: 3px; margin: 0; border-radius: 6px;
  background: rgba(255, 255, 255, 0.92); border: 1px solid var(--border); color: var(--text); }
.m-guide img { width: 100%; display: block; border-radius: 4px; }
.m-guide span { display: block; font-size: 11px; font-weight: 600; text-align: center; padding-top: 2px; }
.m-msg { position: absolute; left: 12px; right: 12px; top: 40%; padding: 12px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 15px; text-align: center; }
.m-sides-head { margin: 10px 12px 4px; font-size: 14px; font-weight: 600; }
.m-sides { display: flex; gap: 8px; overflow-x: auto; padding: 2px 12px 6px; scroll-snap-type: x proximity; }
.m-side { flex: 0 0 auto; width: 96px; padding: 4px; margin: 0; scroll-snap-align: center; border-radius: var(--radius);
  background: var(--surface); color: var(--text); border: 2px solid var(--border); font-weight: 600; font-size: 13px; }
.m-side img { width: 100%; height: 64px; object-fit: contain; display: block; background: var(--surface-2); border-radius: 4px; }
.m-side span { display: block; padding-top: 3px; }
.m-side.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.m-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 12px; }
.m-controls button { margin: 0; }
.m-main { padding: 0 12px 16px; }
.m-h2 { font-size: 16px; margin: 10px 0 4px; }
.m-findings { margin: 0 0 8px; padding-left: 20px; }
.m-findings li { margin: 3px 0; }
.m-zoom { position: fixed; inset: 0; z-index: 20; background: rgba(14, 18, 26, 0.85); display: flex;
  flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.m-zoom[hidden] { display: none; }
.m-zoom img { max-width: 100%; max-height: 70svh; background: #fff; border-radius: var(--radius); }
.m-zoom p { color: #fff; text-align: center; }
/* phones keep :hover after a tap: only the chosen side looks chosen */
.m-side:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.m-side.on, .m-side.on:hover { border-color: var(--accent); background: var(--accent); color: #fff; }
.m-guide:hover { background: rgba(255, 255, 255, 0.92); color: var(--text); }
.m-warn { margin: 0 0 8px; padding: 8px 10px; border-radius: 6px; background: var(--amber-bg); color: var(--amber); font-size: 13px; }

/* --- sign in ---------------------------------------------------------------------------------------------- */
.login-body { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; }
.login-card { width: 100%; max-width: 360px; box-sizing: border-box; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--accent); font-size: 18px; }
.login-brand img { height: 38px; }
.login-btn { width: 100%; margin-top: 4px; }
header .signout { display: flex; align-items: center; gap: 8px; margin: 0; }
header .signout button { padding: 6px 12px; }
.m-top form { margin: 0; }
.m-signout { padding: 7px 10px; font-size: 13px; white-space: nowrap; }
