:root {
  /* VIA family palette — navy / signal blue / amber on light (matches VIA Scout) */
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel2: #f7fafc;
  --line: #e2e8f0;
  --text: #1a202c;
  --navy: #14304a;
  --muted: #718096;
  --accent: #2b6cb0;
  --accent2: #2b6cb0;
  --amber: #f5a623;
  --ok: #2f855a;
  --warn: #c05621;
  --err: #c53030;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
header {
  position: sticky; top: 0; z-index: 10;
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
  padding: env(safe-area-inset-top) 12px 0;
}
.brandline { display: flex; align-items: center; gap: 9px; padding: 10px 4px 8px; }
.brandmark { flex: 0 0 auto; }
header h1 { font-size: 19px; margin: 0; font-weight: 600; color: var(--accent); letter-spacing: .2px; }
header h1 .via { color: var(--navy); font-weight: 800; }
.tech-input { margin-left: auto; width: 108px; font-size: 12px; padding: 5px 9px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); }
.tech-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.help-link { margin-left: 8px; font-size: 12px; color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); border-radius: 16px; padding: 5px 11px; white-space: nowrap;
  background: var(--panel); cursor: pointer; font-weight: 600; }
.help-link:hover { color: var(--text); border-color: var(--accent); }

/* help modal — cross-links as buttons at the top */
.help-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.help-btn { font-size: 13px; padding: 9px 14px; border-radius: 9px; text-decoration: none;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-weight: 600; }
.help-btn:hover { border-color: var(--accent); }
.help-btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
nav#steps { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px; }
nav#steps span {
  white-space: nowrap; font-size: 12px; color: var(--muted);
  padding: 5px 9px; border-radius: 20px; background: var(--panel2);
  border: 1px solid var(--line);
}
nav#steps span.active { color: #fff; background: var(--accent2); border-color: var(--accent2); }
nav#steps span.done { color: var(--ok); border-color: var(--ok); }

