/* Dart Orders — design tokens
   Dart blue:  brand, actions, order tags (lamacoid plates)
   Graphite:   text          Cool grey: surfaces
   Filament:   ONLY for "needs you" (waiting on a PO, no signal) */
@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('/fonts/barlow-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url('/fonts/barlow-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('/fonts/barlow-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow SC'; font-weight: 600; font-display: swap; src: url('/fonts/barlow-sc-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow SC'; font-weight: 700; font-display: swap; src: url('/fonts/barlow-sc-700.woff2') format('woff2'); }
@font-face { font-family: 'Raleway'; font-weight: 300; font-display: swap; src: url('/fonts/raleway-300.woff2') format('woff2'); }

:root {
  --blue: #002495; --blue-2: #1a3cb3; --blue-tint: #e8edfb;
  --ink: #1d2330; --ink-2: #545c6e; --ink-3: #8a91a1;
  --bg: #f3f5f8; --surface: #fff; --line: #e1e5ec; --line-2: #cfd5df;
  --filament: #f5c518; --filament-ink: #7a5d00; --filament-tint: #fff6d6;
  --danger: #b42318; --ok: #0f7b4a;
  --cond: 'Barlow SC', 'Barlow', system-ui, sans-serif;
  --tabbar-h: 64px;
  /* legacy aliases used in markup */
  --navy: var(--blue); --navy-2: var(--blue-2); --brand: var(--blue); --muted: var(--ink-2); --text: var(--ink); --card: var(--surface);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--filament); outline-offset: 2px; }
::selection { background: var(--blue-tint); }

/* ---------- header ---------- */
#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { text-decoration: none; flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 40px; width: auto; display: block; }
.brand-sub { font-family: 'Raleway', sans-serif; font-weight: 300; font-size: 20px; letter-spacing: 2px; color: var(--blue);
  border-left: 1px solid var(--line-2); padding-left: 12px; }
.brand-font { font-family: 'Raleway', sans-serif; font-weight: 300; color: var(--blue); letter-spacing: 1px; }
.iconbtn, #menu { display: none !important; }
.netpill { background: var(--filament); color: #3b2d00; font-family: var(--cond); font-weight: 600; font-size: 13px; padding: 3px 10px; border-radius: 4px; }
#banner { background: var(--filament-tint); color: var(--filament-ink); border-bottom: 1px solid #f0dc8f; padding: 9px 16px; font-size: 14px; }

/* ---------- bottom tab bar ---------- */
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h); color: var(--ink-3); text-decoration: none; font-size: 12px; font-weight: 500; }
#tabbar a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabbar a.on { color: var(--blue); }
#tabbar a.new span.plus { width: 44px; height: 44px; border-radius: 12px; background: var(--blue); color: #fff; display: grid; place-items: center; margin-top: -2px; }
#tabbar a.new span.plus svg { stroke: #fff; stroke-width: 2.4; }
#tabbar a.new { color: var(--blue); font-weight: 600; }
@media (min-width: 760px) {
  #tabbar { left: 50%; right: auto; transform: translateX(-50%); bottom: 16px; width: 520px; border: 1px solid var(--line);
    border-radius: 16px; box-shadow: 0 8px 28px rgba(16, 24, 48, .12); padding-bottom: 0; }
}

main { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); }
h1 { font-family: var(--cond); font-weight: 700; font-size: 28px; line-height: 1.1; margin: 4px 0 16px; letter-spacing: .2px; }
h2 { font-family: var(--cond); font-weight: 600; font-size: 19px; margin: 26px 0 10px; }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
a.card { display: block; color: inherit; text-decoration: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); font-size: 14px; }
.small { font-size: 13px; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--ink-2); padding: 48px 16px; }
.err { color: var(--danger); font-size: 14px; margin-top: 8px; }

/* Order / job number: Dart blue condensed type, no box */
.tag, .orderno { display: inline-block; font-family: var(--cond); font-weight: 700; letter-spacing: .6px; color: var(--blue);
  font-size: 17px; line-height: 1.2; white-space: nowrap; }
.tag.done { color: var(--ink-3); }
.tag.pending { color: var(--ink-3); }
.plate { font-size: 34px; letter-spacing: 1px; line-height: 1; }

/* Status: a dot and a word. Colour only where it matters. */
.st, .pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.st::before, .pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.s-SUBMITTED::before, .s-IN_PROGRESS::before { background: var(--filament); box-shadow: 0 0 0 2px var(--filament-tint); }
.s-PO_SENT::before { background: var(--blue); }
.s-COMPLETE { color: var(--ink-3); } .s-COMPLETE::before { background: var(--ok); }
.s-PENDING::before { background: transparent; box-shadow: inset 0 0 0 2px var(--filament); }

