:root {
  --bg: #eef1f3;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --ink: #1b242c;
  --muted: #5a6772;
  --line: #d6dde2;
  --rail: #1d262e;
  --rail-ink: #c9d2d9;
  --rail-active: #2a3640;
  --copper: #b05a24;
  --copper-strong: #8c4519;
  --copper-soft: #f7e8dd;
  --focus: #2f7dd1;

  --ok: #1f7a4d;
  --ok-soft: #e1f2e9;
  --warn: #9a6400;
  --warn-soft: #fbf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --info: #22609e;
  --info-soft: #e2edf8;
  --teal: #0f6f73;
  --teal-soft: #dcf1f1;
  --neutral-soft: #e8ecef;

  --font-display: "Rubik", "IBM Plex Sans Hebrew", "Segoe UI", Arial, sans-serif;
  --font-body: "IBM Plex Sans Hebrew", "Segoe UI", Arial, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 4px 16px rgba(20, 30, 40, .05);
  --rail-w: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11171c;
    --surface: #182027;
    --surface-2: #1d262e;
    --ink: #e4e9ed;
    --muted: #94a2ad;
    --line: #2b3741;
    --rail: #0b1014;
    --rail-ink: #aab6bf;
    --rail-active: #1a232a;
    --copper: #e0884c;
    --copper-strong: #f09e65;
    --copper-soft: #3a2619;
    --focus: #6aa8ec;
    --ok: #5cc493;
    --ok-soft: #173326;
    --warn: #e4b04d;
    --warn-soft: #362a12;
    --bad: #f07d74;
    --bad-soft: #3a1a18;
    --info: #79b0ea;
    --info-soft: #172a3d;
    --teal: #57c3c7;
    --teal-soft: #11302f;
    --neutral-soft: #242e36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #11171c;
  --surface: #182027;
  --surface-2: #1d262e;
  --ink: #e4e9ed;
  --muted: #94a2ad;
  --line: #2b3741;
  --rail: #0b1014;
  --rail-ink: #aab6bf;
  --rail-active: #1a232a;
  --copper: #e0884c;
  --copper-strong: #f09e65;
  --copper-soft: #3a2619;
  --focus: #6aa8ec;
  --ok: #5cc493;
  --ok-soft: #173326;
  --warn: #e4b04d;
  --warn-soft: #362a12;
  --bad: #f07d74;
  --bad-soft: #3a1a18;
  --info: #79b0ea;
  --info-soft: #172a3d;
  --teal: #57c3c7;
  --teal-soft: #11302f;
  --neutral-soft: #242e36;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}

img { max-width: 100%; display: block; }
a { color: var(--copper-strong); }
a:hover { color: var(--copper); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; font-weight: 500; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.num, .data { font-family: var(--font-data); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; text-align: right; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }

.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 0 8px; }
.brand:hover { color: #fff; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; line-height: 1.1; }
.brand-sub { display: block; font-family: var(--font-body); font-weight: 400; font-size: .75rem; color: var(--rail-ink); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #74828d; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--rail-ink); text-decoration: none;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-weight: 500;
}
.nav a:hover { background: var(--rail-active); color: #fff; }
.nav a[aria-current="page"] { background: var(--rail-active); color: #fff; box-shadow: inset -3px 0 0 #e0884c; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-inline-start: auto; background: #e0884c; color: #1b1007; font-size: .72rem; font-weight: 600; border-radius: 99px; padding: 1px 7px; font-family: var(--font-data); }

.rail-user { margin-top: auto; border-top: 1px solid #2c3842; padding: 14px 8px 0; display: grid; gap: 8px; font-size: .85rem; }
.rail-user strong { color: #fff; display: block; }
.rail-user form { margin: 0; }
.rail-user .linkish { color: var(--rail-ink); }

.topbar { display: none; }

.main { min-width: 0; padding-block: 28px 64px; padding-inline: clamp(16px, 3.5vw, 44px); }
.main-inner { max-width: 1180px; margin: 0 auto; display: grid; gap: 22px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.page-head .eyebrow { font-size: .78rem; letter-spacing: .06em; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 20px; display: grid; gap: 16px; min-width: 0; }
.panel-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 22px; align-items: start; }

.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.readout { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 2px; text-decoration: none; color: var(--ink); }
a.readout:hover { border-color: var(--copper); color: var(--ink); }
.readout .label { font-size: .8rem; color: var(--muted); }
.readout .value { font-family: var(--font-data); font-size: 1.7rem; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; direction: ltr; text-align: right; }
.readout .value small { font-size: .85rem; color: var(--muted); }
.readout.attention { border-color: var(--copper); background: linear-gradient(0deg, var(--copper-soft), var(--surface) 70%); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .92rem;
  padding: 9px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer; line-height: 1.3; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--copper); border-color: var(--copper); color: #fff; }
.btn-primary:hover { background: var(--copper-strong); border-color: var(--copper-strong); color: #fff; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-lg { padding: 14px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--copper-strong); cursor: pointer; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .8rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; min-height: 44px;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input[type="tel"], .input[type="email"] { direction: ltr; text-align: right; }
.field-error { color: var(--bad); font-size: .84rem; font-weight: 500; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--bad); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; min-width: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-inline-start: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: .85rem; white-space: nowrap; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--copper); flex: none; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; cursor: pointer; background: var(--surface); }
.choice:has(input:checked) { border-color: var(--copper); background: var(--copper-soft); }
.choice input { accent-color: var(--copper); width: 18px; height: 18px; margin-top: 3px; flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; user-select: none; }
.chip input:checked + span { background: var(--rail); color: #fff; border-color: var(--rail); }
.chip input:checked + span::before { content: "✓"; font-size: .85em; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: right; font-size: .76rem; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.table .row-link:hover { color: var(--copper-strong); text-decoration: underline; }
.table .end { text-align: left; white-space: nowrap; }
.table .end form, .table .end .btn { margin-inline-start: 4px; }
.table .thumb { width: 52px; height: 52px; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.table tr.is-deleted td { opacity: .55; }
.table tr.has-receiving td { border-bottom: 0; }
.input-sm { min-height: 34px; padding: 5px 8px; font-size: .85rem; }
.table .check-cell { width: 36px; padding-inline-end: 0; }
.check-cell input { width: 18px; height: 18px; accent-color: var(--copper); }
.table tr.is-editing td { background: var(--copper-soft); }
.table tr.is-editing td { padding-inline: 6px; }
.table tr.is-editing [data-cell="ref"] .input { width: 100px; }
.table tr.is-editing [data-cell="date"] .input { width: 128px; }
.pallets-input { width: 64px; text-align: center; transition: border-color .2s, box-shadow .2s; }
.pallets-input.is-busy { opacity: .6; }
.pallets-input.is-done { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.pallets-input.is-error { border-color: var(--bad); }
.table tr.is-editing [data-cell="status"] .select { width: 114px; }
.table tr.is-editing [data-cell="actions"] .btn { display: flex; width: 100%; justify-content: center; margin: 0 0 4px; }
.table tr.is-saved td { background: var(--ok-soft, var(--surface-2)); transition: background .6s; }
.quick-error { color: var(--bad); font-size: .8rem; white-space: normal; margin-top: 4px; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--copper-soft); position: sticky; top: 0; z-index: 5; }
.bulk-bar[hidden] { display: none; }
.bulk-bar .select, .bulk-bar .input { width: auto; min-height: 36px; padding: 6px 10px; }
.bulk-bar [hidden] { display: none; }
.table tr.receiving-row td { padding-top: 0; }
.table tbody tr.receiving-row:hover td { background: transparent; }
.receiving summary { cursor: pointer; font-size: .85rem; color: var(--copper-strong); font-weight: 600; width: fit-content; }
.receiving-body { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); display: grid; gap: 10px; }
.receiving-meta { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0; font-size: .85rem; }
.receiving-meta dt { color: var(--muted); display: inline; }
.receiving-meta dt::after { content: ": "; }
.receiving-meta dd { display: inline; margin: 0; }
.table-mini { font-size: .85rem; background: var(--surface); }
.table-mini th, .table-mini td { padding: 6px 10px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 10px 3px 9px; border-radius: 99px; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-need_quote { background: var(--warn-soft); color: var(--warn); }
.badge-quoted { background: var(--ok-soft); color: var(--ok); }
.badge-rejected { background: var(--bad-soft); color: var(--bad); }
.badge-created { background: var(--info-soft); color: var(--info); }
.badge-ready { background: var(--teal-soft); color: var(--teal); }
.badge-scheduling { background: var(--copper-soft); color: var(--copper-strong); }
.badge-received { background: var(--ok-soft); color: var(--ok); }
.badge-cancelled { background: var(--neutral-soft); color: var(--muted); }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 4px; background: var(--neutral-soft); color: var(--muted); font-weight: 500; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--copper); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-sm); border: 1px solid; font-weight: 500; }
.alert-success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.alert-error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.alert-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info); }
.flashes { display: grid; gap: 8px; }

.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.dl dt { color: var(--muted); font-size: .86rem; }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery a { display: block; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }

.dropzone { border: 2px dashed var(--line); border-radius: var(--r-md); padding: 22px; text-align: center; display: grid; gap: 8px; justify-items: center; background: var(--surface-2); cursor: pointer; position: relative; }
.dropzone:hover, .dropzone.is-over { border-color: var(--copper); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone svg { width: 30px; height: 30px; color: var(--copper); }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }

.empty { text-align: center; padding: 36px 20px; display: grid; gap: 10px; justify-items: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--line); }
.empty strong { color: var(--ink); font-family: var(--font-display); font-size: 1.05rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card-link { display: grid; gap: 6px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: var(--ink); }
.card-link:hover { border-color: var(--copper); color: var(--ink); box-shadow: var(--shadow); }
.card-link .title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.card-link .meta { color: var(--muted); font-size: .88rem; }

.steps { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; font-size: .9rem; counter-increment: step; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); font-family: var(--font-data); font-size: .78rem; }
.steps li.done::before { content: "✓"; background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.steps li.current { color: var(--ink); }
.steps li.current::before { background: var(--copper); color: #fff; border-color: var(--copper); }

.section-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--rail); color: #fff; font-family: var(--font-data); font-size: .8rem; margin-inline-end: 8px; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; position: relative; }
.timeline li::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); margin: 5px auto 0; z-index: 1; }
.timeline li::after { content: ""; position: absolute; top: 18px; bottom: 0; right: 10px; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li > span:empty { display: none; }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.now::before { background: var(--copper); border-color: var(--copper); box-shadow: 0 0 0 4px var(--copper-soft); }
.timeline .t-title { font-weight: 600; }
.timeline .t-meta { color: var(--muted); font-size: .84rem; }

.ticket { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.ticket-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px; border-bottom: 1px dashed var(--line); align-items: center; }
.ticket-row:last-child { border-bottom: 0; }
.ticket-total { background: var(--surface-2); font-weight: 700; }

.qty-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 190px; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.qty-row:last-child { border-bottom: 0; }
.qty-row .thumb { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); }
.qty-row .name { font-weight: 600; }
.qty-row .meta { color: var(--muted); font-size: .84rem; }

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-art { background: var(--rail); color: #dfe6eb; padding: 48px clamp(24px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; inset: auto -120px -160px auto; width: 460px; height: 460px; border-radius: 50%; border: 56px solid rgba(224, 136, 76, .14); }
.auth-art h1 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); color: #fff; max-width: 14ch; }
.auth-art p { max-width: 40ch; color: #aebac3; }
.auth-art .facts { display: flex; flex-wrap: wrap; gap: 24px; font-size: .85rem; color: #aebac3; position: relative; z-index: 1; }
.auth-art .facts strong { display: block; font-family: var(--font-data); font-size: 1.3rem; color: #e0884c; font-weight: 500; }
.auth-main { display: grid; place-items: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 420px; display: grid; gap: 22px; }
.auth-card h2 { font-size: 1.5rem; }
.auth-card .lead { color: var(--muted); }
.auth-alt { border-top: 1px solid var(--line); padding-top: 16px; font-size: .9rem; color: var(--muted); }

.bare { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.bare-head { padding: 16px clamp(16px, 4vw, 40px); display: flex; align-items: center; gap: 10px; background: var(--rail); }
.bare-main { padding: 28px 16px 64px; display: grid; justify-items: center; align-content: start; }
.bare-main > * { width: 100%; max-width: 640px; }

.receive-hero { display: grid; gap: 18px; justify-items: center; text-align: center; padding: 32px 20px; }
.scan-btn { width: min(320px, 100%); aspect-ratio: 1; border-radius: 28px; border: 0; background: var(--copper); color: #fff; font: inherit; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; display: grid; place-items: center; align-content: center; gap: 14px; cursor: pointer; box-shadow: 0 10px 30px color-mix(in srgb, var(--copper) 35%, transparent); }
.scan-btn:hover { background: var(--copper-strong); }
.scan-btn svg { width: 84px; height: 84px; }
.scanner { position: fixed; inset: 0; background: #000; z-index: 50; display: grid; grid-template-rows: 1fr auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scanner .frame::before { content: ""; width: min(70vw, 300px); aspect-ratio: 1; border: 3px solid #e0884c; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
.scanner .bar { padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 10px; background: #0b1014; color: #fff; text-align: center; }
.scanner .manual { display: flex; gap: 8px; }
.scanner .manual .input { background: #1a232a; color: #fff; border-color: #33414c; }

.pallet-list { display: grid; gap: 10px; }
.pallet { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.pallet img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); }
.pallet .seq { font-family: var(--font-data); color: var(--muted); font-size: .8rem; }
.pallet .w { font-family: var(--font-data); font-size: 1.15rem; direction: ltr; unicode-bidi: isolate; }
.pallet-actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }

.device-list { display: grid; gap: 8px; }
.device { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.search { display: flex; gap: 8px; flex: 1 1 260px; max-width: 420px; }

.ts-box { position: fixed; z-index: 70; inset-inline-start: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.ts-box.is-active { inset: 0; display: grid; place-items: center; background: rgba(10, 15, 20, .55); }

@media (max-width: 960px) {
  .grid-main, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .rail { position: fixed; inset: 0 0 0 auto; width: min(300px, 86vw); height: 100%; z-index: 40; transform: translateX(105%); transition: transform .2s ease; padding-top: calc(22px + env(safe-area-inset-top, 0px)); }
  .shell.nav-open .rail { transform: none; box-shadow: -10px 0 40px rgba(0, 0, 0, .35); }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 39; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--rail); padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; position: sticky; top: 0; z-index: 30; }
  .topbar .menu-btn { background: transparent; border: 1px solid #33414c; color: #fff; border-radius: var(--r-sm); width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer; }
  .topbar .menu-btn svg { width: 22px; height: 22px; }
  .main { padding-block: 20px 56px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: 28px 20px; }
  .auth-art .facts, .auth-art p { display: none; }
  .auth-art::after { display: none; }
  .qty-row { grid-template-columns: 48px minmax(0, 1fr); }
  .qty-row .thumb { width: 48px; height: 48px; }
  .qty-row .qty-input { grid-column: 1 / -1; }
  .table-stack thead { display: none; }
  .table-stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table-stack td { padding: 0; border: 0; }
  .table-stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .table-stack .end { text-align: right; }
  .table-stack .thumb-cell { grid-row: span 2; }
  .table-stack tr.has-receiving { border-bottom: 0; }
  .table-stack tr.receiving-row { display: block; padding-top: 0; }
  .table-stack tr.receiving-row > td { display: block; }
  .table-mini thead { display: table-header-group; }
  .table-mini tr { display: table-row; padding: 0; }
  .table-mini td { display: table-cell; padding: 6px 10px; border-bottom: 1px solid var(--line); }
}

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

.photo-pick { display: grid; gap: 6px; }
.photo-pick img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.photo-pick:has(input:checked) img { opacity: .35; outline: 2px solid var(--bad); }
.main-inner > section[id] { scroll-margin-top: 80px; }

.bulk-text { font-family: var(--font-data); font-size: .9rem; min-height: 240px; }
.error-list { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; }
.bulk-example .ticket-row { padding-block: 8px; }
.pallets-field { max-width: 320px; }

.app-card { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; padding: 16px 20px; margin-bottom: 20px; }
.app-card[hidden] { display: none; }
.app-card-icon img { display: block; width: 48px; height: 48px; border-radius: 12px; }
.app-card-text { flex: 1 1 260px; display: grid; gap: 4px; }
.app-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.app-card-actions [hidden], .app-card-text [hidden] { display: none; }

.brand-logo { display: block; height: 40px; width: auto; max-width: 150px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px 8px; }
.logo-preview { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px dashed var(--line); border-radius: var(--r-md); background: #fff; min-height: 80px; }
.logo-preview img { max-height: 80px; max-width: 100%; object-fit: contain; }

body.pdf-print { margin: 0; height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.pdf-print-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.pdf-print-bar strong { margin-inline-end: auto; }
.pdf-print-frame { flex: 1; width: 100%; border: 0; }
.cert-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.brand:has(.brand-logo) .brand-name { font-size: 0; }
.brand:has(.brand-logo) .brand-sub { font-size: .75rem; margin-top: 2px; }
.topbar .brand:has(.brand-logo) .brand-name { display: none; }

.line-items { display: grid; gap: 10px; margin-bottom: 12px; }
.line-item { display: grid; grid-template-columns: minmax(0, 1fr) 170px auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.line-item .field { margin: 0; }
.line-remove[hidden] { visibility: hidden; display: inline-flex; }
@media (max-width: 560px) {
  .line-item { grid-template-columns: minmax(0, 1fr) auto; }
  .line-item .field:first-child { grid-column: 1 / -1; }
}
.confirm-hero { text-align: center; padding: 28px 20px; }
.confirm-hero .confirm-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.confirm-hero .confirm-icon svg { width: 32px; height: 32px; }
.next-steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 8px; }
.coordinator-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.panel-attention { border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-soft); }
.approve-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.chips-static .chip { cursor: default; }
.badge-scheduled { background: var(--teal-soft); color: var(--teal); }
.badge-pending_close { background: var(--copper-soft); color: var(--copper-strong); }
[data-wizard] [data-step][hidden] { display: none; }
.quote-items { display: grid; gap: 8px; }
.quote-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.tab-count { display: inline-block; min-width: 22px; padding: 1px 7px; margin-inline-start: 4px; border-radius: 99px; background: var(--neutral-soft); color: var(--muted); font-family: var(--font-data); font-size: .75rem; text-align: center; }
.tabs a[aria-current="page"] .tab-count { background: var(--copper-soft); color: var(--copper-strong); }
.panel-sub { padding: 14px 20px 6px; border-top: 1px solid var(--line); }
.panel-sub h3 { margin: 0; font-size: .95rem; }
.bank-edit { margin-top: 12px; }
.bank-edit summary { cursor: pointer; color: var(--copper-strong); font-weight: 600; width: fit-content; }
.bank-edit form { margin-top: 12px; }
.invoice-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); margin-bottom: 14px; }
.invoice-summary div { display: grid; gap: 2px; }
.invoice-summary strong { font-size: 1.15rem; direction: ltr; text-align: right; }
.invoice-summary.is-match { border-color: var(--ok); background: var(--ok-soft); }
.invoice-summary.is-mismatch { border-color: var(--bad); background: var(--bad-soft); }
.invoice-file iframe { display: block; width: 100%; height: 75vh; border: 0; }
.invoice-file img { display: block; max-width: 100%; height: auto; border-radius: var(--r-sm); }
.invoice-filter { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.invoice-filter .input { max-width: 320px; }
.invoice-pickups { max-height: 420px; overflow: auto; }
.invoice-pickups thead th { position: sticky; top: 0; z-index: 1; }
.invoice-pickups tr[hidden] { display: none; }
.invoice-upload > summary { list-style: none; width: fit-content; }
.invoice-upload > summary::-webkit-details-marker { display: none; }
.invoice-upload[open] > summary { margin-bottom: 14px; }
.invoice-upload form { padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.tag-company { background: var(--copper-soft); color: var(--copper-strong); }
.pickup-pick { display: grid; gap: 8px; }
.pickup-pick .input { max-width: 320px; }
.pickup-pick-list { max-height: 240px; overflow: auto; display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.pickup-pick-row[hidden] { display: none; }
.breakdown-pickup { border-top: 1px solid var(--line); padding: 10px 0; }
.breakdown-pickup summary { cursor: pointer; }
.breakdown-pickup .table-wrap { margin-top: 8px; }
.log-wrap { max-height: 520px; overflow: auto; }
.log-wrap thead th { position: sticky; top: 0; z-index: 1; }
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; padding: 14px 16px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.filter-bar .field { margin: 0; }
.filter-bar label { font-size: .8rem; }
.filter-bar .input, .filter-bar .select { min-height: 40px; padding: 8px 10px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.balance-readouts { margin-bottom: 16px; }
.balance-breakdown { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); font-size: .9rem; color: var(--muted); }
.balance-breakdown strong { color: var(--ink); margin-inline-start: 4px; }
