/* ═══════════════════════════════════════════════════════════════════════
   APPROACH 2 — "Workbench"
   Design system: a guided, task-first interface built for clarity first
   and density second.

   Everything here is deliberately larger, calmer and more explicit than
   Approach 1: 16px base text, 44px controls, 3px focus rings, generous
   whitespace, and plain-language labelling baked into the components.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* Warm-neutral paper, near-black ink. Text on paper clears 16:1. */
  --paper: 250 249 247;
  --card: 255 255 255;
  --card-2: 246 245 242;
  --card-3: 237 235 231;
  --edge: 222 219 213;
  --edge-strong: 190 186 178;
  --ink: 24 24 27;
  --ink-2: 68 68 76;
  --ink-3: 105 105 115;

  /* One decisive blue. 7.4:1 on paper, so it can carry text as well as fill. */
  --brand: 21 78 168;
  --brand-ink: 255 255 255;
  --brand-tint: 231 240 252;
  --brand-edge: 168 199 238;

  --go: 20 108 76;          /* success / positive money            */
  --go-tint: 224 244 235;
  --go-edge: 150 205 184;
  --wait: 141 84 4;         /* warning / needs attention           */
  --wait-tint: 253 243 221;
  --wait-edge: 226 190 118;
  --stop: 173 33 33;        /* danger / money out                  */
  --stop-tint: 253 232 232;
  --stop-edge: 232 160 160;
  --note: 22 100 138;       /* neutral emphasis                    */
  --note-tint: 224 242 250;
  --note-edge: 152 202 226;

  --div-fleet: 21 118 66;
  --div-logistics: 27 86 179;
  --div-warehouse: 146 96 6;
  --div-freight: 173 47 47;

  --focus: 21 78 168;
  --shadow-1: 0 1px 3px rgb(24 24 27 / 0.07);
  --shadow-2: 0 6px 18px -4px rgb(24 24 27 / 0.12), 0 2px 6px -2px rgb(24 24 27 / 0.06);
  --shadow-3: 0 24px 48px -12px rgb(24 24 27 / 0.22);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
}

.dark {
  --paper: 18 18 21;
  --card: 28 28 33;
  --card-2: 36 36 42;
  --card-3: 46 46 54;
  --edge: 58 58 68;
  --edge-strong: 84 84 96;
  --ink: 245 245 247;
  --ink-2: 194 194 202;
  --ink-3: 154 154 165;

  --brand: 130 178 250;
  --brand-ink: 12 20 34;
  --brand-tint: 20 38 66;
  --brand-edge: 52 88 140;

  --go: 86 214 162;
  --go-tint: 12 48 38;
  --go-edge: 30 92 72;
  --wait: 240 190 90;
  --wait-tint: 54 40 12;
  --wait-edge: 108 80 24;
  --stop: 250 140 140;
  --stop-tint: 58 24 24;
  --stop-edge: 110 48 48;
  --note: 120 190 240;
  --note-tint: 14 42 62;
  --note-edge: 36 82 112;

  --div-fleet: 92 226 160;
  --div-logistics: 130 178 250;
  --div-warehouse: 240 200 90;
  --div-freight: 250 140 140;

  --focus: 130 178 250;
  --shadow-1: 0 1px 3px rgb(0 0 0 / 0.5);
  --shadow-2: 0 6px 18px -4px rgb(0 0 0 / 0.6);
  --shadow-3: 0 24px 48px -12px rgb(0 0 0 / 0.7);
}

