/* PaddockDesk - application styles.
   Brand: approved navy / red identity (sampled from the approved logo),
   with a racing blue for interactive elements. */

:root {
  --navy: #08294f;
  --navy-900: #051a33;
  --navy-800: #0a2342;
  --navy-700: #123a6a;
  --red: #e90a17;
  --red-700: #b80712;
  --blue: #1d6fe0;
  --blue-700: #1557b3;
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #e1e7ef;
  --line-strong: #cdd6e2;
  --text: #0e1a2b;
  --muted: #46576c;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(8, 41, 79, 0.06), 0 2px 8px rgba(8, 41, 79, 0.05);
  --shadow-lg: 0 10px 40px rgba(5, 26, 51, 0.25);
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --sidebar: 300px;

  --t-slate: #46576c; --t-slate-bg: #eef2f7;
  --t-blue: #1557b3; --t-blue-bg: #e7f0fd;
  --t-violet: #6a3fc1; --t-violet-bg: #f1ebfd;
  --t-amber: #9a6200; --t-amber-bg: #fff4dc;
  --t-orange: #b44a00; --t-orange-bg: #ffeddf;
  --t-green: #13784a; --t-green-bg: #e4f6ec;
  --t-red: #c0101b; --t-red-bg: #fde8e9;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg); overflow-x: hidden; }
body.modal-open { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.75rem; letter-spacing: 0.2px; }
h2 { font-size: 1rem; font-weight: 700; }
h3 { font-size: 0.9rem; font-weight: 700; margin: 14px 0 6px; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.tiny { font-size: 0.8rem; }
.strong { font-weight: 700; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.88em; letter-spacing: 0.3px; }
.nowrap { white-space: nowrap; }
.warn { color: var(--t-red); }
.center { text-align: center; }
.clamp-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.link { color: var(--blue-700); text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { text-decoration: underline; }
.icon { width: 18px; height: 18px; flex: none; }
.icon.ok { color: var(--t-green); }
:focus-visible { outline: 3px solid rgba(29, 111, 224, 0.45); outline-offset: 2px; }

/* ---------- Shell ---------- */
#app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy); color: #fff; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 12px; border-right: 3px solid var(--red); z-index: 30; }
.brand { display: block; padding: 2px 0 18px; text-decoration: none; }
.brand-lockup { display: block; background: #08294f; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1); padding-bottom: 10px; overflow: hidden; }
.brand-logo { width: 100%; height: auto; }
.brand-tagline { display: block; margin-top: -2px; text-align: center; color: #fff; font-weight: 600; font-size: 0.74rem; letter-spacing: 0.19em; text-transform: uppercase; white-space: nowrap; padding: 0 10px; }
.brand-icon { display: none; width: 40px; height: 40px; border-radius: 9px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: rgba(255, 255, 255, 0.88); text-decoration: none; font-weight: 600; font-size: 1rem; position: relative; }
.nav-link .icon { width: 20px; height: 20px; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link.is-active { background: rgba(255, 255, 255, 0.11); color: #fff; }
.nav-link.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--red); }
.sidebar-foot { margin-top: auto; display: grid; gap: 6px; padding: 12px 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); font-size: 0.86rem; color: rgba(255, 255, 255, 0.8); }
.alpha-tag { justify-self: start; background: var(--red); color: #fff; font-weight: 700; font-size: 0.76rem; letter-spacing: 0.8px; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; }
.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 24px; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); min-height: 60px; }
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; text-transform: uppercase; letter-spacing: 1px; color: var(--navy); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-switch { position: relative; display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 30px; background: var(--surface); cursor: pointer; min-width: 0; }
.user-switch select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.user-meta strong { font-size: 0.88rem; white-space: nowrap; }
.user-meta small { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.view { outline: none; min-width: 0; }

/* ---------- Page ---------- */
.page { padding: 22px 24px 48px; max-width: 1240px; margin: 0 auto; display: grid; gap: 16px; min-width: 0; }
.page-wide { max-width: none; }
.narrow { max-width: 620px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .muted { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.9rem; justify-self: start; }
.back-link:hover { color: var(--navy); }
.eyebrow { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; color: var(--red); font-size: 0.85rem; margin: 6px 0 -6px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; color: var(--navy); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.6px; }
.card-head h2 .icon { color: var(--red); }
.notice { text-align: center; padding: 32px; display: grid; gap: 10px; justify-items: center; }
.callout { background: var(--surface-2); border-left: 3px solid var(--blue); padding: 10px 12px; border-radius: 0 6px 6px 0; margin: 10px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 18px 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.empty p { margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.count-badge { background: var(--navy); color: #fff; border-radius: 20px; font-size: 0.75rem; font-weight: 700; padding: 1px 8px; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; border: 1px solid transparent; padding: 9px 14px; font-weight: 700; font-size: 0.9rem; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px; transition: background 0.15s, border-color 0.15s; }
.btn-sm { padding: 5px 10px; min-height: 34px; font-size: 0.86rem; }
.btn-lg { padding: 11px 18px; min-height: 46px; font-size: 0.98rem; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-700); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--navy); }
.btn-secondary:hover { border-color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--t-red); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--t-red); border-color: #f1b8bc; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--t-red); }
input, select, textarea { border: 1px solid var(--line-strong); border-radius: 7px; padding: 8px 10px; background: #fff; min-height: 40px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid rgba(29, 111, 224, 0.18); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input[type="color"] { padding: 2px; height: 40px; }
.input-plate { text-transform: uppercase; font-weight: 700; letter-spacing: 1px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field-label { font-size: 0.88rem; font-weight: 700; color: var(--navy); }
.field-hint { color: var(--muted); font-size: 0.84rem; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; min-width: 0; }
.fieldset legend { font-weight: 700; font-size: 0.85rem; padding: 0 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.w-xs { width: 90px; flex: none; }
.w-xxs { width: 64px; flex: none; }
.inline-field select { min-width: 170px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 280px; display: flex; align-items: center; min-width: 0; }
.search .icon { position: absolute; left: 11px; color: var(--muted); }
.search input { padding-left: 36px; }
.grow { flex: 1 1 220px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; max-width: 100%; }
.seg-btn { border: 0; background: transparent; padding: 6px 11px; border-radius: 7px; font-weight: 600; font-size: 0.9rem; cursor: pointer; color: var(--muted); }
.seg-btn.is-active { background: var(--surface); color: var(--navy); box-shadow: var(--shadow); }
.seg-btn[disabled] { cursor: default; }
.tabs { justify-self: start; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 20px; padding: 5px 12px; font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input:not(.w-xs):not(.w-xxs) { flex: 1 1 200px; width: auto; }
.inline-form select { width: auto; flex: 0 1 220px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Pills, plates, avatars ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 9px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; color: var(--t-slate); background: var(--t-slate-bg); }
.tone-slate.pill { color: var(--t-slate); background: var(--t-slate-bg); }
.tone-blue.pill { color: var(--t-blue); background: var(--t-blue-bg); }
.tone-violet.pill { color: var(--t-violet); background: var(--t-violet-bg); }
.tone-amber.pill { color: var(--t-amber); background: var(--t-amber-bg); }
.tone-orange.pill { color: var(--t-orange); background: var(--t-orange-bg); }
.tone-green.pill { color: var(--t-green); background: var(--t-green-bg); }
.tone-red.pill { color: var(--t-red); background: var(--t-red-bg); }
.live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .live-dot::before { animation: none; } * { scroll-behavior: auto !important; } }
.mock-tag { display: inline-block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.6px; color: var(--t-amber); background: var(--t-amber-bg); border: 1px solid #f0d390; border-radius: 4px; padding: 0 4px; vertical-align: middle; }
.plate { display: inline-flex; align-items: center; justify-content: center; background: #f6c400; color: #111; font-family: var(--font-display); font-weight: 700; letter-spacing: 1.2px; border-radius: 4px; padding: 2px 8px; font-size: 1rem; border: 1px solid rgba(0, 0, 0, 0.25); white-space: nowrap; line-height: 1.3; }
.plate-sm { font-size: 0.82rem; padding: 1px 6px; }
.plate-lg { font-size: 1.5rem; padding: 4px 14px; border-radius: 6px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; font-size: 0.8rem; flex: none; }
.avatar-sm { width: 26px; height: 26px; font-size: 0.68rem; }
.avatar-empty { background: var(--t-slate-bg); color: var(--muted); }

/* ---------- Dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border-top: 3px solid var(--t-slate); transition: transform 0.12s; min-width: 0; }
.kpi:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.kpi-icon { grid-row: 1 / 3; width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--t-slate-bg); color: var(--t-slate); }
.kpi-value { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1; color: var(--navy); }
.kpi-label { font-size: 0.88rem; color: var(--muted); font-weight: 600; }
.kpi.tone-blue { border-top-color: var(--blue); } .kpi.tone-blue .kpi-icon { background: var(--t-blue-bg); color: var(--t-blue); }
.kpi.tone-amber { border-top-color: #e7a614; } .kpi.tone-amber .kpi-icon { background: var(--t-amber-bg); color: var(--t-amber); }
.kpi.tone-orange { border-top-color: #f07a1c; } .kpi.tone-orange .kpi-icon { background: var(--t-orange-bg); color: var(--t-orange); }
.kpi.tone-green { border-top-color: #22a565; } .kpi.tone-green .kpi-icon { background: var(--t-green-bg); color: var(--t-green); }
.kpi.tone-violet { border-top-color: #7c4ddb; } .kpi.tone-violet .kpi-icon { background: var(--t-violet-bg); color: var(--t-violet); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-main, .dash-side { display: grid; gap: 16px; min-width: 0; }
.money-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(122px, 1fr)); gap: 10px; }
.money-cell { background: var(--surface-2); border-radius: 8px; padding: 12px; display: grid; gap: 4px; border-left: 3px solid var(--navy); }
.money-cell.tone-amber { border-left-color: #e7a614; } .money-cell.tone-red { border-left-color: var(--red); } .money-cell.tone-green { border-left-color: #22a565; }
.money-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.money-value { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; color: var(--navy); }
.row-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.row-list > li { min-width: 0; }
.row-list > li + li { border-top: 1px solid var(--line); }
.row-link { display: flex; align-items: center; gap: 10px; padding: 9px 4px; text-decoration: none; min-width: 0; }
.row-link:hover { background: var(--surface-2); }
.row-time { font-weight: 700; font-size: 0.85rem; color: var(--navy); min-width: 48px; }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-main strong, .row-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--muted); }
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alert { padding: 8px 10px 8px 12px; border-radius: 7px; font-size: 0.92rem; border-left: 3px solid; }
.alert a { text-decoration: none; font-weight: 600; }
.alert a:hover { text-decoration: underline; }
.alert-danger { background: var(--t-red-bg); border-color: var(--red); color: #7d0a11; }
.alert-warning { background: var(--t-amber-bg); border-color: #e7a614; color: #6b4500; }
.alert-info { background: var(--t-blue-bg); border-color: var(--blue); color: #123f7f; }
.tech-now { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tech-now li { display: flex; gap: 10px; align-items: center; }
.tech-now div { display: grid; min-width: 0; }
.card-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 8px; }

/* ---------- Job cards & board ---------- */
.job-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); border-left: 4px solid var(--t-slate); min-width: 0; }
.job-card.dragging { opacity: 0.5; }
.job-card-link { display: grid; gap: 4px; padding: 10px 12px 10px; text-decoration: none; }
.job-card-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.job-no { font-weight: 700; font-size: 0.84rem; color: var(--muted); }
.job-vehicle { font-weight: 700; margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-reason { font-size: 0.9rem; color: var(--muted); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job-card-meta { display: flex; align-items: center; gap: 6px; font-size: 0.86rem; min-width: 0; margin-top: 2px; }
.job-card-meta .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.job-value { font-weight: 700; color: var(--navy); }
.job-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.job-flags:empty { display: none; }
.job-move-btn { position: absolute; top: 8px; right: 8px; display: none; align-items: center; gap: 4px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; font-size: 0.8rem; font-weight: 700; padding: 3px 7px; cursor: pointer; color: var(--navy); }
.job-card:hover .job-move-btn, .job-card:focus-within .job-move-btn { display: inline-flex; }
@media (hover: none) { .job-move-btn { display: inline-flex; position: static; margin: 0 12px 10px; } }
.stage-checked_in, .stage-in_progress { border-left-color: var(--blue); }
.stage-diagnosing, .stage-quality_check { border-left-color: #7c4ddb; }
.stage-awaiting_approval { border-left-color: #e7a614; }
.stage-waiting_parts { border-left-color: #f07a1c; }
.stage-ready { border-left-color: #22a565; }
.stage-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.stage-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 20px; text-decoration: none; font-weight: 700; font-size: 0.86rem; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.stage-chip b { background: var(--surface-2); border-radius: 10px; padding: 0 6px; }
.stage-chip.is-active { border-color: var(--navy); background: var(--navy); color: #fff; }
.stage-chip.is-active b { background: rgba(255, 255, 255, 0.2); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; scroll-snap-type: x proximity; min-width: 0; max-width: 100%; }
.board-col { background: #e9edf3; border-radius: var(--radius); padding: 8px; min-height: 200px; scroll-snap-align: start; border: 2px solid transparent; min-width: 0; }
.board-col.drop-hover { border-color: var(--blue); background: var(--t-blue-bg); }
.board-col.is-focus { border-color: var(--navy); }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; border-bottom: 3px solid var(--t-slate); margin-bottom: 8px; }
.board-col-head h2 { font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.7px; color: var(--navy); }
.board-col-head.tone-blue { border-color: var(--blue); } .board-col-head.tone-violet { border-color: #7c4ddb; } .board-col-head.tone-amber { border-color: #e7a614; }
.board-col-head.tone-orange { border-color: #f07a1c; } .board-col-head.tone-green { border-color: #22a565; } .board-col-head.tone-red { border-color: var(--red); }
.board-col-body { display: grid; gap: 8px; }
.col-empty { color: var(--muted); font-size: 0.88rem; text-align: center; padding: 16px 0; margin: 0; }
.move-list { display: grid; gap: 6px; }
.move-option { display: flex; align-items: center; gap: 10px; justify-content: space-between; text-align: left; border: 1px solid var(--line); background: var(--surface); padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.move-option:hover { border-color: var(--navy); }
.move-option.is-blocked { background: var(--surface-2); cursor: not-allowed; }
.move-option.is-blocked .pill { opacity: 0.55; }
.move-reason { font-size: 0.88rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); max-width: 100%; }
.card > .table-wrap { margin: 0 0 4px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); background: var(--surface-2); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table-tight td { padding: 8px 10px; }
.table .num { text-align: right; white-space: nowrap; }
.row-click { cursor: pointer; }
.row-click:hover td { background: var(--surface-2); }
.group-row td { background: var(--surface-2); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px; color: var(--navy); padding: 5px 10px; }
.row-actions { width: 40px; text-align: right; }
.flags-inline { margin-top: 4px; }
.perm-table td, .perm-table th { padding: 6px 8px; }

/* ---------- Job page ---------- */
.job-head { display: grid; gap: 14px; border-top: 4px solid var(--red); }
.job-head-main { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.job-head-main > div { min-width: 0; }
.job-head h1 { font-size: 1.6rem; }
.job-head-reason { font-size: 1.05rem; margin: 4px 0; font-weight: 600; }
.job-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-head-actions .btn-row { margin: 0 0 0 auto; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.stepper li { display: grid; gap: 4px; justify-items: center; text-align: center; position: relative; }
.stepper .dot { width: 100%; height: 6px; border-radius: 3px; background: var(--line); }
.stepper .done .dot { background: var(--navy-700); }
.stepper .current .dot { background: var(--red); }
.step-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stepper .current .step-label { color: var(--red); font-weight: 800; }
.section-nav { display: flex; gap: 6px; overflow-x: auto; position: sticky; top: 60px; z-index: 10; background: var(--bg); padding: 6px 0; }
.section-nav a { text-decoration: none; font-weight: 700; font-size: 0.88rem; padding: 5px 11px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.section-nav a:hover { border-color: var(--navy); }
.job-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.job-main, .job-side { display: grid; gap: 16px; min-width: 0; }
.job-main > .card { scroll-margin-top: 110px; }
.totals { display: grid; gap: 4px; margin: 12px 0 0 auto; max-width: 300px; }
.totals div { display: flex; justify-content: space-between; gap: 16px; font-size: 0.9rem; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 600; }
.totals .total { border-top: 2px solid var(--navy); padding-top: 6px; font-size: 1.05rem; }
.totals .total dd { font-weight: 800; color: var(--navy); }
.totals .approved-total dd { color: var(--t-green); font-weight: 700; }
.add-lines { display: grid; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-strong); }
.approval-bar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.approval-info { display: grid; gap: 2px; }
.notice-mock, .banner-mock { background: var(--t-amber-bg); border: 1px solid #f0d390; color: #6b4500; border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; }
.banner-mock { display: flex; gap: 10px; align-items: flex-start; }
.banner-mock .icon { color: var(--t-amber); margin-top: 2px; }
.decision-list { display: grid; gap: 8px; margin-top: 10px; }
.decision-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.seg-radio { display: inline-flex; gap: 5px; align-items: center; padding: 5px 10px; border-radius: 7px; font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.seg-radio:has(input:checked).tone-green { background: var(--t-green-bg); color: var(--t-green); }
.seg-radio:has(input:checked).tone-red { background: var(--t-red-bg); color: var(--t-red); }
.parts-list { list-style: none; margin: 0; padding: 0; display: grid; }
.parts-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.parts-list li:last-child { border-bottom: 0; }
.parts-list .is-declined { opacity: 0.55; }
.parts-main { display: grid; min-width: 0; }
.parts-status { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.order-chip { display: inline-block; margin: 4px 6px 0 0; padding: 2px 8px; background: var(--surface-2); border-radius: 12px; font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.health-item { border: 1px solid var(--line); border-radius: 9px; padding: 10px; display: grid; gap: 8px; border-top: 3px solid var(--line-strong); min-width: 0; }
.health-item.state-good { border-top-color: #22a565; }
.health-item.state-advisory { border-top-color: #e7a614; }
.health-item.state-attention { border-top-color: var(--red); }
.seg-health { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.seg-health .seg-btn { padding: 7px 4px; font-size: 0.82rem; }
.seg-health .seg-btn.is-active.tone-green { background: var(--t-green-bg); color: var(--t-green); }
.seg-health .seg-btn.is-active.tone-amber { background: var(--t-amber-bg); color: var(--t-amber); }
.seg-health .seg-btn.is-active.tone-red { background: var(--t-red-bg); color: var(--t-red); }
.health-notes { font-size: 0.85rem; }
.photo-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 0.86rem; font-weight: 700; color: var(--blue-700); cursor: pointer; justify-self: start; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-doc { flex-direction: column; gap: 4px; text-decoration: none; font-size: 0.76rem; padding: 6px; text-align: center; color: var(--navy); }
.thumb-doc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.diag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.diag { border: 1px solid var(--line); border-left: 3px solid var(--navy); border-radius: 8px; padding: 10px 12px; }
.diag p { margin: 4px 0; font-size: 0.9rem; }
.diag-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 800; background: var(--navy); color: #fff; padding: 2px 7px; border-radius: 5px; font-size: 0.85rem; }
.label { font-weight: 700; color: var(--navy); }
.history summary { cursor: pointer; font-weight: 700; color: var(--blue-700); margin-top: 12px; }
.history .diag-list { margin-top: 10px; }
.notes-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.notes-grid h3 { margin-top: 0; }
.note-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.note-list li { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.note-list p { margin: 0 0 2px; }
.note-form { display: grid; gap: 6px; justify-items: start; }
.kv { display: grid; gap: 0; margin: 0; }
.kv > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; text-align: right; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.kv dd select { width: auto; min-width: 160px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; }
.timeline p { margin: 0; font-size: 0.92rem; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); margin-top: 5px; }
.tl-stage { background: var(--navy); } .tl-approval { background: #22a565; } .tl-estimate_sent { background: #e7a614; } .tl-parts { background: #f07a1c; } .tl-payment, .tl-invoice { background: var(--red); } .tl-work { background: var(--blue); }

/* ---------- Lists (customers/vehicles) ---------- */
.list-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list-card { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; box-shadow: var(--shadow); min-width: 0; flex-wrap: wrap; }
.list-card:hover { border-color: var(--navy); }
.list-card-main { display: grid; flex: 1 1 200px; min-width: 0; }
.list-card-plates { display: flex; gap: 6px; flex-wrap: wrap; }
.vehicle-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; border-top: 4px solid var(--red); }
.vehicle-hero-main { flex: 1 1 240px; min-width: 0; }
.vehicle-hero-main p { margin: 2px 0; }
.health-mini { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; }
.health-mini li { display: flex; justify-content: space-between; gap: 8px; font-size: 0.88rem; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; }
.history-list > li { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.history-list > li:last-child { border-bottom: 0; }
.history-date { font-weight: 700; color: var(--navy); font-size: 0.88rem; }
.history-work { margin: 4px 0; padding-left: 18px; font-size: 0.86rem; color: var(--muted); }

/* ---------- Parts ---------- */
.parts-lookup { display: grid; gap: 10px; }
.parts-lookup .btn { justify-self: start; }
.add-to-job { display: flex; gap: 6px; align-items: center; }
.add-to-job select { width: auto; }
.parts-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.parts-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; min-width: 0; }

/* ---------- Technician ---------- */
.tech-page { max-width: 760px; }
.tech-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.tech-top select { width: auto; }
.tech-current { border-top: 4px solid var(--red); display: grid; gap: 6px; }
.tech-current-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.tech-current-head > div { flex: 1 1 200px; min-width: 0; }
.tech-current-head h2 { font-size: 1.3rem; font-family: var(--font-display); }
.tech-current-head p { margin: 2px 0 0; overflow-wrap: anywhere; }
.tech-reason { font-size: 1.1rem; font-weight: 600; margin: 6px 0; }
.tech-timer { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--t-blue); }
.tech-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px; border-radius: 10px; border: 0; font-weight: 800; font-size: 1.05rem; cursor: pointer; text-decoration: none; padding: 10px 14px; }
.tbtn .icon { width: 22px; height: 22px; }
.tbtn-start { background: var(--blue); color: #fff; }
.tbtn-pause { background: #e7a614; color: #2a1b00; }
.tbtn-done { background: #18925a; color: #fff; }
.tbtn-ghost { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--navy); font-size: 0.95rem; min-height: 50px; }
.tech-blocked { display: flex; align-items: center; gap: 8px; background: var(--surface-2); padding: 12px; border-radius: 8px; font-weight: 600; }
.check-list, .tech-parts, .tech-diags, .tech-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.check-list li { display: flex; gap: 8px; align-items: center; }
.check-list .icon { color: var(--t-green); }
.tech-parts li { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.tech-diags li { padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 0.9rem; }
.tech-record { display: grid; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.tech-record .note-form { grid-template-columns: 1fr auto; align-items: end; justify-items: stretch; }
.tech-record-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tech-next { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-wrap: wrap; }
.tech-next > div { display: grid; flex: 1 1 180px; min-width: 0; }
.tech-list a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; text-decoration: none; flex-wrap: wrap; }
.tech-list a span:not(.pill):not(.plate) { flex: 1 1 140px; min-width: 0; }

/* ---------- Settings ---------- */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-nav { display: grid; gap: 2px; position: sticky; top: 76px; }
.settings-tab { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); }
.settings-tab:hover { background: var(--surface); color: var(--navy); }
.settings-tab.is-active { background: var(--surface); color: var(--navy); box-shadow: var(--shadow); border-left: 3px solid var(--red); }
.settings-body { display: grid; gap: 16px; min-width: 0; }
.form-card { display: grid; gap: 14px; max-width: 760px; }
.form-card > .btn { justify-self: start; }
.hours-grid { display: grid; gap: 8px; }
.hours-row { display: grid; grid-template-columns: 110px 90px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: center; }
.brand-preview { height: 90px; border: 1px dashed var(--line-strong); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 10px; background: var(--surface-2); }
.brand-preview img { max-height: 70px; width: auto; }
.staff-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; flex-wrap: wrap; }
.staff-row select { width: auto; }
.staff-row.is-inactive { opacity: 0.55; }

/* ---------- Modal & toasts ---------- */
#modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 26, 51, 0.55); }
.modal { position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-wide { width: min(760px, 100%); }
.modal-form { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); border-top: 4px solid var(--red); }
.modal-head h2 { font-size: 1.1rem; color: var(--navy); }
.modal-body { padding: 16px 18px; overflow-y: auto; display: grid; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; pointer-events: none; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--navy); color: #fff; padding: 11px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 0.9rem; border-left: 4px solid var(--blue); transition: opacity 0.4s, transform 0.4s; }
.toast-success { border-left-color: #22a565; }
.toast-warning { border-left-color: #e7a614; }
.toast-danger { border-left-color: var(--red); background: #3a0a0e; }
.toast-out { opacity: 0; transform: translateY(8px); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  :root { --sidebar: 76px; }
  .sidebar { padding: 14px 10px; align-items: center; }
  .brand-logo { display: none; }
  .brand-icon { display: block; }
  .brand { padding: 0 0 14px; }
  .nav { width: 100%; }
  .nav-link { flex-direction: column; gap: 3px; padding: 8px 4px; font-size: 0.74rem; text-align: center; }
  .nav-link.is-active::before { left: -10px; }
  .sidebar-foot { display: none; }
  .dash-grid, .job-grid { grid-template-columns: minmax(0, 1fr); }
  .job-side { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
  .parts-board { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .two-col, .notes-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .settings-tab { white-space: nowrap; }
  .field-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-md { display: none; }
  .stepper .step-label { display: none; }
}
@media (max-width: 720px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 3px solid var(--red); }
  .brand { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 0; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { flex: 1 0 68px; padding: 6px 2px; font-size: 0.72rem; }
  .nav-link.is-active::before { left: 12px; right: 12px; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .workspace { padding-bottom: 72px; }
  .topbar { padding: 8px 14px; min-height: 54px; }
  .user-meta { display: none; }
  .user-switch { padding: 3px; }
  .page { padding: 14px 14px 32px; gap: 12px; }
  h1 { font-size: 1.45rem; }
  .card { padding: 14px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px; column-gap: 8px; }
  .kpi-icon { width: 32px; height: 32px; }
  .kpi-value { font-size: 1.6rem; }
  .field-row, .field-row-3, .field-row-4 { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  .board { grid-auto-columns: 84vw; }
  .job-head-main { flex-direction: column; gap: 10px; }
  .job-head h1 { font-size: 1.3rem; }
  .job-head-actions .btn-row { margin: 0; width: 100%; }
  .job-head-actions .btn-lg { flex: 1 1 100%; }
  .section-nav { top: 54px; }
  .job-side { grid-template-columns: minmax(0, 1fr); }
  .history-list > li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .hours-row { grid-template-columns: 1fr auto; }
  .hours-row input[type="time"] { grid-column: span 1; }
  .toolbar .seg { width: 100%; }
  .modal { max-height: calc(100vh - 16px); }
  #modal-root { padding: 8px; align-items: flex-end; }
  #toasts { bottom: 84px; left: 16px; right: 16px; max-width: none; }
  .add-to-job { flex-wrap: wrap; }
  .tech-record .note-form { grid-template-columns: minmax(0, 1fr); }
  .row-link { flex-wrap: wrap; row-gap: 4px; }
  .row-link .row-main { flex: 1 1 calc(100% - 150px); }
  .row-link .avatar { display: none; }
  .row-link > .pill { margin-left: 58px; }
}
@media (max-width: 400px) {
  .tech-actions, .tech-record-btns { grid-template-columns: minmax(0, 1fr); }
}
