/* Layout: floating glass rail (brand + grouped nav with icons) beside a wide work area with a top bar (SKU search + user).
   Soft translucent cards with large radii on an airy background; steel neutrals, Solar gold for actions and the active state. */
:root {
  --bg: #eef1f4;
  --bg-glow-1: rgba(242, 183, 5, .22);     /* warm gold wash, top left */
  --bg-glow-2: rgba(92, 140, 210, .20);    /* cool steel-blue wash, right */
  --bg-glow-3: rgba(240, 150, 120, .14);   /* faint copper, bottom */
  --surface: #ffffff;                      /* solid surface: inputs, sticky headers, modals, documents */
  --surface-2: #f4f6f8;
  --glass: rgba(255, 255, 255, .74);       /* cards and panels */
  --glass-strong: rgba(255, 255, 255, .88);
  --glass-line: rgba(255, 255, 255, .9);
  --ink: #161c22;
  --ink-2: #46505a;
  --muted: #6b7580;
  --line: #e3e7ec;
  --line-strong: #c9d0d7;
  --accent: #f2b705;           /* Solar logo gold: primary buttons, marks */
  --accent-strong: #845100;    /* logo bronze: links, active text, focus on light ground */
  --accent-soft: #fdf3d2;
  --on-accent: #2b1a00;        /* text on gold */
  --ok: #17794a;  --ok-soft: #e1f3ea;
  --warn: #8f5d00; --warn-soft: #fbf0d4;
  --bad: #b8322a; --bad-soft: #fbe6e3;
  --info: #2c5aa8; --info-soft: #e5edfa;
  --shadow-sm: 0 1px 2px rgba(22, 28, 34, .04), 0 4px 16px rgba(40, 52, 66, .06);
  --shadow: 0 2px 6px rgba(22, 28, 34, .05), 0 16px 40px rgba(40, 52, 66, .10);
  --scrim: rgba(16, 22, 28, .35);
  --photo-bg: #f3f4f6;

  --f-display: "Archivo", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r: 10px;
  --r-lg: 18px;
  --side-w: 248px;
  --gap: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1114; --bg-glow-1: rgba(242, 183, 5, .07); --bg-glow-2: rgba(80, 120, 190, .10); --bg-glow-3: rgba(200, 110, 80, .05);
    --surface: #161b20; --surface-2: #1c2228; --glass: rgba(24, 30, 36, .72); --glass-strong: rgba(26, 32, 38, .9); --glass-line: rgba(255, 255, 255, .06);
    --ink: #e5e9ed; --ink-2: #b3bcc5; --muted: #8b959f;
    --line: #283038; --line-strong: #39434d; --accent: #f2b705; --accent-strong: #f5c84a; --accent-soft: #33280a; --on-accent: #1f1400;
    --ok: #5cc98f; --ok-soft: #13301f; --warn: #e2b04a; --warn-soft: #33270c; --bad: #f07a6e; --bad-soft: #3a1714; --info: #7ea8f0; --info-soft: #16243d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 16px 40px rgba(0, 0, 0, .45); --scrim: rgba(0, 0, 0, .6); --photo-bg: #0f1418;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1114; --bg-glow-1: rgba(242, 183, 5, .07); --bg-glow-2: rgba(80, 120, 190, .10); --bg-glow-3: rgba(200, 110, 80, .05);
  --surface: #161b20; --surface-2: #1c2228; --glass: rgba(24, 30, 36, .72); --glass-strong: rgba(26, 32, 38, .9); --glass-line: rgba(255, 255, 255, .06);
  --ink: #e5e9ed; --ink-2: #b3bcc5; --muted: #8b959f;
  --line: #283038; --line-strong: #39434d; --accent: #f2b705; --accent-strong: #f5c84a; --accent-soft: #33280a; --on-accent: #1f1400;
  --ok: #5cc98f; --ok-soft: #13301f; --warn: #e2b04a; --warn-soft: #33270c; --bad: #f07a6e; --bad-soft: #3a1714; --info: #7ea8f0; --info-soft: #16243d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 16px 40px rgba(0, 0, 0, .45); --scrim: rgba(0, 0, 0, .6); --photo-bg: #0f1418;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: 14px/1.5 var(--f-body); color: var(--ink); -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 600px at -5% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 700px at 105% 15%, var(--bg-glow-2), transparent 60%),
    radial-gradient(900px 500px at 50% 115%, var(--bg-glow-3), transparent 60%);
  background-attachment: fixed;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font: 650 24px/1.2 var(--f-display); letter-spacing: -.015em; margin: 0 0 18px; text-wrap: balance; }
