:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1116;
  --surface: #171B22;
  --surface-2: #1E232B;
  --card: #1F252E;
  --lane: #12161C;
  --hover: #262C35;
  --seg-on: #2C333D;
  --ink: #E8EAED;
  --muted: #A3AAB5;
  --faint: #7D8592;
  --line: #2A3039;
  --line-2: #232830;
  --line-strong: #3A414C;
  --field: #3A414C;
  --accent: #F08A3C;
  --accent-hover: #F59B55;
  --accent-ink: #1A1006;
  --accent-soft: #2A1D12;
  --strong-bg: #E8EAED; --strong-fg: #0E1116; --strong-hover: #FFFFFF;
  --logo-bg: #E8EAED; --logo-fg: #0E1116;
  --repairs: #DE7428;
  --mfg: #5A88E8;
  --chart-grid: #262C35;
  --chart-axis: #3F4652;
  --ok: #3FB96B; --ok-bg: #12291B; --ok-ink: #A6E6BD;
  --warn: #E8A13A; --warn-bg: #2E2312; --warn-ink: #F6D19A;
  --bad: #F06A5E; --bad-bg: #321816; --bad-ink: #F9BDB6;
  --info: #6E9BF5; --info-bg: #17223A;
  --neutral-dot: #7D8592;
  --urgent-bg: #C2341F;
  --drop: #18233A; --drop-line: #4E6AA8; --drop-ink: #A9BEF0;
  --filled: #13271B;
  --toast-bg: #E8EAED; --toast-fg: #0E1116; --toast-ok: #1A7F37;
  --scrim: rgba(0, 0, 0, .62);
  --shadow: rgba(0, 0, 0, .45);
  --particle-line: rgba(200, 212, 235, .16);
  --insert-fill: #4A515C; --insert-edge: #D6DAE0; --insert-groove: #9AA3AF; --insert-sink: #3A4049;
  --tool-carbide: #59616D; --tool-hss: #7C8794; --tool-edge: #D6DAE0; --tool-groove: #2B3038; --tool-shine: rgba(255,255,255,.22); --tool-gullet: #1E2228; --tool-band: #D4A23C;
  --steel: #5E6672; --steel-ss: #8B95A2; --steel-edge: #D6DAE0; --steel-ring: rgba(255,255,255,.10); --steel-shine: rgba(255,255,255,.28);
  --jobno-r-bg: rgba(222, 116, 40, .18); --jobno-r-fg: #F7B07A; --jobno-r-line: rgba(222, 116, 40, .45);
  --jobno-m-bg: rgba(90, 136, 232, .20); --jobno-m-fg: #A9C1F7; --jobno-m-line: rgba(90, 136, 232, .5);
  --particle-alpha: .95;
  --ic-bg: rgba(255, 255, 255, .06);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "SF Mono", Menlo, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FA;
  --card: #FFFFFF;
  --lane: #E9EBEE;
  --hover: #EEF0F3;
  --seg-on: #FFFFFF;
  --ink: #1B1F24;
  --muted: #5B6270;
  --faint: #8A919C;
  --line: #E2E4E8;
  --line-2: #F0F1F3;
  --line-strong: #C9CDD4;
  --field: #D5D9DF;
  --accent: #C2410C;
  --accent-hover: #A8370A;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFF7F1;
  --strong-bg: #1B1F24; --strong-fg: #FFFFFF; --strong-hover: #000000;
  --logo-bg: #1B1F24; --logo-fg: #FFFFFF;
  --repairs: #D9590F;
  --mfg: #2B59C3;
  --chart-grid: #ECEEF1;
  --chart-axis: #B9BEC6;
  --ok: #1A7F37; --ok-bg: #E9F6EC; --ok-ink: #14532D;
  --warn: #B54708; --warn-bg: #FFF4EC; --warn-ink: #5C2A06;
  --bad: #B42318; --bad-bg: #FEF3F2; --bad-ink: #7A1A12;
  --info: #2B59C3; --info-bg: #EEF2FC;
  --neutral-dot: #8A919C;
  --urgent-bg: #B42318;
  --drop: #DDE4F3; --drop-line: #8A9BC4; --drop-ink: #3B4F86;
  --filled: #F2FAF4;
  --toast-bg: #1B1F24; --toast-fg: #FFFFFF; --toast-ok: #6FD38D;
  --scrim: rgba(20, 24, 31, .45);
  --shadow: rgba(20, 24, 31, .14);
  --particle-line: rgba(27, 31, 36, .13);
  --insert-fill: #C9CED6; --insert-edge: #2E343C; --insert-groove: #6B7380; --insert-sink: #B4BAC3;
  --tool-carbide: #A9B0BA; --tool-hss: #CDD4DC; --tool-edge: #2E343C; --tool-groove: #5D6571; --tool-shine: rgba(255,255,255,.7); --tool-gullet: #6E7682; --tool-band: #C98A12;
  --steel: #AEB5BF; --steel-ss: #D3D9E0; --steel-edge: #2E343C; --steel-ring: rgba(0,0,0,.10); --steel-shine: rgba(255,255,255,.75);
  --jobno-r-bg: #FFF1E7; --jobno-r-fg: #8F3505; --jobno-r-line: #F5C29E;
  --jobno-m-bg: #EDF2FC; --jobno-m-fg: #1E4596; --jobno-m-line: #B9CBF2;
  --particle-alpha: .7;
  --ic-bg: rgba(27, 31, 36, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.header { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.logo { width: 48px; height: 48px; border-radius: 12px; background: var(--logo-bg); color: var(--logo-fg); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; overflow: hidden; flex: none; border: 0; padding: 0; }
.logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.title-block { display: flex; flex-direction: column; line-height: 1.2; }
.title-block .t { font-size: 20px; font-weight: 700; }
.title-block .s { font-size: 13px; color: var(--muted); }
.main { flex: 1; width: 100%; padding: 20px 24px 32px; }
.main.narrow { max-width: 1280px; margin: 0 auto; }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 24px; background: var(--surface); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.footer .saved { display: flex; align-items: center; gap: 8px; }
.footer .saved::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 16px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); font-size: 15px; font-weight: 500; color: var(--ink); white-space: nowrap; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.dark { background: var(--strong-bg); border-color: var(--strong-bg); color: var(--strong-fg); font-weight: 600; }
.btn.dark:hover:not(:disabled) { background: var(--strong-hover); }
.btn.danger { color: var(--bad); font-weight: 600; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.icon { width: 44px; padding: 0; }
.btn.sm.icon { width: 36px; }
.btn.big { height: 52px; font-size: 16px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 14px; }

.user-btn { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 12px 0 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.user-btn:hover { background: var(--hover); }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none; }
.avatar.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; background: var(--bg); color: var(--ink); }
.menu { position: absolute; right: 0; top: 56px; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px var(--shadow); padding: 6px; z-index: 50; display: flex; flex-direction: column; }
.menu .mi { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 15px; }
.menu .mi:hover { background: var(--hover); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .label { font-size: 12px; color: var(--muted); padding: 6px 12px 2px; }

/* ---------- forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; min-width: 0; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.input, .select, .textarea { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); font-size: 15px; font-weight: 400; outline: none; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--bad); }
.input.filled { background: var(--filled); }
.err { color: var(--bad); font-size: 13px; font-weight: 400; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > * { flex: 1 1 180px; }
.search { display: flex; align-items: center; gap: 8px; height: 44px; width: 320px; max-width: 100%; padding: 0 12px; background: var(--surface); border: 1px solid var(--field); border-radius: 10px; }
.search input { border: 0; outline: none; flex: 1; min-width: 0; background: transparent; font-size: 14px; }
.search:focus-within { border-color: var(--ink); }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--lane); border-radius: 10px; }
.seg button { height: 38px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--seg-on); font-weight: 600; box-shadow: 0 1px 2px var(--shadow); }
.seg button.urgent[aria-pressed="true"] { background: var(--urgent-bg); color: #fff; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar .l, .toolbar .r { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- panels, tables, chips */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.panel.pad { padding: 20px 24px; }
.panel h2 { font-size: 18px; font-weight: 600; }
.panel .sub { font-size: 14px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; padding: 12px 16px; background: var(--surface-2); color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--surface-2); }
table.data tr.new td { background: var(--accent-soft); }
table.data .num { text-align: right; white-space: nowrap; }
table.data .nowrap { white-space: nowrap; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 16px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.empty .btn { margin-top: 12px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--bg); color: var(--ink); white-space: nowrap; }
.chip .d { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral-dot); flex: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); } .chip.ok .d { background: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); } .chip.warn .d { background: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); } .chip.bad .d { background: var(--bad); }
.chip.info { background: var(--info-bg); } .chip.info .d { background: var(--info); }
/* job number badge: orange for Repairs, blue for Manufacturing */
.jobno { display: inline-flex; align-items: center; font-family: var(--mono); font-weight: 700; font-size: 14px; letter-spacing: .02em; padding: 2px 9px; border-radius: 7px; border: 1px solid; white-space: nowrap; line-height: 1.45; }
.jobno.r { background: var(--jobno-r-bg); color: var(--jobno-r-fg); border-color: var(--jobno-r-line); }
.jobno.m { background: var(--jobno-m-bg); color: var(--jobno-m-fg); border-color: var(--jobno-m-line); }
.jobno.big { font-size: 17px; padding: 3px 11px; }
/* stock picker (booking stock to a job, product materials) */
.stock-pick-btn { display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; min-width: 0; }
.stock-pick-btn .sp-btn-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-panel { position: fixed; z-index: 80; display: flex; flex-direction: column; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 18px 44px var(--shadow); overflow: hidden; }
.sp-head { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex: none; }
.sp-head .search { height: 40px; }
.sp-search-input { border: 0; outline: none; flex: 1; min-width: 0; background: transparent; font-size: 14px; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-chip { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 12px; color: var(--muted); }
.sp-chip[aria-pressed="true"] { background: var(--seg-on); color: var(--ink); border-color: var(--line-strong); font-weight: 600; }
.sp-head .muted { font-size: 12px; flex: none; }
.sp-list { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 6px; }
.sp-group { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--line-2); }
.sp-count { margin-left: auto; font-weight: 600; color: var(--faint); }
.sp-opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 6px 12px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.sp-opt.active { background: var(--hover); }
.sp-opt[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
.sp-opt.disabled { cursor: not-allowed; opacity: .5; }
.sp-thumb { flex: none; width: 36px; height: 36px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.stock-pick-btn .sp-thumb { width: 30px; height: 30px; }
.sp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sp-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-qty { flex: none; font-size: 13px; font-weight: 600; }
.sp-qty.low { color: var(--warn); }
.sp-qty.out { color: var(--bad); font-weight: 500; }
.sp-clear { flex: none; border: 0; border-top: 1px solid var(--line); background: transparent; padding: 10px; font-size: 13px; color: var(--accent); font-weight: 600; }

/* insert drawings (Inventory › Tooling › Cutting Inserts) */
.insert-thumb { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.insert-preview { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.ip-draw { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; }
.ip-rows { flex: 1 1 240px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; min-width: 0; }
.ip-row { display: flex; gap: 10px; align-items: baseline; }
.ip-code { flex: none; min-width: 34px; text-align: center; font-family: var(--mono); font-weight: 700; font-size: 13px; padding: 1px 6px; border-radius: 6px; background: var(--ic-bg); border: 1px solid var(--line); }
.tag-urgent { font-size: 12px; font-weight: 600; color: var(--bad); background: var(--bad-bg); border-radius: 6px; padding: 2px 8px; }
.tag-new { font-size: 11px; font-weight: 600; color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: 1px 6px; }
.note-tag { font-size: 12px; color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: 4px 8px; align-self: flex-start; }
.badge-sample { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 10px; border: 1px dashed var(--line-strong); border-radius: 999px; }

/* ---------- home tiles */
.home { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 32px 0; min-height: calc(100vh - 160px); }
.home h1 { font-size: 28px; text-align: center; }
.home p { margin: 6px 0 0; color: var(--muted); text-align: center; }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; max-width: 1010px; }
.tile { position: relative; width: 185px; height: 185px; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; text-align: center; color: var(--ink); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.tile:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 12px 28px var(--shadow); border-color: var(--line-strong); }
.tile .ic { width: 64px; height: 64px; border-radius: 16px; background: var(--ic-bg); display: flex; align-items: center; justify-content: center; color: var(--accent); backdrop-filter: blur(2px); }
.tile .nm { font-size: 17px; font-weight: 600; line-height: 1.2; }
.tile .sb { font-size: 13px; color: var(--muted); }
.tile .lowbadge { position: absolute; top: 12px; right: 12px; }

/* Particle field: one shared simulation drawn behind every tile
   (see js/particles.js), so the effect flows across the tiles in sync. */
.tile { overflow: hidden; isolation: isolate; }
.tile-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; border-radius: inherit; }
.tile .ic, .tile .nm, .tile .sb, .tile .lowbadge { position: relative; }
.tile .lowbadge { position: absolute; }
@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
}
.tile.big { width: 200px; height: 200px; }

/* ---------- crumbs */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 14px; margin-bottom: 12px; }
.crumbs button { height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--accent); font-weight: 500; }
.crumbs .cur { padding: 0 8px; font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 26px; }
.page-head .sub { color: var(--muted); font-size: 15px; margin-top: 2px; }