/* ---------- order lists ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 8px; }
.orow { display: grid; grid-template-columns: 84px 1fr auto; gap: 4px 12px; align-items: start; padding: 13px 14px;
  text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
.orow:first-child { border-top: 0; }
.orow:active { background: #f6f8fb; }
.orow .tag { margin-top: 1px; justify-self: start; }
.orow-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.orow-meta { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--ink-2); }
.orow-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.age { font-size: 13px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.age.old { color: var(--filament-ink); font-weight: 600; }
.orow .err { grid-column: 1 / -1; margin: 0; }

.sec { display: flex; align-items: baseline; gap: 10px; margin: 26px 2px 10px; }
.sec:first-of-type { margin-top: 10px; }
.sec-name { font-family: var(--cond); font-weight: 700; font-size: 20px; }
.sec-count { font-family: var(--cond); font-weight: 600; font-size: 20px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sec-hint { font-size: 13px; color: var(--ink-2); margin-left: auto; }
.sec.needs .sec-name::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--filament);
  margin-right: 8px; vertical-align: 2px; box-shadow: 0 0 0 3px var(--filament-tint); }
.sec .linkbtn { margin-left: auto; }
.quiet { color: var(--ink-2); font-size: 14px; padding: 4px 2px 6px; }
.jobhead { font-family: var(--cond); font-weight: 600; font-size: 17px; margin: 22px 2px 8px; display: flex; gap: 10px; align-items: center; }

/* ---------- order detail ---------- */
.ohead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 4px; }
.ojob { font-family: var(--cond); font-weight: 600; font-size: 22px; margin: 14px 0 0; }
.oaddr { color: var(--ink-2); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px 18px; margin: 16px 0 4px; }
.facts dt { font-size: 13px; color: var(--ink-3); }
.facts dd { margin: 0; font-weight: 500; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 18px 0 6px; list-style: none; padding: 0; }
.steps li { font-size: 12px; color: var(--ink-3); padding-top: 9px; border-top: 4px solid var(--line); font-weight: 500; }
.steps li.done { border-top-color: var(--blue); color: var(--ink); }
.steps li.now { border-top-color: var(--blue); color: var(--blue); font-weight: 600; }
.steps.waiting li.now { border-top-color: var(--filament); color: var(--filament-ink); }

.bom { list-style: none; margin: 0; padding: 0; counter-reset: line; }
.bom li { counter-increment: line; display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.bom li:first-child { border-top: 0; }
.bom li::before { content: counter(line); color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.material { white-space: pre-wrap; font: 500 15px/1.45 'Barlow', sans-serif; background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0; }
.notes { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-size: 15px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 14px 14px; position: relative; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }

/* ---------- forms & buttons ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input, select, textarea { width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 200px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--blue); flex: none; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; margin: 10px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 16px/1 'Barlow', sans-serif;
  padding: 0 18px; min-height: 48px; border-radius: 8px; border: 1.5px solid var(--blue); cursor: pointer; text-decoration: none;
  background: var(--blue); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.ghost, .btn.ok, .btn.amber { background: #fff; color: var(--blue); border-color: var(--line-2); }
.btn.amber { border-color: var(--blue); }
.btn.danger { background: #fff; color: var(--danger); border-color: #efc6c2; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: default; }
.linkbtn { background: none; border: 0; padding: 4px 0; font: 600 14px 'Barlow', sans-serif; color: var(--blue); cursor: pointer; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.actions.stack { flex-direction: column; } .actions.stack .btn { width: 100%; }
.actions .more { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.filters .full { grid-column: 1 / -1; }
.filters input { background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%238a91a1' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 12px center; padding-left: 38px; }
.filters select { padding: 10px; font-size: 15px; }
@media (min-width: 700px) { .filters { grid-template-columns: 2fr 1fr 1fr; } .filters .full { grid-column: auto; } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-3); font-weight: 600; font-size: 13px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 12px; text-decoration: none; color: var(--ink-2); white-space: nowrap; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--blue); border-bottom-color: var(--blue); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 50; max-width: 90vw; font-weight: 500;
  box-shadow: 0 8px 24px rgba(16,24,48,.25); }
.login { max-width: 400px; margin: 8vh auto 0; }
.login .logo img { width: 100%; height: auto; display: block; }
.login-sub { text-align: center; font-size: 20px; letter-spacing: 3px; margin: 4px 0 8px; }
dialog { border: 0; border-radius: 16px; padding: 20px; width: min(480px, 94vw); color: var(--ink); }
dialog::backdrop { background: rgba(16, 22, 40, .55); }
dialog h2 { margin-top: 0; }
.tagbox { font-family: var(--cond); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; font-size: 20px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.thumb img { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 6px; background: var(--bg); }
.slip-preview { width: 100%; max-height: 300px; object-fit: contain; margin-top: 10px; border-radius: 8px; background: var(--bg); }
.imgdlg { width: min(900px, 96vw); } .imgdlg img { width: 100%; height: auto; display: block; border-radius: 8px; }
.who { display: flex; align-items: center; gap: 14px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--blue-tint); color: var(--blue); display: grid; place-items: center;
  font-family: var(--cond); font-weight: 700; font-size: 20px; flex: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

button.orow { width: 100%; background: none; border: 0; border-top: 1px solid var(--line); font: inherit; text-align: left; cursor: pointer; color: inherit; }
button.orow:first-child { border-top: 0; }

.linkbtn.danger-link { color: var(--danger); }

.fold { margin-top: 18px; }
.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; padding: 6px 2px 12px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: 'Show'; margin-left: auto; font: 600 14px 'Barlow', sans-serif; color: var(--blue); }
.fold[open] > summary::after { content: 'Hide'; }
.lifecycle { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

.misc-card { border-style: dashed; border-color: var(--line-2); background: #fbfcfe; }