h2 { font: 600 15.5px/1.3 var(--f-display); margin: 28px 0 12px; text-wrap: balance; }
code, .code, .mono { font-family: var(--f-mono); font-size: .92em; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* Glass surface shared by cards, panels, tables, the rail and the top bar. */
.panel, .tablewrap, .card, .pipe, nav.side, .appbar, .login, .tabs, .flow b {
  background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
}

/* ---------- shell ---------- */
.layout { display: flex; min-height: 100vh; gap: 0; }
nav.side {
  width: var(--side-w); flex: none; position: sticky; top: var(--gap); margin: var(--gap) 0 var(--gap) var(--gap);
  height: calc(100vh - 2 * var(--gap)); overflow-y: auto; display: flex; flex-direction: column; padding: 18px 12px 12px;
  border-radius: 22px; scrollbar-width: thin;
}
.brand { display: flex; color: var(--ink); flex-direction: column; align-items: flex-start; gap: 4px; padding: 2px 10px 14px; }
.brand:hover { text-decoration: none; }
.brand img { height: 40px; width: auto; display: block; }
.brand b { font: 700 16px/1.1 var(--f-display); letter-spacing: -.01em; display: block; }
.brand small { padding-left: 2px; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
nav.side .grp { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 14px 12px 6px; }
nav.side a.nav {
  display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: 4px 10px 4px 6px; border-radius: 12px; font-weight: 500;
  transition: background .12s, color .12s;
}
nav.side a.nav + a.nav { margin-top: 2px; }
nav.side a.nav svg { flex: none; color: var(--muted); box-sizing: content-box; padding: 6px; border-radius: 9px; transition: background .12s, color .12s; }
nav.side a.nav .step { margin-left: auto; font: 500 11px var(--f-mono); color: var(--muted); }
nav.side a.nav:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--ink); text-decoration: none; }
nav.side a.nav:hover svg { background: var(--surface-2); color: var(--ink-2); }
nav.side a.nav.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
nav.side a.nav.on svg { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 10px color-mix(in srgb, var(--accent) 40%, transparent); }
nav.side a.nav.on .step { color: var(--accent-strong); }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font: 600 14px var(--f-display);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-strong))); color: var(--on-accent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.who { display: flex; align-items: center; gap: 10px; }
.who .nm { font-weight: 600; font-size: 13px; line-height: 1.25; }
.who .hi { font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.who .links { font-size: 12px; color: var(--muted); }
.who .links a { color: var(--accent-strong); }
.topbar { display: none; }
.work { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: var(--gap) var(--gap) 0 calc(var(--gap) + 4px); }
.appbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; border-radius: 20px; position: sticky; top: var(--gap); z-index: 30;
}
.appbar .search { position: relative; flex: 1; max-width: 460px; }
.appbar .search svg { position: absolute; left: 12px; top: 50%; margin-top: -8px; color: var(--muted); pointer-events: none; }
.appbar .search input { width: 100%; padding-left: 36px; background: color-mix(in srgb, var(--surface-2) 80%, transparent); border-color: transparent; border-radius: 12px; }
.appbar .search input:hover { border-color: var(--line-strong); }
.appbar .search input:focus { background: var(--surface); border-color: var(--accent-strong); }
.appbar .today { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.appbar .who { padding-left: 14px; border-left: 1px solid var(--line); }
main { flex: 1; padding: 24px 18px 48px; min-width: 0; }

/* ---------- generic building blocks ---------- */
.panel { border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 18px; }
.panel h2:first-child { margin-top: 0; }
.row { display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: flex-end; }
.row > h1 { margin: 0; align-self: center; }
main > .row:first-child { margin-bottom: 20px; align-items: center; }
.row > label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- forms ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  padding: 7px 11px; min-height: 38px; transition: border-color .12s, box-shadow .12s, background .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-strong); box-shadow: 0 0 0 4px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent-strong); vertical-align: -3px; margin: 0 6px 0 0; }
input.num { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
input.sku { width: 340px; max-width: 100%; }
textarea { width: 100%; min-height: 72px; resize: vertical; line-height: 1.45; }
label.muted { display: flex; flex-direction: column; gap: 5px; }

button {
  font: 500 13.5px/1 var(--f-body); color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 0 16px; height: 38px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
}
button:hover { background: var(--surface-2); border-color: var(--muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary {
  background: var(--accent); border-color: color-mix(in srgb, var(--accent) 70%, var(--accent-strong)); color: var(--on-accent); font-weight: 600;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
button.primary:hover { filter: brightness(.96); background: var(--accent); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); }
button.danger { color: var(--bad); border-color: var(--line-strong); }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
button.small { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { width: 38px; padding: 0; justify-content: center; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; z-index: 1;
}
tbody tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.tablewrap { overflow-x: auto; border-radius: var(--r-lg); }
.tablewrap table { border: 0; }
.tablewrap thead th { background: color-mix(in srgb, var(--surface-2) 92%, transparent); }
.tablewrap thead th:first-child { padding-left: 18px; }
.tablewrap tbody td:first-child { padding-left: 18px; }
.panel > table { margin: -4px 0 0; }
.panel > table th { background: transparent; }
a.code, td a.code { font-weight: 500; }
.nowrap { white-space: nowrap; }
.empty { padding: 32px 12px; text-align: center; color: var(--muted); }

/* ---------- badges / state ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font: 600 11px/1 var(--f-body); letter-spacing: .02em; padding: 5px 9px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.b-green { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.b-red { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.b-amber { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.b-blue { background: var(--info-soft); color: var(--info); border-color: transparent; }
.b-green::before, .b-red::before, .b-amber::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- stat cards / KPI tiles ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); margin-bottom: 24px; }
.card { border-radius: var(--r-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; color: inherit; transition: box-shadow .15s, transform .15s; }
a.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); text-decoration: none; }
.card .v { font: 650 26px/1.1 var(--f-display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.card .l { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.card.alert .v { color: var(--bad); }
.card .chip { align-self: flex-start; margin-top: 6px; }
/* Tile with a coloured icon square on the left (dashboard). */
.cards.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .cards.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .cards.kpis { grid-template-columns: 1fr; } }
.card.kpi { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: center; }
.card.kpi .ic { grid-row: span 3; align-self: start; }
.ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); flex: none; }
.ic.t-gold { background: var(--accent-soft); color: var(--accent-strong); }
.ic.t-red { background: var(--bad-soft); color: var(--bad); }
.ic.t-green { background: var(--ok-soft); color: var(--ok); }
.ic.t-blue { background: var(--info-soft); color: var(--info); }
.ic.t-amber { background: var(--warn-soft); color: var(--warn); }

/* ---------- dashboard pipeline ---------- */
.pipe { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-radius: var(--r-lg); margin-bottom: 10px; overflow: hidden; }
.stage { position: relative; padding: 16px 16px 16px 24px; color: inherit; display: flex; flex-direction: column; gap: 3px; border-left: 1px solid var(--line); }
.stage:first-child { border-left: 0; padding-left: 18px; }
.stage:not(:first-child)::before {
  content: ""; position: absolute; left: -7px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: rotate(45deg);
}
a.stage:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); text-decoration: none; }
.stage .k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stage .k svg { color: var(--muted); }
.stage .v { font: 650 26px/1.15 var(--f-display); font-variant-numeric: tabular-nums; }
.stage .u { font-size: 12px; color: var(--muted); }
.stage.act .v { color: var(--accent-strong); }
.stage.act .k svg { color: var(--accent-strong); }
.stage.act .k::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.branch { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); margin: 0 0 24px 4px; }
.branch a { color: var(--ink-2); font-weight: 500; }