main { max-width: 760px; margin: 0 auto; padding: 16px 14px 60px; }
.step { display: none; }
.step.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1;transform:none;} }
h2 { margin: 4px 0 4px; font-size: 22px; color: var(--navy); }
.hint { color: var(--muted); margin: 0 0 14px; font-size: 14px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid label.wide, label.wide { grid-column: 1 / -1; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
input, select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 10px; font-size: 15px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.actions.inline { margin: 12px 0; flex-wrap: wrap; }
button, .filebtn, a.primary, a.ghost {
  font-size: 15px; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  border: 1px solid var(--line); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.primary:disabled { opacity: .4; cursor: not-allowed; }
.ghost { background: transparent; color: var(--text); }
.filebtn { background: var(--panel2); color: var(--text); }

.capture { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
video#cam { width: 100%; max-height: 340px; background: #000; border-radius: 10px; display: block; }
.capture-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

.qc { margin: 14px 0; padding: 12px 14px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.qc.pass { background: rgba(47,133,90,.10); border-color: var(--ok); color: var(--ok); }
.qc.fail { background: rgba(197,48,48,.08); border-color: var(--err); color: var(--err); }
.qc .metrics { color: var(--muted); font-size: 12px; margin-top: 6px; }

.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumbs figure { margin: 0; width: 104px; }
.thumbs img { width: 104px; height: 104px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.thumbs figcaption { font-size: 10px; color: var(--muted); margin-top: 3px; }
.thumbs .crop-btn { width: 100%; margin-top: 4px; padding: 5px; font-size: 12px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; }

/* dev toolbar */
#devbar { position: fixed; left: 10px; bottom: 10px; z-index: 90; display: flex; gap: 6px; align-items: center;
  background: var(--navy); border: 1px solid var(--amber); border-radius: 22px; padding: 5px 8px;
  box-shadow: 0 3px 12px rgba(20,48,74,.25); }
#devbar .devbar-label { color: var(--amber); font-size: 10px; font-weight: 700; letter-spacing: 1px; padding: 0 4px; }
#devbar button { font-size: 12px; padding: 6px 10px; border-radius: 16px; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.22); }
#devbar button:hover { border-color: var(--amber); }
#devbar .badge { background: var(--err); color: #fff; border-radius: 10px; padding: 0 5px; font-size: 10px; margin-left: 3px; }
#bug_modal textarea, #fix_modal textarea, #known_paste { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 10px; font-size: 15px; width: 100%; resize: vertical; }

/* bug modal: floating + draggable, doesn't block the app behind it */
#bug_modal.floatmodal { background: transparent; pointer-events: none; align-items: flex-start; }
#bug_modal.floatmodal .modal-box { pointer-events: auto; margin-top: 60px; box-shadow: 0 12px 40px rgba(20,48,74,.4); }
.drag-handle { cursor: move; user-select: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drag-hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.bug-shot { margin: 8px 0 4px; }
.bug-shot img { max-width: 100%; max-height: 220px; border: 1px solid var(--line); border-radius: 8px; display: block; }
.bug-shot button { margin-top: 6px; font-size: 12px; padding: 6px 10px; }

/* issues / change-log list */
.issue-list { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow: auto; }
.issue-list li { font-size: 13px; padding: 7px 2px; border-top: 1px solid var(--line); line-height: 1.5; }
.issue-list li:first-child { border-top: 0; }
.issue-list .empty { color: var(--muted); }
.issue-list em { color: var(--muted); font-style: italic; }
.issue-list .fixed { color: var(--ok); font-style: normal; }
.issue-list a { color: var(--accent); }
.modal-sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.matchrow { border-top: 1px solid var(--line); padding: 8px 0; }
.matchrow:first-child { border-top: 0; }
.matchrow.accepted { opacity: .5; }
.matchq { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.matchopts { display: flex; gap: 6px; flex-wrap: wrap; }
.matchopt { font-size: 12px; padding: 6px 10px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); cursor: pointer; }
.matchopt:hover { border-color: var(--accent); }
.matchopt small { color: var(--muted); }
.matchopt.asis { color: var(--muted); }

/* crop modal */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; }
.modal-box h3 { margin: 0 0 6px; }
.crop-stage { background: #000; border-radius: 10px; display: flex; justify-content: center;
  touch-action: none; user-select: none; }
#crop_canvas { max-width: 100%; cursor: crosshair; border-radius: 10px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
th { color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; }
td input, td select { padding: 6px; font-size: 13px; }
td.del button { padding: 6px 9px; background: transparent; color: var(--err); border-color: var(--line); }
/* low-confidence detections: amber tint + left rule so they're scrutinized */
tr.low-conf td { background: rgba(197,131,33,.10); }
tr.low-conf td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

.resume { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chips .chip { padding: 7px 12px; border-radius: 20px; font-size: 13px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
.chips .chip:hover { border-color: var(--accent); }
.chips .chip small { color: var(--muted); margin-left: 5px; }
.chips .chip-label { color: var(--muted); font-size: 12px; align-self: center; }
.chips .chip-x { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 0 0 0 6px; font-size: 13px; }
.chips .chip-x:hover { color: var(--err); }
.chips .chip-cat { background: transparent; border: 0; color: var(--accent); cursor: pointer; padding: 0 0 0 6px; font-size: 11px; }
.chips .chip-cat:hover { color: var(--ok); }
.knownbtn { font-size: 13px; padding: 8px 12px; margin-bottom: 14px; }

.status { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }

/* toggle switch */
.switch { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 22px; background: var(--panel2);
  border: 1px solid var(--line); position: relative; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s;
}
.switch input:checked + .track { background: var(--accent2); border-color: var(--accent2); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }

.cost {
  margin: 10px 0 0; padding: 10px 14px; border-radius: 10px; font-size: 14px;
  background: rgba(47,133,90,.08); border: 1px solid var(--ok); color: var(--ok);
}
.cost .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.validation { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; border: 1px solid; }
.validation.ok { background: rgba(47,133,90,.08); border-color: var(--ok); color: var(--ok); }
.validation.warn { background: rgba(197,131,33,.10); border-color: var(--warn); color: var(--warn); }
.validation.err { background: rgba(197,48,48,.08); border-color: var(--err); color: var(--err); }
.validation ul { margin: 8px 0 0; padding-left: 18px; }
.validation li { margin: 3px 0; color: var(--text); }
.validation li.error::marker { color: var(--err); }
.validation li.warning::marker { color: var(--warn); }
.spinner {
  width: 16px; height: 16px; flex: 0 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* full-width busy bar shown over the table area while the ML runs */
.detecting { position: relative; }
.overlay {
  display: none; position: absolute; inset: 0; z-index: 5;
  background: rgba(247,250,252,.82); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  border-radius: 10px; color: var(--navy); font-size: 14px; text-align: center; padding: 20px;
}
.detecting .overlay { display: flex; }
.overlay .spinner { width: 34px; height: 34px; border-width: 3px; }
button.busy { opacity: .7; cursor: progress; }
.warn { color: var(--warn); font-size: 13px; min-height: 16px; margin: 4px 0 0; }
.preview { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 12px; color: #2d3748; max-height: 340px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
