/* ============================================================================
   EDDAHOME 2.0 — "Job Card" design system.
   Source of truth for tokens and rules: DESIGN.md in the repo root.
   Type sizes come ONLY from the ramp: 11 / 12 / 13 / 14 / 16 / 18 / 21 / 28.
   Spacing is a 4px base scale. Elevation is declared ONCE per surface:
   panels and cards sit on borders; only overlays (modal, palette, toast,
   print-preview) cast a shadow.
   ========================================================================== */

/* ---------- fonts (self-hosted — the app runs offline) ---------- */
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/plex-sans-var.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/plex-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/plex-mono-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* warm-grey family — one gray temperature everywhere */
  --bg: #f4f3f0;
  --panel: #ffffff;
  --ink: #211f1c;
  --muted: #6e6960;
  --faint: #9b958a;
  --line: #e6e3dc;
  --line-soft: #f0eee9;
  --th-bg: #faf9f6;

  /* brand red — reserved for primary actions, the logo, and stamps */
  --brand: #c5202a; --brand-dark: #a31219; --brand-deep: #8c0c0c;
  --brand-tint: #faeeed; --accent: #c5202a;

  /* status colors, desaturated a step and warmed to sit with the neutrals */
  --ok: #1f7448; --ok-tint: #e9f2ec;
  --warn: #9a5b0b; --warn-tint: #f8f0e0;
  --bad: #b3271d; --bad-tint: #faedeb;
  --info: #295fa6; --info-tint: #ebf1f8;

  --sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', system-ui, Roboto, Arial, sans-serif;
  --mono: 'IBM Plex Mono', 'Cascadia Mono', Consolas, Menlo, monospace;

  /* the ONLY shadow: overlays that float above the page */
  --shadow-pop: 0 18px 50px -12px rgba(33, 31, 28, .28);

  --radius: 10px;
  --r-sm: 6px; --r-md: 8px;

  /* motion — one strong ease-out; UI stays under 200ms */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans); background: var(--bg); color: var(--ink);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- browser surfaces carry the design too ---------- */
::selection { background: #f2d8d5; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
* { scrollbar-width: thin; scrollbar-color: #d8d4cb transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d8d4cb; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- icons (inline SVG sprite in index.html) ---------- */
.ico {
  width: 15px; height: 15px; flex-shrink: 0; vertical-align: -2px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico.lg { width: 17px; height: 17px; }

/* ---------- document identity: numbers & stamps ---------- */
/* Every PO / REQ / GRN / MO / INSP number is set in mono — the visual anchor
   of a register, the way job numbers read in a physical book. */
.docnum { font-family: var(--mono); font-weight: 600; font-size: .95em; letter-spacing: .02em; }

/* Status stamp for document detail pages (and the printable PO). */
.stamp {
  display: inline-block; font-family: var(--mono); font-weight: 600; font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase; line-height: 1;
  border: 2px solid currentColor; border-radius: 5px; padding: 4px 9px 3px;
  transform: rotate(-2deg); vertical-align: 3px; white-space: nowrap;
}
.stamp.ok { color: var(--ok); }
.stamp.warn { color: var(--warn); }
.stamp.bad { color: var(--bad); }
.stamp.info { color: var(--info); }
.stamp.mut { color: var(--faint); }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--panel); border-right: 1px solid var(--line); flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.logo { display: block; padding: 14px 16px 10px; border-bottom: 1px solid var(--line-soft); }
.logo img { display: block; width: 100%; height: auto; border-radius: var(--r-sm); }
.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 1px 0;
  color: #45403a; font-size: 13px; font-weight: 500; border-radius: 7px;
}
.nav a .ico { color: var(--faint); }
.nav a:hover { background: var(--line-soft); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; }
.nav a.active .ico { color: var(--brand); }
.nav .sect {
  padding: 16px 10px 5px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--faint); font-weight: 600;
}
.sidebar .foot { padding: 12px 16px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line-soft); }