/* ── base ─────────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

body {
  background: rgb(var(--paper));
  color: rgb(var(--ink));
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Type scale — one step larger than a typical admin, on purpose. */
.h1 { font-size: 1.75rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
.h2 { font-size: 1.3125rem; line-height: 1.3; font-weight: 680; letter-spacing: -0.01em; }
.h3 { font-size: 1.0625rem; line-height: 1.4; font-weight: 650; }
.lead { font-size: 1.0625rem; line-height: 1.6; color: rgb(var(--ink-2)); }
.body { font-size: 1rem; line-height: 1.6; }
.small { font-size: 0.9375rem; line-height: 1.55; }
.tiny { font-size: 0.8125rem; line-height: 1.5; }
.eyebrow {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: rgb(var(--ink-3));
}
.num { font-variant-numeric: tabular-nums; }
.big-number { font-size: 2.25rem; line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* ── focus: thick, high contrast, never removed ───────────────────── */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid rgb(var(--focus));
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: rgb(var(--brand)); color: rgb(var(--brand-ink));
  padding: 0.75rem 1.25rem; border-radius: var(--r-sm); font-weight: 700;
  transition: top 140ms ease;
}
.skip-link:focus { top: 1rem; }

/* ── buttons: large, labelled, obvious ───────────────────────────── */
.b {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0 1.125rem; border-radius: var(--r-sm);
  font-size: 1rem; font-weight: 640; line-height: 1.2; text-align: center;
  border: 2px solid transparent; cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 80ms ease;
}
.b:active:not(:disabled) { transform: translateY(1px); }
.b:disabled { opacity: 0.45; cursor: not-allowed; }
.b svg { width: 20px; height: 20px; flex: none; }

.b-go { background: rgb(var(--brand)); color: rgb(var(--brand-ink)); box-shadow: var(--shadow-1); }
.b-go:hover:not(:disabled) { background: rgb(var(--brand) / 0.88); }

.b-plain {
  background: rgb(var(--card)); color: rgb(var(--ink));
  border-color: rgb(var(--edge-strong)); box-shadow: var(--shadow-1);
}
.b-plain:hover:not(:disabled) { background: rgb(var(--card-2)); border-color: rgb(var(--ink-3)); }

.b-quiet { background: transparent; color: rgb(var(--brand)); }
.b-quiet:hover:not(:disabled) { background: rgb(var(--brand-tint)); }

.b-stop { background: rgb(var(--stop)); color: #fff; }
.b-stop:hover:not(:disabled) { background: rgb(var(--stop) / 0.86); }

.b-lg { min-height: 3.25rem; padding: 0 1.5rem; font-size: 1.0625rem; border-radius: var(--r-md); }
.b-sm { min-height: 2.25rem; padding: 0 0.75rem; font-size: 0.9375rem; }
.b-sm svg { width: 17px; height: 17px; }
.b-square { width: 2.75rem; padding: 0; }
.b-square.b-sm { width: 2.25rem; }
.b-wide { width: 100%; }

/* ── form controls ────────────────────────────────────────────────── */
.lbl {
  display: block; font-size: 1rem; font-weight: 650; color: rgb(var(--ink));
  margin-bottom: 0.375rem;
}
.lbl .opt { font-weight: 450; color: rgb(var(--ink-3)); }
.lbl .must { color: rgb(var(--stop)); font-weight: 700; }
.help { font-size: 0.9375rem; color: rgb(var(--ink-2)); margin-top: 0.375rem; }
.err {
  display: flex; align-items: flex-start; gap: 0.375rem;
  font-size: 0.9375rem; font-weight: 600; color: rgb(var(--stop)); margin-top: 0.375rem;
}

.in, .sel, .ta {
  width: 100%; min-height: 2.875rem;
  background: rgb(var(--card)); color: rgb(var(--ink));
  border: 2px solid rgb(var(--edge-strong)); border-radius: var(--r-sm);
  font-size: 1rem; padding: 0.5rem 0.75rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.ta { line-height: 1.55; resize: vertical; }
.sel {
  appearance: none; padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23696973' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 20px;
}
.in::placeholder, .ta::placeholder { color: rgb(var(--ink-3)); }
.in:hover, .sel:hover, .ta:hover { border-color: rgb(var(--ink-3)); }
.in:focus, .sel:focus, .ta:focus {
  outline: none; border-color: rgb(var(--brand));
  box-shadow: 0 0 0 4px rgb(var(--brand) / 0.2);
}
.in:disabled, .sel:disabled, .ta:disabled {
  background: rgb(var(--card-3)); color: rgb(var(--ink-3)); cursor: not-allowed; border-style: dashed;
}
.in[aria-invalid="true"], .sel[aria-invalid="true"], .ta[aria-invalid="true"] {
  border-color: rgb(var(--stop)); background: rgb(var(--stop-tint));
}

/* Choice controls are big enough to hit on a phone in a truck yard. */
.box {
  appearance: none; width: 1.5rem; height: 1.5rem; flex: none;
  border: 2px solid rgb(var(--edge-strong)); border-radius: 6px;
  background: rgb(var(--card)); cursor: pointer; position: relative;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.box[type="radio"] { border-radius: 50%; }
.box:checked { background: rgb(var(--brand)); border-color: rgb(var(--brand)); }
.box:checked::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center/1rem url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.5 3.5L13 5'/%3E%3C/svg%3E");
}
.box[type="radio"]:checked::after { background: #fff; border-radius: 50%; inset: 5px; }

/* A whole labelled block is the click target, not just the 24px square. */
.choice {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.875rem 1rem; border: 2px solid rgb(var(--edge));
  border-radius: var(--r-md); background: rgb(var(--card)); cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.choice:hover { border-color: rgb(var(--ink-3)); background: rgb(var(--card-2)); }
.choice:has(:checked) { border-color: rgb(var(--brand)); background: rgb(var(--brand-tint)); }
.choice:has(:focus-visible) { outline: 3px solid rgb(var(--focus)); outline-offset: 2px; }

.toggle {
  appearance: none; width: 3rem; height: 1.75rem; border-radius: 999px;
  background: rgb(var(--edge-strong)); position: relative; cursor: pointer; flex: none;
  transition: background-color 160ms ease;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 1.25rem; height: 1.25rem;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform 160ms ease;
}
.toggle:checked { background: rgb(var(--brand)); }
.toggle:checked::after { transform: translateX(1.25rem); }

/* ── surfaces ─────────────────────────────────────────────────────── */
.panel {
  background: rgb(var(--card)); border: 2px solid rgb(var(--edge));
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.panel-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1.125rem 1.25rem;
  border-bottom: 2px solid rgb(var(--edge));
}
.panel-body { padding: 1.25rem; }

/* A record card: the browse unit, used instead of a table row. */
.record {
  display: block; background: rgb(var(--card));
  border: 2px solid rgb(var(--edge)); border-radius: var(--r-md);
  padding: 1rem 1.125rem; transition: border-color 140ms ease, box-shadow 140ms ease;
}
a.record:hover, button.record:hover { border-color: rgb(var(--brand)); box-shadow: var(--shadow-2); }
.record.flag-wait { border-left: 6px solid rgb(var(--wait)); }
.record.flag-stop { border-left: 6px solid rgb(var(--stop)); }
.record.flag-go { border-left: 6px solid rgb(var(--go)); }
.record.flag-note { border-left: 6px solid rgb(var(--note)); }

/* ── status: shape + word + colour, never colour alone ───────────── */
.tag {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.25rem 0.625rem; border-radius: 999px;
  font-size: 0.875rem; font-weight: 650; line-height: 1.4; white-space: nowrap;
  border: 2px solid transparent;
}
.tag svg { width: 15px; height: 15px; flex: none; }
.tag-plain { background: rgb(var(--card-3)); color: rgb(var(--ink-2)); border-color: rgb(var(--edge-strong)); }
.tag-brand { background: rgb(var(--brand-tint)); color: rgb(var(--brand)); border-color: rgb(var(--brand-edge)); }
.tag-go    { background: rgb(var(--go-tint)); color: rgb(var(--go)); border-color: rgb(var(--go-edge)); }
.tag-wait  { background: rgb(var(--wait-tint)); color: rgb(var(--wait)); border-color: rgb(var(--wait-edge)); }
.tag-stop  { background: rgb(var(--stop-tint)); color: rgb(var(--stop)); border-color: rgb(var(--stop-edge)); }
.tag-note  { background: rgb(var(--note-tint)); color: rgb(var(--note)); border-color: rgb(var(--note-edge)); }

/* ── callouts: the main teaching device in this approach ─────────── */
.callout {
  display: flex; gap: 0.875rem; padding: 1rem 1.125rem;
  border-radius: var(--r-md); border: 2px solid; font-size: 1rem;
}
.callout svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.callout > div { min-width: 0; }
.callout strong { display: block; font-weight: 700; margin-bottom: 0.125rem; }
.callout p { color: rgb(var(--ink-2)); }
.c-note { background: rgb(var(--note-tint)); border-color: rgb(var(--note-edge)); color: rgb(var(--note)); }
.c-go   { background: rgb(var(--go-tint)); border-color: rgb(var(--go-edge)); color: rgb(var(--go)); }
.c-wait { background: rgb(var(--wait-tint)); border-color: rgb(var(--wait-edge)); color: rgb(var(--wait)); }
.c-stop { background: rgb(var(--stop-tint)); border-color: rgb(var(--stop-edge)); color: rgb(var(--stop)); }

/* ── navigation ───────────────────────────────────────────────────── */
.goal {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.625rem 0.875rem; border-radius: var(--r-sm);
  font-size: 1rem; font-weight: 640; color: rgb(var(--ink-2)); white-space: nowrap;
  border: 2px solid transparent;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.goal:hover { background: rgb(var(--card-2)); color: rgb(var(--ink)); }
.goal[aria-current="page"] {
  background: rgb(var(--brand-tint)); color: rgb(var(--brand)); border-color: rgb(var(--brand-edge));
}
.goal svg { width: 20px; height: 20px; flex: none; }
.goal .n {
  margin-left: 0.125rem; font-size: 0.8125rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: rgb(var(--wait)); color: #fff; border-radius: 999px;
  min-width: 1.375rem; padding: 0 0.375rem; text-align: center;
}

.task {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.625rem 0.75rem; border-radius: var(--r-sm);
  font-size: 0.9375rem; font-weight: 560; color: rgb(var(--ink-2));
  border-left: 4px solid transparent;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.task:hover { background: rgb(var(--card-2)); color: rgb(var(--ink)); }
.task[aria-current="page"] {
  background: rgb(var(--brand-tint)); color: rgb(var(--brand));
  border-left-color: rgb(var(--brand)); font-weight: 680;
}
.task svg { width: 18px; height: 18px; flex: none; }
.task .n {
  margin-left: auto; font-size: 0.8125rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: rgb(var(--ink-3)); background: rgb(var(--card-3));
  border-radius: 999px; min-width: 1.5rem; padding: 0.0625rem 0.4375rem; text-align: center;
}
.task .n.hot { background: rgb(var(--wait-tint)); color: rgb(var(--wait)); }

/* ── steps ────────────────────────────────────────────────────────── */
.steps { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.step {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.625rem 0.875rem; border-radius: var(--r-md);
  border: 2px solid rgb(var(--edge)); background: rgb(var(--card));
  font-size: 0.9375rem; font-weight: 600; color: rgb(var(--ink-3)); flex: 1 1 12rem;
}
.step .dot {
  display: grid; place-items: center; width: 1.75rem; height: 1.75rem; flex: none;
  border-radius: 50%; background: rgb(var(--card-3)); color: rgb(var(--ink-3));
  font-size: 0.875rem; font-weight: 700;
}
.step[data-state="current"] {
  border-color: rgb(var(--brand)); background: rgb(var(--brand-tint)); color: rgb(var(--brand));
}
.step[data-state="current"] .dot { background: rgb(var(--brand)); color: rgb(var(--brand-ink)); }
.step[data-state="done"] { border-color: rgb(var(--go-edge)); color: rgb(var(--go)); }
.step[data-state="done"] .dot { background: rgb(var(--go)); color: #fff; }

/* ── tables (the optional power-user view) ───────────────────────── */
.grid-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9375rem; }
.grid-table th {
  position: sticky; top: 0; z-index: 2; text-align: left; white-space: nowrap;
  background: rgb(var(--card-2)); color: rgb(var(--ink-2));
  font-size: 0.875rem; font-weight: 700; padding: 0.75rem 1rem;
  border-bottom: 2px solid rgb(var(--edge));
}
.grid-table td { padding: 0.875rem 1rem; border-bottom: 1px solid rgb(var(--edge)); vertical-align: top; }
.grid-table tbody tr:hover { background: rgb(var(--card-2)); }
.grid-table th.r, .grid-table td.r { text-align: right; font-variant-numeric: tabular-nums; }

/* ── progress ─────────────────────────────────────────────────────── */
.meter { height: 10px; border-radius: 999px; background: rgb(var(--card-3)); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: rgb(var(--brand)); }

/* ── skeleton ─────────────────────────────────────────────────────── */
.sk {
  background: linear-gradient(90deg, rgb(var(--card-3)) 25%, rgb(var(--edge)) 37%, rgb(var(--card-3)) 63%);
  background-size: 400% 100%; border-radius: 6px; animation: sh 1.4s ease infinite;
}
@keyframes sh { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── dialogs ──────────────────────────────────────────────────────── */
dialog::backdrop { background: rgb(24 24 27 / 0.55); }
dialog[open] {
  border: 2px solid rgb(var(--edge)); border-radius: var(--r-lg); padding: 0;
  background: rgb(var(--card)); color: rgb(var(--ink));
  box-shadow: var(--shadow-3); max-width: min(94vw, 36rem); width: 100%;
}
dialog.wide[open] { max-width: min(94vw, 54rem); }

/* ── toasts ───────────────────────────────────────────────────────── */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 1.5rem; z-index: 60;
  display: flex; flex-direction: column; gap: 0.625rem; width: min(30rem, calc(100vw - 2rem));
}
.toast {
  display: flex; gap: 0.75rem; align-items: flex-start;
  background: rgb(var(--ink)); color: rgb(var(--card));
  border-radius: var(--r-md); padding: 0.875rem 1.125rem; box-shadow: var(--shadow-3);
  font-size: 1rem; font-weight: 560;
  animation: rise 200ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.toast svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.toast.ok svg { color: rgb(var(--go)); }
.toast.bad svg { color: rgb(var(--stop)); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ── helpers ──────────────────────────────────────────────────────── */
.rows > * + * { border-top: 2px solid rgb(var(--edge)); }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x { overflow-x: auto; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.key {
  font: 700 0.8125rem/1 ui-monospace, SFMono-Regular, monospace;
  border: 2px solid rgb(var(--edge-strong)); border-bottom-width: 3px;
  border-radius: 6px; padding: 0.25rem 0.4375rem; color: rgb(var(--ink-2));
  background: rgb(var(--card-2));
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
}