/* ---------- misc existing pieces ---------- */
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.flow b { border-radius: 999px; padding: 5px 11px; color: var(--ink); font-weight: 500; box-shadow: none; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 12.5px; }
.kv > div:nth-child(even) { font-weight: 500; overflow-wrap: anywhere; }
.reqs { font-size: 12px; color: var(--muted); }
.reqs td { padding: 3px 12px; border: 0; background: transparent !important; }
.tabs { display: inline-flex; gap: 3px; margin-bottom: 16px; flex-wrap: wrap; border-radius: 14px; padding: 4px; }
.tabs button { border: 0; background: transparent; height: 32px; border-radius: 10px; color: var(--ink-2); }
.tabs button:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.tabs button.on { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 600; }

/* ---------- toast & modal ---------- */
#toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
#toast div { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow); max-width: 420px; font-weight: 500; animation: rise .18s ease-out; }
#toast div.err { background: var(--bad); color: #fff; }
.modal-bg {
  position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; z-index: 50;
  animation: fade .12s ease-out; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 24px 26px; width: min(660px, 100%); max-height: 84vh; overflow-y: auto; box-shadow: var(--shadow); animation: rise .16s ease-out; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal form > p, .modal > p { margin: 12px 0; }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(400px, 100%); border-radius: 24px; padding: 32px; box-shadow: var(--shadow); }