/* sidebar search trigger (opens the command palette) */
.nav-search {
  display: flex; align-items: center; gap: 8px; width: calc(100% - 4px); margin: 8px 2px 2px;
  padding: 7px 10px; font-family: inherit; font-size: 13px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer;
}
.nav-search:hover { border-color: #c9c4ba; color: var(--ink); }
.nav-search kbd { margin-left: auto; }
kbd {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px;
}

.main { flex: 1; padding: 24px 32px 60px; max-width: 1280px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.3px; line-height: 1.25; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .k { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.card .v { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.card .v.small { font-size: 16px; }
.card.alert { border-color: #eecac5; background: #fffbfa; }
.card.alert .v { color: var(--bad); }
.card.good .v { color: var(--ok); }

/* ---------- panels & tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.panel-head { padding: 12px 18px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.1px; }
.panel-body { padding: 14px 18px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 8px 14px; background: var(--th-bg); color: var(--muted);
  font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, td.clickable:hover { background: #f8f7f4; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* batch header rows inside the receiving table */
tr.subhead td { background: var(--th-bg); font-weight: 600; border-top: 1px solid var(--line); }

/* receiving progress bars */
.bar { position: relative; height: 5px; background: var(--line-soft); border-radius: 4px; overflow: hidden; min-width: 70px; margin-top: 5px; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--ok); border-radius: 4px; }
.bar i.rej { background: var(--bad); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; background: var(--brand); color: #fff;
  border: 1px solid var(--brand); border-radius: var(--r-md); padding: 8px 15px;
  font-size: 13px; cursor: pointer; font-family: inherit; font-weight: 600;
  transition: background .12s ease, border-color .12s ease, transform 140ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn.secondary { background: var(--panel); color: #45403a; border: 1px solid #d3cfc6; }
.btn.small { padding: 4px 11px; font-size: 12px; border-radius: 7px; }
.btn.danger { background: var(--panel); color: var(--bad); border: 1px solid #ecc0ba; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
  .btn.secondary:hover { background: #faf9f6; color: var(--ink); border-color: #beb9ae; }
  .btn.danger:hover { background: var(--bad-tint); border-color: var(--bad); }
  .btn:disabled:hover { background: var(--brand); border-color: var(--brand); }
  .btn.secondary:disabled:hover { background: var(--panel); }
}

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.2px; white-space: nowrap; }
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.info { background: var(--info-tint); color: var(--info); }
.badge.mut { background: var(--line-soft); color: var(--muted); }

/* ---------- forms ---------- */
input, select, textarea {
  font-family: inherit; font-size: 13px; padding: 8px 11px; border: 1px solid #d3cfc6; border-radius: var(--r-md);
  background: var(--panel); color: var(--ink); width: 100%; transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #a39d92; box-shadow: 0 0 0 3px rgba(33, 31, 28, .07); }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
input[type=file] { padding: 6px; font-size: 12px; }
label { display: block; font-size: 12px; color: #57524a; margin-bottom: 5px; font-weight: 600; }
.field { margin-bottom: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(33, 31, 28, .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 46px 16px; z-index: 50; overflow-y: auto;
  transition: opacity .15s ease;
}
.modal {
  background: var(--panel); border-radius: 14px; width: 100%; max-width: 620px; box-shadow: var(--shadow-pop);
  transition: transform .18s var(--ease-out), opacity .18s ease;
}
.modal.wide { max-width: 900px; }
.modal-head { padding: 15px 20px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px 20px; max-height: 72vh; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 9px; }
.x { background: none; border: none; font-size: 21px; cursor: pointer; color: var(--faint); font-family: inherit; line-height: 1; }
.x:hover { color: var(--ink); }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #26231f; color: #fff; padding: 11px 16px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-pop); max-width: 400px;
  transition: transform .2s var(--ease-out), opacity .2s ease;
}
.toast.err { background: var(--bad); }

/* entrances — elements never appear from nothing */
@starting-style {
  .toast { opacity: 0; transform: translateY(8px); }
  .modal { opacity: 0; transform: scale(0.98); }
  .modal-back { opacity: 0; }
  .pal { opacity: 0; transform: scale(0.98); }
}

/* ---------- command palette (Ctrl+K) ---------- */
.pal-back {
  position: fixed; inset: 0; background: rgba(33, 31, 28, .4); z-index: 120;
  display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px;
}
.pal {
  width: 100%; max-width: 580px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-pop); overflow: hidden;
  transition: transform .18s var(--ease-out), opacity .18s ease;
}
.pal-input { display: flex; align-items: center; gap: 10px; padding: 2px 16px; border-bottom: 1px solid var(--line-soft); color: var(--faint); }
.pal-input input { border: none; box-shadow: none; border-radius: 0; padding: 13px 0; font-size: 16px; background: transparent; }
.pal-input input:focus { border: none; box-shadow: none; }
.pal-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.pal-group { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); padding: 10px 10px 4px; }
.pal-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md);
  cursor: pointer; font-size: 13px; color: var(--ink);
}
.pal-item .ico { color: var(--faint); }
.pal-item .meta { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.pal-item.active { background: var(--brand-tint); }
.pal-item.active .ico { color: var(--brand); }
.pal-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }
.pal-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 12px; }

/* ---------- skeleton loading ---------- */
.skel {
  border-radius: var(--r-sm); background: linear-gradient(90deg, var(--line-soft) 25%, #f7f6f2 37%, var(--line-soft) 63%);
  background-size: 400% 100%; animation: skel 1.2s ease infinite;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-page .skel { margin-bottom: 10px; }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.mini { font-size: 12px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.insight { background: var(--info-tint); border: 1px solid #ccdaeb; border-radius: 9px; padding: 10px 14px; font-size: 13px; }
.insight b { color: var(--info); }
.insight.warn { background: var(--warn-tint); border-color: #ecd9b4; }
.insight.warn b { color: var(--warn); }
.insight.ok { background: var(--ok-tint); border-color: #c2ddcc; }
.insight.ok b { color: var(--ok); }
.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }
.match-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: var(--panel); }
.match-row:hover { border-color: #beb9ae; }
.score { font-weight: 600; color: var(--brand); font-size: 13px; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

/* margin indicator on selling prices */
.margin-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.margin-chip.good { background: var(--ok-tint); color: var(--ok); }
.margin-chip.low { background: var(--warn-tint); color: var(--warn); }
.margin-chip.loss { background: var(--bad-tint); color: var(--bad); }

/* ---------- pipeline stepper ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.step { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 12px; color: var(--faint); font-weight: 500; }
.step .dot {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--faint); flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.step.done { color: var(--ok); }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.current { color: var(--ink); font-weight: 600; }
.step.current .dot { border-color: var(--brand); color: var(--brand); }
.step-arrow { color: var(--line); align-self: center; padding: 0 2px; font-size: 12px; }

/* ---------- tab strip (project / detail pages) ---------- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 18px; }
.tab {
  appearance: none; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px;
  padding: 9px 14px; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }
.tab .badge { font-size: 11px; padding: 1px 7px; }

/* ---------- filter chips & pager ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 5px 13px; border-radius: 999px; border: 1px solid #d3cfc6; background: var(--panel);
  color: #57524a; font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.chip:hover { border-color: #beb9ae; background: #faf9f6; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 11px 16px; font-size: 12px; color: var(--muted); }
.pager button { font-family: inherit; padding: 4px 11px; border: 1px solid #d3cfc6; background: var(--panel); border-radius: 7px; cursor: pointer; font-size: 12px; color: #45403a; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:not(:disabled):hover { background: #faf9f6; }

/* picker rows (full-page product picker) */
.pick-row td { padding: 10px 14px; }
.pick-row .pname { font-weight: 600; }
.pick-row input[type=number] { padding: 6px 9px; font-size: 13px; }
.table-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.table-toolbar input[type=search], .table-toolbar input[type=text] { max-width: 320px; }

/* ---------- guide page ---------- */
.guide-step { display: flex; gap: 15px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); }
.guide-step:last-child { border-bottom: none; }
.guide-step .n { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.guide-step h3 { font-size: 14px; margin-bottom: 4px; font-weight: 600; }
.guide-step p { font-size: 13px; color: #57524a; line-height: 1.55; }
.guide-step p + p { margin-top: 6px; }
.guide-step code, .kbd { background: var(--line-soft); color: var(--ink); border-radius: 5px; padding: 1px 6px; font-size: 12px; font-weight: 600; font-family: var(--mono); }
.flowline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 15px 18px; font-size: 12px; font-weight: 600; }
.flowline .fstep { background: var(--panel); color: #45403a; border: 1px solid var(--line); padding: 5px 11px; border-radius: var(--r-md); }
.flowline .farr { color: var(--faint); }
.flowline .fstep.done { background: var(--ok-tint); color: var(--ok); border-color: var(--ok); }
.flowline .fstep.now { background: var(--brand-tint); color: var(--brand-dark); border-color: var(--brand); font-weight: 600; }

/* ---------- printing (Ctrl/Cmd+P on any page — written for the Guide) ---------- */
@media print {
  @page { margin: 14mm 12mm; }

  /* screen chrome that means nothing on paper */
  .sidebar, #toast, #modal-root, .btn, button, .toolbar, .tabs, .nav-search { display: none !important; }

  html, body { background: #fff; color: #000; font-size: 10.5pt; line-height: 1.5; }
  .layout { display: block; min-height: 0; }
  .main { max-width: none; padding: 0; }

  a { color: #000; text-decoration: none; }

  .page-head { border-bottom: 1.5pt solid #000; padding-bottom: 8pt; margin-bottom: 14pt; }
  .page-head h1 { font-size: 20pt; }
  .page-head .sub { font-size: 10pt; color: #444; }

  .panel {
    border: none; border-top: 0.75pt solid #999; border-radius: 0;
    box-shadow: none; margin: 0 0 12pt; padding: 8pt 0 0; break-inside: auto;
  }
  .panel-head { border: none; padding: 0 0 6pt; display: block; }
  .panel-head h2 { font-size: 13pt; break-after: avoid; }
  .panel-body { padding: 0; }

  .panel:has(> .panel-body > .toolbar:only-child) { display: none; }

  .guide-step { break-inside: avoid; padding: 5pt 0; border: none; }
  .guide-step h3 { font-size: 11pt; break-after: avoid; }
  .guide-step .n {
    background: #fff !important; color: #000 !important;
    border: 0.75pt solid #000; box-shadow: none;
  }

  p, li { orphans: 3; widows: 3; }
  table { break-inside: auto; border-collapse: collapse; width: 100%; font-size: 9pt; }
  tr { break-inside: avoid; }
  th, td { border: 0.5pt solid #999; padding: 4pt 5pt; }
  th { background: #eee !important; }
  .scroll-x { overflow: visible !important; }

  .badge {
    background: #fff !important; color: #000 !important;
    border: 0.5pt solid #666; font-size: 8pt; padding: 1pt 4pt;
  }
  .flowline { break-inside: avoid; }
  .fstep { background: #fff !important; color: #000 !important; border: 0.5pt solid #666; }
  .muted, .mini.muted { color: #555 !important; }
  code { background: #f0f0f0 !important; color: #000 !important; }
  .insight { background: #f7f7f7 !important; color: #000 !important; border-color: #999 !important; }
}

/* ---------- printable PO document ---------- */
/* On screen: a full-page preview overlay with its own Print/Close bar.
   In print: the overlay is the ONLY thing on paper. */
.doc-back { position: fixed; inset: 0; z-index: 150; background: rgba(33, 31, 28, .55); overflow-y: auto; padding: 30px 16px; }
.doc-actions { max-width: 820px; margin: 0 auto 12px; display: flex; justify-content: flex-end; gap: 9px; }
.doc { background: #fff; max-width: 820px; margin: 0 auto; padding: 34px 40px; border-radius: var(--r-sm); box-shadow: var(--shadow-pop); color: #191713; font-size: 13px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; border-bottom: 2.5px solid var(--brand); padding-bottom: 14px; margin-bottom: 16px; }
.doc-head img { width: 150px; height: auto; }
.doc-head .doc-title { text-align: right; }
.doc-head .doc-title h1 { font-size: 21px; letter-spacing: 1.5px; font-weight: 600; }
.doc-head .doc-title .mini { margin-top: 3px; }
.doc-head .doc-title .docnum { font-size: 13px; }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.doc-box { border: 1px solid #ccc; border-radius: var(--r-sm); padding: 10px 13px; }
.doc-box h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #666; margin-bottom: 6px; }
.doc table { font-size: 12px; }
.doc th { background: #f2f2f2; color: #333; }
.doc th, .doc td { border: 0.5px solid #bbb; padding: 6px 9px; }
.doc .doc-total td { font-weight: 600; background: #fafafa; }
.doc-terms { margin-top: 16px; font-size: 12px; color: #333; }
.doc-terms h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #666; margin-bottom: 5px; }
.doc-sign { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 22px; margin-top: 44px; }
.doc-sign div { border-top: 1px solid #333; padding-top: 6px; font-size: 12px; text-align: center; color: #333; }

@media print {
  /* when a document overlay is open, print it and nothing else */
  body:has(.doc-back) .layout { display: none !important; }
  .doc-back { position: static; background: none; padding: 0; overflow: visible; }
  .doc-actions { display: none !important; }
  .doc { box-shadow: none; border-radius: 0; max-width: none; padding: 0; }
  .doc th, .doc td { border: 0.5pt solid #999; }
}

/* ---------- login ---------- */
.login-back {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  width: 100%; max-width: 360px; padding: 26px 28px;
}
.login-card img { display: block; width: 70%; margin: 0 auto 14px; border-radius: var(--r-md); }
.login-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; text-align: center; }
.login-card p { text-align: center; }

/* ---------- delivery planner ---------- */
.pl-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; }
.pl-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: grab; transition: border-color .12s ease;
}
.pl-row:hover { border-color: #beb9ae; }
.pl-row:active { cursor: grabbing; }
.pl-rank {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums;
}
.pl-grip { color: var(--faint); font-size: 15px; flex-shrink: 0; }
.pl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pl-main b { font-size: 13px; }
.pl-dates { display: flex; flex-direction: column; gap: 3px; text-align: right; flex-shrink: 0; color: var(--muted); }
.pl-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; padding: 12px 14px; }
.pl-day {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 8px; min-height: 84px;
  display: flex; flex-direction: column; gap: 5px; transition: border-color .12s ease, background .12s ease;
}
.pl-day.off { background: var(--line-soft); color: var(--muted); }
.pl-day.full { border-color: #eecac5; background: #fffbfa; }
.pl-day-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: #57524a; white-space: nowrap; }
.pl-cap { font-size: 11px; font-weight: 600; color: var(--muted); }
.pl-cap.bad { color: var(--bad); }
.pl-day-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pl-chip {
  background: var(--info-tint); color: var(--info); border: 1px solid #ccdaeb; border-radius: 7px;
  padding: 3px 8px; font-size: 11px; font-weight: 600; cursor: grab; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-chip.late { background: var(--bad-tint); color: var(--bad); border-color: #ecc0ba; }
.pl-chip:active { cursor: grabbing; }
.drop-hover { border-color: var(--brand) !important; background: var(--brand-tint) !important; }

@media (max-width: 900px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 50px; }
  .pl-cal { grid-template-columns: repeat(2, 1fr); }
  .pl-dates { text-align: left; }
}

/* ---------- reduced motion: keep fades, drop movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- inspection report: card-per-line layout (Build 9) ---------- */
.insp-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--panel, #fff); }
.insp-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.insp-card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.insp-card-grid.wide { grid-template-columns: 180px 1fr 1fr; margin-top: 4px; }
.insp-card-grid .field { margin-bottom: 0; }
@media (max-width: 900px) { .insp-card-grid, .insp-card-grid.wide { grid-template-columns: 1fr 1fr; } }