/* ---------- board */
.board { display: flex; gap: 16px; align-items: stretch; overflow-x: auto; padding-bottom: 8px; }
.lane { flex: 1 1 0; min-width: 230px; min-height: calc(100vh - 250px); background: var(--lane); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; transition: background .12s ease; }
.lane.over { background: var(--drop); box-shadow: inset 0 0 0 2px var(--drop-line); }
.lane-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 2px; }
.lane-head .n { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.lane-head .n i { width: 10px; height: 10px; border-radius: 50%; }
.lane-head .c { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 2px 10px; }
.lane-empty { border: 2px dashed var(--line-strong); border-radius: 12px; padding: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.drop-hint { height: 64px; border: 2px dashed var(--drop-line); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--drop-ink); }
.jobcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; cursor: grab; box-shadow: 0 1px 2px var(--shadow); }
.jobcard:hover { border-color: var(--line-strong); }
.jobcard.dragging { opacity: .4; border-color: var(--drop-line); }
.jobcard .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.jobcard .no { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
.jobcard .who { font-size: 14px; font-weight: 500; }
.jobcard .what { font-size: 13px; color: var(--muted); }
.jobcard .bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line-2); }
.jobcard .due { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.jobcard .due.late { color: var(--bad); font-weight: 600; }
.jobcard .acts { display: flex; align-items: center; gap: 4px; }
.mv { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.mv:hover { background: var(--hover); }

/* ---------- drawer / modal / toast */
.backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 60; border: 0; }
/* Pop-up windows open in the centre of the screen */
.drawer { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 600px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 64px var(--shadow); z-index: 61; display: flex; flex-direction: column; overflow: hidden; animation: pop-in .16s ease-out; }
.drawer.wide { width: 820px; }
.backdrop { animation: fade-in .16s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer, .backdrop { animation: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 20px; font-weight: 700; }
.drawer-head .s { font-size: 13px; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); }
.drawer-foot .btn { flex: 1 1 120px; }
.drawer-foot { justify-content: flex-end; }
.modal { position: fixed; left: 50%; top: 18vh; transform: translateX(-50%); width: 440px; max-width: calc(100% - 32px); background: var(--surface); border-radius: 16px; box-shadow: 0 20px 48px var(--shadow); z-index: 71; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-size: 19px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 10px; }
.backdrop.top { z-index: 70; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: var(--toast-bg); color: var(--toast-fg); border-radius: 12px; font-size: 14px; box-shadow: 0 10px 28px var(--shadow); z-index: 90; max-width: calc(100% - 32px); }
.toast.error { background: #B42318; color: #fff; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; font-size: 14px; }
.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-weight: 500; overflow-wrap: anywhere; }
.section-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.timeline { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.timeline .ev { display: flex; gap: 10px; }
.timeline .ev .when { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 112px; }
.box { border: 1px solid var(--line); border-radius: 12px; }
.box-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.box-row:last-child { border-bottom: 0; }

/* ---------- forms pages */
.form-page { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; max-width: 1240px; margin: 0 auto; }
.form-page .col-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.form-page .col-side { flex: 1 1 300px; min-width: 0; position: sticky; top: 92px; display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; flex-direction: column; gap: 14px; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.step-head .l { display: flex; align-items: center; gap: 10px; }
.step-no { width: 28px; height: 28px; border-radius: 50%; background: var(--strong-bg); color: var(--strong-fg); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.scanbox { flex: 1 1 320px; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 12px; background: var(--surface); }
.scanbox input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-family: var(--mono); font-size: 18px; }
.scanbox.found { border-color: var(--ok); }
.scanbox.missing { border-color: var(--warn); }
.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.banner.ok { background: var(--ok-bg); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.bad { background: var(--bad-bg); color: var(--bad-ink); }
.banner.neutral { background: var(--bg); color: var(--muted); }
.picked { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.picker { position: relative; }
.picker .list { position: absolute; left: 0; right: 0; top: 52px; z-index: 30; max-height: 280px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 28px var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.picker .opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.picker .opt:hover, .picker .opt.active { background: var(--hover); }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.summary-row .v { font-weight: 500; text-align: right; }
.line-item { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.line-item .row { align-items: flex-end; }

/* ---------- dashboard */
.kpis { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.kpi { flex: 1 1 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi .k { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.kpi .v { font-size: 32px; font-weight: 700; line-height: 1.1; }
.kpi .s { font-size: 13px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.legend { display: flex; gap: 14px; font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 8px 20px var(--shadow); padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; min-width: 170px; z-index: 5; }
.chart-tip .r { display: flex; justify-content: space-between; gap: 12px; }
.grid-2 { display: flex; flex-wrap: wrap; gap: 20px; }
.grid-2 > * { flex: 1 1 460px; min-width: 0; }

/* ---------- labels / print */
.label-preview { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #FFFFFF; color: #1B1F24; }
.label-preview .muted { color: #5B6270; }
.label-preview svg { max-width: 100%; }
#print-area { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  #app, .backdrop, .drawer, .modal, .toast { display: none !important; }
  #print-area { display: block; color: #000; font-family: var(--font); }
  .p-label { width: 62mm; padding: 2mm; display: flex; flex-direction: column; align-items: center; gap: 1mm; page-break-after: always; }
  .p-label svg { width: 58mm; height: auto; }
  .p-label .qr { width: 18mm; height: 18mm; }
  .p-label .row-l { display: flex; align-items: center; gap: 2mm; }
  .p-label .t { font-size: 8pt; font-weight: 600; text-align: center; }
  .p-job { font-size: 10.5pt; }
  .p-job h1 { font-size: 20pt; margin: 0 0 2mm; }
  .p-job table { width: 100%; border-collapse: collapse; margin: 3mm 0; }
  .p-job td, .p-job th { border: 1px solid #999; padding: 2mm 3mm; text-align: left; vertical-align: top; }
  .p-job th { background: #eee; width: 32%; }
  .p-job .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6mm; border-bottom: 2px solid #000; padding-bottom: 3mm; margin-bottom: 3mm; }
  .p-job .head img { max-height: 18mm; max-width: 50mm; }
  .p-job .box { border: 1px solid #999; min-height: 30mm; padding: 2mm 3mm; margin: 2mm 0; border-radius: 0; }
  .p-job .sig { display: flex; gap: 10mm; margin-top: 8mm; }
  .p-job .sig div { flex: 1; border-top: 1px solid #000; padding-top: 1mm; font-size: 9pt; }
}

/* ---------------------------------------------------------------- sign-in */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.signin-card { width: 100%; max-width: 420px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 24px 60px -24px var(--shadow); border-top: 3px solid var(--accent); }
.signin-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.signin-title { font-size: 20px; font-weight: 700; }
.signin-card .btn.big { width: 100%; margin-top: 4px; }
.signin-help { margin: 0; font-size: 13px; text-align: center; }
