/* PACE — workshop-floor UI.
   Palette from the maintenance base: slate ink, brushed-steel greys, and inspection-tag yellow.
   The tag is the one bold element: it carries a job's status everywhere. */
:root {
  --ink: #1B2631;
  --ink-2: #3D4B58;
  --steel: #66788A;
  --line: #CBD3DA;
  --plate: #E7EBEE;
  --panel: #FFFFFF;
  --tag: #FFC72C;
  --tag-ink: #3B2E00;
  --go: #1E7A4C;
  --go-bg: #E3F2E9;
  --stop: #B8322A;
  --stop-bg: #FBE7E5;
  --warn: #8A5A00;
  --warn-bg: #FFF4D6;
  --focus: #2F6FDE;
  --radius: 6px;
  --radius-lg: 10px;
  --font: 'Barlow', system-ui, sans-serif;
  --font-c: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--plate); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-c); line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1em; max-width: 72ch; }
small, .muted { color: var(--steel); }
code, .mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: .9em; }

/* ── Top bar ── */
.topbar {
  background: var(--ink); color: #fff;
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; }
.brand-name { font-family: 'Montserrat', var(--font-c); font-weight: 700; font-size: 1.3rem; letter-spacing: .08em; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  color: #C9D3DC; text-decoration: none; padding: 8px 12px; border-radius: var(--radius);
  font-weight: 500; white-space: nowrap;
}
.nav a:hover, .nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.1); }
.nav .count {
  display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 11px;
  background: var(--tag); color: var(--tag-ink); font-size: .8rem; font-weight: 700; text-align: center;
}
.who { color: #C9D3DC; font-size: .9rem; white-space: nowrap; }
.who a { color: #fff; margin-left: 10px; }

.demo-strip {
  background: var(--warn-bg); color: var(--warn); font-size: .88rem; padding: 6px 24px;
  border-bottom: 1px solid #F0DFA8;
}

main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.narrow { max-width: 720px; }

/* ── Page head ── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--ink-2); }

/* ── Panels ── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-flush { padding: 0; overflow: hidden; }
.panel h2 { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* ── The tag: job status ── */
.tag {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 12px 3px 22px; border-radius: 4px 12px 12px 4px;
  font-family: var(--font-c); font-weight: 600; font-size: .9rem; white-space: nowrap;
  background: var(--plate); color: var(--ink-2); border: 1px solid var(--line);
}
.tag::before {  /* punched hole */
  content: ''; position: absolute; left: 7px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border-radius: 50%; background: var(--panel); box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.25);
}
.tag-pending_review { background: var(--tag); color: var(--tag-ink); border-color: #E5AE10; }
.tag-approved { background: var(--go); color: #fff; border-color: var(--go); }
.tag-returned, .tag-failed { background: var(--stop); color: #fff; border-color: var(--stop); }
.tag-processing, .tag-queued { background: #DCE6F4; color: #1D3F73; border-color: #B8CBE6; }
.tag-started { background: #fff; }
.tag-lg { font-size: 1.15rem; padding: 6px 18px 6px 30px; }
.tag-lg::before { left: 10px; width: 11px; height: 11px; margin-top: -5.5px; }

/* ── Buttons & forms ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius); border: 1px solid var(--ink);
  background: var(--panel); color: var(--ink); font: 600 1rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--plate); color: var(--ink); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); color: #fff; }
.btn-go { background: var(--go); border-color: var(--go); color: #fff; }
.btn-go:hover { background: #17633D; color: #fff; }
.btn-stop { color: var(--stop); border-color: var(--stop); }
.btn-big { min-height: 64px; font-size: 1.2rem; padding: 14px 26px; width: 100%; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { display: block; font-weight: 400; color: var(--steel); font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #AEB9C3; border-radius: var(--radius);
  font: 400 1rem var(--font); color: var(--ink); background: #fff;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input.big { font-size: 1.5rem; font-family: var(--font-c); font-weight: 600; letter-spacing: .03em; min-height: 60px; }
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }

/* ── Flash ── */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash-ok { background: var(--go-bg); border-color: #B5DCC5; color: #134D30; }
.flash-error { background: var(--stop-bg); border-color: #F0BDB8; color: #7C1F19; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid #E2E7EB; vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); font-size: .9rem; background: #F5F7F8; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFBFC; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; }

/* ── Stats ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; text-decoration: none; }
.stat b { display: block; font-family: var(--font-c); font-size: 2rem; line-height: 1.1; }
.stat span { color: var(--ink-2); }
.stat.attention { border-color: #E5AE10; box-shadow: inset 4px 0 0 var(--tag); }

/* ── Steps (SWI) ── */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.steps li { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid #E2E7EB; }
.steps li:last-child { border-bottom: 0; }
.step-no {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-c); font-weight: 700; background: var(--plate); color: var(--ink);
}
.step-confirmed .step-no { background: var(--go); color: #fff; }
.step-missing .step-no { background: var(--stop); color: #fff; }
.step-uncertain .step-no { background: var(--tag); color: var(--tag-ink); }
.step-text { font-weight: 500; }
.step-evidence { font-size: .9rem; color: var(--ink-2); margin-top: 2px; }
.step-time { font-family: var(--font-c); font-weight: 600; }
.steps-guided li { grid-template-columns: 48px 1fr; padding: 16px 0; font-size: 1.15rem; }
.steps-guided .step-no { width: 40px; height: 40px; font-size: 1.1rem; }

/* ── Flags ── */
.flags { list-style: none; padding: 0; margin: 0; }
.flags li { padding: 10px 12px 10px 14px; border-radius: var(--radius); margin-bottom: 8px; border-left: 4px solid; font-weight: 500; }
.flag-error { background: var(--stop-bg); border-color: var(--stop); color: #7C1F19; }
.flag-warn { background: var(--warn-bg); border-color: #D69E16; color: #6B4600; }

/* ── Record page ── */
.video-box { position: sticky; top: 16px; }
.video-box video { width: 100%; border-radius: var(--radius-lg); background: #000; display: block; aspect-ratio: 16/9; }
.transcript { max-height: 360px; overflow-y: auto; }
.seg { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 7px 4px; border-radius: 4px; cursor: pointer; }
.seg:hover { background: var(--plate); }
.seg.active { background: #FFF6D1; }
.seg time { font-family: var(--font-c); font-weight: 600; color: var(--steel); }
.jump { font-family: var(--font-c); font-weight: 600; background: none; border: 0; padding: 0; color: var(--focus); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--steel); }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.match { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.match img { width: 120px; border-radius: 4px; border: 1px solid var(--line); }
.ok-text { color: var(--go); font-weight: 600; }
.bad-text { color: var(--stop); font-weight: 600; }
.summary-list { margin: 0 0 12px; padding-left: 20px; }
.summary-list li { margin-bottom: 4px; }
.sec-title { font-family: var(--font-c); font-weight: 600; font-size: 1rem; color: var(--ink-2); margin: 14px 0 4px; }
.decide { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }

/* ── Capture ── */
.capture-drop { border: 2px dashed #9AA7B3; border-radius: var(--radius-lg); padding: 28px; text-align: center; background: #F7F9FA; }
.capture-drop input[type=file] { margin-top: 12px; }
.big-id { font-family: var(--font-c); font-weight: 700; font-size: 1.5rem; }
.wo-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; cursor: pointer; background: #fff; }
.wo-card + .wo-card { margin-top: 10px; }
.wo-card > input { margin-top: 5px; width: 20px; height: 20px; flex: none; }
.wo-card > span { flex: 1; min-width: 0; }
.wo-card:has(input:checked) { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--tag); }

/* ── Login ── */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { font-size: 2.8rem; color: #fff; margin-top: 24px; max-width: 17ch; }
.login-side p { color: #C9D3DC; font-size: 1.1rem; }
.pillars { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.pillars li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; color: #C9D3DC; }
.pillars b { color: #fff; display: block; font-family: var(--font-c); font-size: 1.1rem; }
.pillars .letter { width: 34px; height: 34px; border-radius: 4px 10px 10px 4px; background: var(--tag); color: var(--tag-ink); display: grid; place-items: center; font-family: var(--font-c); font-weight: 700; font-size: 1.2rem; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form form { width: 100%; max-width: 380px; }

/* ── Search ── */
mark { background: #FFE58A; padding: 0 2px; border-radius: 2px; }
.hit { padding: 12px 0; border-bottom: 1px solid #E2E7EB; }
.hit:last-child { border-bottom: 0; }

/* ── Email preview ── */
iframe.email { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

.empty { padding: 32px; text-align: center; color: var(--ink-2); }
.empty p { margin: 0 auto 14px; }

@media (max-width: 900px) {
  .grid-main, .grid-2 { grid-template-columns: 1fr; }
  .video-box { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 32px 24px; }
  .login-side h1 { font-size: 2.3rem; }
  .pillars { display: none; }
}
@media (max-width: 640px) {
  main { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .who span { display: none; }
  h1 { font-size: 1.6rem; }
  .field-row { grid-template-columns: 1fr; }
  th, td { padding: 9px 10px; }
  .steps li { grid-template-columns: 36px 1fr; }
  .steps li .step-time { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.login-side .brand-mark { width: 56px; height: 56px; }
.login-side .brand-name { font-size: 1.8rem; }

/* ── Phase 2: roles, corrections, setup ── */
.role-switch { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; }
.role-switch select { min-height: 32px; padding: 2px 8px; font-size: .9rem; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 6px; }
.role-switch select option { color: var(--ink); }
.role-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--tag); color: var(--tag-ink); font-weight: 600; font-size: .85rem; margin-right: 10px; }
.correction { margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--tag); background: #FFF9E3; font-size: .9rem; border-radius: 0 4px 4px 0; }
.correct-box { margin-top: 6px; font-size: .92rem; }
.correct-box summary { cursor: pointer; color: var(--focus); }
.correct-fields { display: grid; grid-template-columns: minmax(130px, 1fr) 2fr; gap: 8px; margin-top: 8px; }
@media (max-width: 560px) { .correct-fields { grid-template-columns: 1fr; } }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid var(--line); background: var(--plate); margin: 1px 2px 1px 0; }
.pill-go { background: var(--go-bg); border-color: #B5DCC5; color: #134D30; }
.pill-stop { background: var(--stop-bg); border-color: #F0BDB8; color: #7C1F19; }
.pill-warn { background: var(--warn-bg); border-color: #E8C46A; color: #6B4600; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks .check { font-weight: 400; }
tr.inactive td { color: var(--steel); }
.company { margin-bottom: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px 16px; }
  .topbar .nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .who > span:not(.role-chip) { display: none; }
  .who .role-chip { display: inline-block; }
}