.login .brand { padding: 0 0 22px; align-items: center; text-align: center; }
.login .brand img { height: 72px; }
.login h1 { font-size: 21px; margin-bottom: 4px; }
.login p.muted { margin: 0 0 18px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.login input { width: 100%; }
.login button { width: 100%; justify-content: center; height: 42px; margin-top: 6px; }

/* ---------- SKU photos & details ---------- */
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; background: var(--photo-bg); }
.nophoto { background: var(--surface-2); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; }
span.thumb.nophoto::after { content: ""; width: 16px; height: 12px; border: 1.5px solid var(--line-strong); border-radius: 2px; }
td.tcell { width: 56px; padding: 6px 4px 6px 12px; }
.clip { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skuhead { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.skuhead > .panel { margin-bottom: 18px; }
.gallery { width: 320px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; }
.mainphoto { width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: contain; border-radius: 14px; background: var(--photo-bg); cursor: zoom-in; display: flex; color: var(--muted); }
div.mainphoto { cursor: default; border: 1px dashed var(--line-strong); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumbs .tw { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.thumbs .thumb { width: 60px; height: 60px; cursor: pointer; }
.thumbs .thumb:hover { border-color: var(--accent-strong); }
.thumbs .tools { display: flex; gap: 3px; }
.thumbs .tools button { height: 22px; padding: 0 7px; font-size: 11px; }
.gallery #addp { align-self: flex-start; }
.desc { white-space: pre-wrap; margin: 0 0 16px; color: var(--ink-2); max-width: 70ch; }
table.attrs { background: transparent; margin-top: 6px; }
table.attrs td { border: 0; padding: 3px 6px 3px 0; }
table.attrs tbody tr:hover td { background: transparent; }
.modal.wide { width: min(1100px, 100%); text-align: center; }
.bigphoto { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; }


/* ---------- purchase orders ---------- */
.meter { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); vertical-align: middle; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); }
table.poed { background: transparent; }
table.poed td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.poed th { background: transparent; padding-left: 0; }
table.poed td.amt, table.poed td.uom { padding-top: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals { margin: 14px 0 0 auto; width: min(340px, 100%); display: flex; flex-direction: column; gap: 6px; }
.totals > div { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.totals > div span { color: var(--muted); }
.totals .grand { border-top: 1px solid var(--line-strong); padding-top: 8px; font: 600 17px var(--f-display); }
.totals .grand span { color: var(--ink); }

/* The PO itself, laid out like the paper document it replaces. */
.podoc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 36px 40px; max-width: 920px; color: var(--ink); }
.podoc .lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 4px; }
.podoc .co { font: 700 18px/1.25 var(--f-display); }
.podoc .addr { white-space: pre-line; color: var(--ink-2); }
.po-logo { height: 54px; width: auto; display: block; margin-bottom: 8px; }
.po-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 3px solid var(--accent); }
.po-from { min-width: 0; flex: 1; font-size: 13px; }
.po-title { text-align: right; }
.po-title .doc { font: 700 24px/1 var(--f-display); text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin-bottom: 12px; }
.po-title dl { display: grid; grid-template-columns: auto auto; gap: 3px 14px; margin: 0; justify-content: end; align-items: baseline; }
.po-title dt { color: var(--muted); font-size: 12px; }
.po-title dd { margin: 0; font-weight: 600; text-align: left; }
.po-title dd.big { font-size: 18px; }
.po-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 18px; border: 1px solid var(--line-strong); }
.po-parties > div { padding: 12px 16px; min-width: 0; }
.po-parties > div + div { border-left: 1px solid var(--line-strong); }
.po-parties .dlv { color: var(--ink); font-weight: 500; }
.po-kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 12.5px; }
.po-kv dt { color: var(--muted); }
.po-kv dd { margin: 0; overflow-wrap: anywhere; }
.po-intro { color: var(--ink-2); margin: 16px 0 10px; }
.po-lines { border: 1px solid var(--line-strong); }
.po-lines th { position: static; background: var(--surface-2); color: var(--ink-2); }
.po-lines td, .po-lines th { border-right: 1px solid var(--line); vertical-align: top; }
.po-lines td .code { font-weight: 600; }
.po-lines td .desc { color: var(--muted); margin: 2px 0 0; white-space: pre-line; }
.po-lines tbody tr:hover td { background: transparent; }
.po-sum { display: flex; gap: 24px; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; margin-top: 4px; }
.po-sum .words { flex: 1; min-width: 220px; padding-top: 14px; font-weight: 500; }
.po-end { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .08em; margin: 18px 0 0; }
.po-terms { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.po-terms ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); display: grid; gap: 3px; }
.po-sign { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 32px; font-size: 13px; }
.po-sign > div { min-width: 220px; }
.po-sign > div:last-child { text-align: right; }
.po-sign .for { font-weight: 600; }
.po-sign > div:first-child .po-sig { margin-left: 0; }
.po-sign .line { border-top: 1px solid var(--line-strong); margin: 4px 0 6px; }
.po-sig { display: block; height: 64px; max-width: 240px; object-fit: contain; margin: 6px 0 0 auto; }
.po-foot { margin: 22px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; }
.panel.accept { border-left: 4px solid var(--line-strong); }
.panel.accept.ok { border-left-color: var(--ok); }
.panel.accept.late { border-left-color: var(--bad); }
.panel.warnbox { border-left: 4px solid var(--accent); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
ul.plog { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.sigbox { width: 220px; height: 70px; border: 1px dashed var(--line-strong); border-radius: var(--r); display: grid; place-items: center; background: #fff; }
.sigbox img { max-width: 210px; max-height: 64px; }
@media (max-width: 600px) { .po-parties { grid-template-columns: 1fr; } .po-parties > div + div { border-left: 0; border-top: 1px solid var(--line-strong); } }
@media (max-width: 600px) { .podoc { padding: 20px 16px; } .po-title { text-align: left; } .po-title dl { justify-content: start; } }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .layout { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40;
    background: var(--glass-strong); border-bottom: 1px solid var(--line); padding: 8px 16px;
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  .topbar .brand { padding: 0; flex-direction: row; align-items: center; gap: 10px; }
  .topbar .brand img { height: 24px; }
  nav.side {
    position: fixed; left: 0; top: 0; bottom: 0; height: auto; margin: 0; border-radius: 0 22px 22px 0; z-index: 60; background: var(--glass-strong);
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }
  .layout.nav-open nav.side { transform: none; }
  .layout.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 55; }
  .work { padding: 12px 12px 0; }
  .appbar { position: static; padding: 8px 10px; border-radius: 16px; gap: 10px; }
  .appbar .today, .appbar > .spacer { display: none; }
  .appbar .search { max-width: none; }
  .appbar .who { padding-left: 10px; }
  .appbar .who > div:last-child { display: none; }
  main { padding: 18px 4px 40px; }
  .pipe { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage:nth-child(4) { border-left: 0; padding-left: 16px; }
  .stage:nth-child(n+4) { border-top: 1px solid var(--line); }
  .stage:nth-child(4)::before { display: none; }
  input.sku { width: 100%; }
  .gallery { width: 100%; }
  .clip { max-width: 200px; }
}
@media (max-width: 480px) {
  .pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage:nth-child(4) { border-left: 1px solid var(--line); padding-left: 22px; }
  .stage:nth-child(4)::before { display: block; }
  .stage:nth-child(odd) { border-left: 0; padding-left: 16px; }
  .stage:nth-child(odd)::before { display: none; }
  .stage:nth-child(n+3) { border-top: 1px solid var(--line); }
  h1 { font-size: 19px; }
}
/* Phones: tables with inputs / buttons become one card per row (app.js stackTables() adds .stack and data-label). */
@media (max-width: 640px) {
  table.stack, table.stack > tbody { display: block; width: 100%; }
  table.stack > thead { display: none; }
  .tablewrap:has(> table.stack) { overflow: visible; background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  table.stack > tbody > tr {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; margin: 0 0 12px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  }
  table.stack > tbody > tr > td, .tablewrap table.stack tbody td:first-child { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  table.stack > tbody > tr > td:empty { display: none; }
  table.stack > tbody > tr > td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 3px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  }
  /* wide content gets the full card width: the SKU box, remarks, buttons, cells without a column name, single "nothing here" rows */
  table.stack > tbody > tr > td:first-child, table.stack > tbody > tr > td:not([data-label]), table.stack > tbody > tr > td[colspan],
  table.stack > tbody > tr > td:has(input.sku, textarea, input[data-f="remarks"]) { grid-column: 1 / -1; }
  table.stack > tbody > tr > td input:not([type="checkbox"]):not([type="radio"]), table.stack > tbody > tr > td select { width: 100% !important; max-width: none; }
  table.stack > tbody tr:hover td { background: transparent; }
  table.stack > tbody > tr.reqs { margin-left: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  nav.side, .topbar, .appbar, button, .noprint, #toast { display: none !important; }
  .work { padding: 0; }
  .panel, .tablewrap, .card, .pipe { box-shadow: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: #fff !important; }
  .podoc { border: 0; padding: 0; max-width: none; box-shadow: none; }
  .podoc, .podoc * { color: #000 !important; background: transparent !important; }
  .po-lines th { background: #eee !important; }
  .po-head { border-bottom-color: #f2b705 !important; }
  .po-lines tr, .po-sum, .po-sign, .po-terms { break-inside: avoid; }
  .po-sign { break-before: avoid; }
  @page { size: A4; margin: 14mm 14mm 16mm;
    @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 9pt sans-serif; color: #555; } }
  main { padding: 0; }
  body { background: #fff; }
  .tablewrap, .panel { border-color: #ccc; }
}

/* batch / lot numbers */
.batch { font: 500 12px/1 var(--f-mono); padding: 4px 7px; border-radius: 6px; background: var(--info-soft); color: var(--info); white-space: nowrap; }

/* attendance */
.att-P { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.att-HD { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.att-A { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.att-L { background: var(--info-soft); color: var(--info); border-color: transparent; }
.att-WO, .att-HO { background: var(--surface-2); color: var(--muted); border-color: transparent; }
#sum { gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg span { display: block; min-width: 34px; padding: 8px 6px; text-align: center; font: 600 12px/1 var(--f-mono); color: var(--muted); border-left: 1px solid var(--line); }
.seg label:first-child span { border-left: 0; }
.seg label:hover span { background: var(--surface-2); color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-strong); outline-offset: -2px; }
.seg input:checked + span { background: var(--ink-2); color: var(--surface); }
.seg .s-P input:checked + span { background: var(--ok); color: #fff; }
.seg .s-HD input:checked + span { background: var(--warn); color: #fff; }
.seg .s-A input:checked + span { background: var(--bad); color: #fff; }
.seg .s-L input:checked + span { background: var(--info); color: #fff; }
.seg input:disabled + span { cursor: default; }
.seg input:disabled:not(:checked) + span { opacity: .55; }
table.att td { padding-top: 6px; padding-bottom: 6px; }
table.att input[type="time"] { width: 112px; }
table.att input:disabled { opacity: .45; }
table.att tr.unsaved td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.grp td { background: var(--surface-2); font: 600 11px/1.2 var(--f-body); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 7px; padding-bottom: 7px; }
table.attgrid th, table.attgrid td { padding: 6px 5px; font-size: 12px; }
table.attgrid th { text-align: center; letter-spacing: 0; }
table.attgrid th div { font-weight: 500; color: var(--muted); }
table.attgrid th.tot, table.attgrid td.tot { padding: 6px 8px; }
table.attgrid td.ac { text-align: center; font: 600 11px/1 var(--f-mono); min-width: 26px; cursor: pointer; border-left: 1px solid var(--line); }
table.attgrid td.ac:hover { outline: 2px solid var(--accent-strong); outline-offset: -2px; }
table.attgrid .sun:not([class*="att-"]) { background: var(--surface-2); }
.printonly { display: none; }
@page attreg { size: A4 landscape; margin: 8mm; }
@media print {
  .printonly { display: block; margin-bottom: 8px; font-size: 13px; }
  .attprint { page: attreg; }
  .attprint .tablewrap { overflow: visible; }
  table.attgrid th, table.attgrid td { padding: 2px 2px; font-size: 8.5px; position: static; }
  table.attgrid td.ac { min-width: 0; }
  table.attgrid * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- database viewer ---------- */
.dbview { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.dbtables { padding: 6px; max-height: calc(100vh - 190px); overflow-y: auto; position: sticky; top: 92px; }
.dbtables a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; color: var(--ink); }
.dbtables a span:first-child { display: flex; flex-direction: column; min-width: 0; }
.dbtables a code { background: none; border: 0; padding: 0; font-size: 12.5px; }
.dbtables a small { color: var(--muted); font-size: 11px; }
.dbtables a:hover { background: var(--surface-2); }
.dbtables a.on { background: var(--accent-soft); }
.dbtables a.on code { color: var(--accent-strong); font-weight: 600; }
.dbgrid { max-height: calc(100vh - 200px); }
.dbgrid th { cursor: pointer; }
.dbgrid td { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; white-space: nowrap; padding: 6px 10px; }
@media (max-width: 800px) {
  .dbview { grid-template-columns: 1fr; }
  .dbtables { position: static; max-height: 220px; }
}

/* ---------- labels (QL-800) ---------- */
.lblwrap { display: grid; grid-template-columns: 250px minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.lbllib { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 10px; }
.lbllist { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 330px); overflow-y: auto; }
.lbllist li { display: flex; gap: 6px; align-items: flex-start; padding: 6px 6px; border-radius: 10px; }
.lbllist li.on { background: var(--accent-soft); }
.lbllist li a { display: flex; flex-direction: column; color: var(--ink); min-width: 0; }
.lbllist li a b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lblform { display: flex; flex-direction: column; gap: 10px; }
.lblform label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.lblform label.chk { flex-direction: row; align-items: center; font-size: 13px; }
.lblform fieldset { border: 0; border-top: 1px solid var(--line); margin: 4px 0 0; padding: 10px 0 0; display: flex; flex-direction: column; gap: 10px; }
.lblform legend { font: 600 13px var(--f-display); padding: 0 6px 0 0; color: var(--ink); }
.lblform .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lblform [hidden] { display: none !important; }
.lblstate { font-size: 12.5px; padding: 7px 12px; border-radius: 10px; background: var(--surface-2); }
.lblstate.dirty { background: var(--warn-soft); color: var(--warn); }
.lblbench { overflow-x: auto; }
.lblprev { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; padding: 12px 0; }
.lblprev.wrap { flex-direction: row; flex-wrap: wrap; }
.lblroll { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); line-height: 0; }
.lblroll svg { display: block; }
#lblprint { display: none; }
@media (max-width: 1100px) {
  .lblwrap { grid-template-columns: minmax(0, 1fr); }
  .lblwrap > * { min-width: 0; }
  .lbllib { position: static; }
  .lbllist { max-height: 260px; }
}
@media print {
  body.lblprinting #app, body.lblprinting #toast, body.lblprinting .modal-bg { display: none !important; }
  body.lblprinting { background: #fff; margin: 0; }
  body.lblprinting #lblprint { display: block; }
  #lblprint .lblpage { break-after: page; overflow: hidden; line-height: 0; }
  #lblprint .lblpage:last-child { break-after: auto; }
  #lblprint svg { display: block; }
  #lblprint .a4sheet { position: relative; width: 210mm; height: 296mm; break-after: page; overflow: hidden; }
  #lblprint .a4sheet:last-child { break-after: auto; }
  #lblprint .a4sheet .cell { position: absolute; outline: 0.2mm dashed #999; }
  #lblprint .a4sheet .foot { position: absolute; left: 10mm; right: 10mm; bottom: 6mm; display: flex; justify-content: space-between; font: 8pt sans-serif; color: #555; }
}

/* ---------- quotations ---------- */
.row > label.chk, label.chk { display: inline-flex; flex-direction: row; align-items: center; gap: 0; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
.fieldpick { gap: 8px 18px; }
table.qed td { vertical-align: top; }
table.qed input.sku { width: 100%; min-width: 220px; }
table.qed input.num { width: 84px; }
#qform.noprev .prevc, #qform.noprev .prevopt { display: none; }
#qform.pl .qonly, #qform:not(.pl) .plonly { display: none; }
table.qed .ov .badge { font-size: 10.5px; padding: 2px 6px; }
table.qed .net, table.qed .amt { font-variant-numeric: tabular-nums; padding-top: 14px; }
.modal.qdet { width: min(760px, 100%); }
.qrevs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qrev { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r); color: var(--ink); text-decoration: none; background: var(--surface); }
.qrev:hover { border-color: var(--accent-strong); }
.qrev.on { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft); font-weight: 600; }
.qchg ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.qchg .badge { min-width: 64px; justify-content: center; text-transform: uppercase; font-size: 10.5px; }
.qd-sec { margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.qd-sec textarea { margin-top: 6px; }
.qd-sec textarea:disabled, .qd-specs input:disabled { color: var(--muted); background: var(--surface-2); }
.qd-specs { margin-top: 6px; }
.qd-specs td { padding: 3px 6px 3px 0; border: 0; }
.qd-specs .dk { width: 170px; }
.qd-specs .dv { width: 340px; max-width: 100%; }
.qd-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.qd-ph { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 6px 8px; cursor: pointer; font-size: 12px; text-align: center; }
.qd-ph img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.qd-ph:has(input:checked) { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Printed quotation: always paper colours (also in dark mode), laid out like the owner's BMG price list. */
.qdoc {
  --q-ink: #18212b; --q-ink-2: #4a5561; --q-line: #d5dbe2; --q-zebra: #f5f7f9; --q-head: #26313c; --q-gold: #f2b705; --q-bronze: #845100;
  background: #fff; color: var(--q-ink); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 40px 44px; max-width: 920px; font-size: 13.5px; line-height: 1.45;
}
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 16px; border-bottom: 3px solid var(--q-gold); }
.q-co { font: 800 30px/1.1 var(--f-display); letter-spacing: .01em; text-transform: uppercase; color: var(--q-ink); margin-bottom: 8px; }
.q-addr { color: var(--q-ink-2); white-space: pre-line; font-size: 13px; }
.q-logo { height: 62px; width: auto; flex: none; }
.q-to { margin: 24px 0 8px; }
.q-title { font: 800 26px/1.15 var(--f-display); text-transform: uppercase; letter-spacing: .01em; margin: 0 0 12px; color: var(--q-ink); }
.q-cust { font: 700 14px/1.3 var(--f-display); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 6px; }
.q-caddr { white-space: pre-line; color: var(--q-ink-2); margin-bottom: 6px; }
.q-facts { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 12px 0 0; }
.q-facts > div { display: flex; gap: 6px; }
.q-facts dt { color: var(--q-ink-2); }
.q-facts dt::after { content: ":"; }
.q-facts dd { margin: 0; font-weight: 600; }
.q-sec { font: 700 16px/1.3 var(--f-display); color: var(--q-bronze); margin: 22px 0 10px; }
.q-lines { width: 100%; border-collapse: collapse; margin-top: 14px; border: 1px solid var(--q-line); }
.q-sec + .q-lines { margin-top: 0; }
.q-lines th { position: static; background: var(--q-head); color: #fff; font: 700 11.5px/1.3 var(--f-display); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; text-align: left; vertical-align: top; border: 0; }
.q-lines th.n { text-align: right; }
.q-lines th small { display: block; font: 500 10.5px/1.3 var(--f-body); text-transform: none; letter-spacing: 0; opacity: .8; margin-top: 2px; }
.q-lines td { padding: 10px 12px; border: 0; border-top: 1px solid var(--q-line); border-left: 1px solid var(--q-line); vertical-align: top; color: var(--q-ink); background: #fff; }
.q-lines tbody tr:nth-child(even) td { background: var(--q-zebra); }
.q-lines tbody tr:hover td { background: inherit; }
.q-lines td.code { font: 700 13px/1.4 var(--f-mono); white-space: nowrap; border-left: 0; }
.q-lines td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-lines td.prev { color: var(--q-ink-2); }
.q-lines td.rate { font-weight: 700; }
.q-lines th.ph, .q-lines td.ph { width: 74px; padding-right: 0; }
.q-lines td.ph img { width: 64px; height: 64px; object-fit: contain; display: block; border-radius: 4px; background: #fff; }
.q-lines .pn { font-size: 14px; }
.q-lines .pd { color: var(--q-ink-2); font-size: 12.5px; margin-top: 3px; white-space: pre-line; }
.q-lines .ps { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; font-size: 12px; color: var(--q-ink-2); }
.q-lines .ps b { font-weight: 600; color: var(--q-ink); }
.q-lines .pnote { margin-top: 4px; font-size: 12px; font-style: italic; color: var(--q-ink-2); white-space: pre-line; }
.q-total { display: flex; justify-content: flex-end; gap: 28px; align-items: baseline; margin-top: 0; padding: 12px; border: 1px solid var(--q-line); border-top: 0;
  font: 700 15px/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.q-total span { color: var(--q-ink-2); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
.q-notes { margin-top: 26px; }
.q-h { font: 700 13px/1.3 var(--f-display); text-transform: uppercase; letter-spacing: .03em; color: var(--q-bronze); margin-bottom: 8px; }
.q-notes p { margin: 0 0 6px; color: var(--q-ink-2); }
.q-sign { margin-top: 30px; }
.q-sign .po-sig { margin: 4px 0; }
@media (max-width: 600px) {
  .qdoc { padding: 20px 16px; }
  .q-co { font-size: 22px; } .q-logo { height: 40px; }
  .qdoc .q-lines { display: block; overflow-x: auto; }
}
@media print {
  .qdoc { border: 0; border-radius: 0; padding: 0; max-width: none; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .q-lines tr, .q-total, .q-sign, .q-notes p { break-inside: avoid; }
  .q-h { break-after: avoid; }
  .q-sec { break-after: avoid; }
  .q-lines thead { display: table-header-group; }
}

/* ---------- proforma invoice (PI): copy of the paper PI "0050 AE" — Arial, black rules, one A4 sheet per page ---------- */
table.pied input { min-height: 34px; }
table.pied td { padding-left: 4px; padding-right: 4px; }
table.pied input.num { width: 76px; }
.pidocs { display: grid; gap: 24px; overflow-x: auto; }
/* On screen the sheet is A4 with the print margins as padding, so the area for content is exactly the printed one (used to fit lines per page). */
.pidoc {
  background: #fff; color: #000; font: 11.5px/1.25 Arial, Helvetica, "Liberation Sans", sans-serif; width: 210mm; height: 297mm; box-sizing: border-box;
  padding: 10mm 10mm 16mm; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-sm);
}
.pidoc b { font-weight: 700; }
.pi-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.pi-ret { border: 1px dotted #000; padding: 3px 6px; font-size: 15px; line-height: 1.2; justify-self: start; }
.pi-brand { border: 1.5px solid #000; transform: skewX(-14deg); padding: 10px 26px 6px; text-align: center; }
.pi-brand > * { transform: skewX(14deg); }
.pi-brand img { height: 46px; display: block; margin: 0 auto; }
.pi-brand div { font: 700 14px/1.1 "Times New Roman", Georgia, serif; letter-spacing: .02em; margin-top: 2px; }
.pi-addr { font-size: 7.5px; line-height: 1.35; }
.pi-no { margin-top: 6px; font-weight: 700; font-size: 12.5px; }
.pi-no .big { font-size: 16px; margin-left: 8px; }
.pi-parties { width: 100%; border-collapse: collapse; margin-top: 2px; border-top: 2px solid #000; }
.pi-parties td { border: 0; padding: 3px 4px; vertical-align: top; width: 62%; font-size: 12.5px; }
.pi-parties td + td { width: 38%; border-left: 1.5px solid #000; }
.pi-parties tr.buyer td { height: 82px; }
.pi-parties tr + tr td { border-top: 2px solid #000; }
.pi-buyer { font-weight: 700; margin-top: 2px; }
.pi-v { font-weight: 700; margin-left: 90px; }
.pi-body { flex: 1; display: flex; min-height: 0; }
.pi-lines { width: 100%; height: 100%; border-collapse: collapse; border: 2px solid #000; border-left-width: 4px; border-left-style: double; border-right-width: 4px; border-right-style: double; }
.pi-lines th { position: static; background: #fff; color: #000; font: 700 13px Arial, Helvetica, sans-serif; text-transform: none; letter-spacing: 0; border: 1.5px solid #000; padding: 2px 6px; text-align: center; }
.pi-lines td { border: 0; border-left: 1.5px solid #000; padding: 1px 5px; vertical-align: top; height: 1px; color: #000; background: #fff; font-size: 11.5px; }
.pi-lines { table-layout: fixed; }
.pi-lines th:nth-child(1) { width: 7%; } .pi-lines th:nth-child(2) { width: 9%; } .pi-lines th:nth-child(4), .pi-lines th:nth-child(5), .pi-lines th:nth-child(6) { width: 12.5%; }
.pi-lines tr.pi-sum td { white-space: nowrap; overflow: visible; }
.pi-lines td:first-child { border-left: 0; }
.pi-lines tbody tr:hover td { background: #fff; }
.pi-lines td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pi-lines td.c { text-align: center; }
.pi-lines td small { font-size: 9px; }
.pi-lines tr.gs td { padding-top: 9px; }
.pi-lines tr.pi-hd td { padding-top: 10px; padding-bottom: 4px; font-weight: 700; }
.pi-lines tr.pi-fill td { height: auto; }
.pi-lines tr.pi-sum td { padding-top: 6px; padding-bottom: 6px; }
.pi-lines tr.pi-sum td:nth-child(4) { border-left: 1.5px solid #000; }
.pi-lines tr.pi-sum td:nth-child(5) { border-left: 0; }
.pi-tot { display: inline-block; border-bottom: 3px double #000; border-top: 1.5px solid #000; padding: 1px 0 1px 10px; }
.pi-lines tr.pi-words td { padding: 6px 6px 40px; font-size: 12px; }
.pi-lines tr.pi-words td + td { border-left: 0; }
.pi-foot { display: flex; justify-content: space-between; gap: 20px; margin-top: 8px; font-size: 12.5px; }
.pi-terms { border-collapse: collapse; }
.pi-terms td { border: 0; padding: 0 10px 0 0; font-weight: 700; background: none; height: auto; }
.pi-sign { white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; text-align: right; }
.pi-sign img { height: 46px; max-width: 160px; object-fit: contain; }
.pi-sigspace { height: 46px; }
@media print {
  .pidocs { display: block; }
  .pidoc { width: auto; height: 271mm; padding: 0; border: 0; border-radius: 0; box-shadow: none; break-after: page; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pidoc:last-child { break-after: auto; }
}
