/* FreightBridge WMS — shared styles. Light is the default; dark via [data-theme="dark"]. */
:root {
  /* light theme: same colours, ~5% stronger for easier reading */
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #e7ebf1;
  --border: #d3d9e2;
  --text: #121a27;
  --muted: #4f5a6c;
  --brand: #1b56c0;
  --brand-ink: #ffffff;
  --accent: #ea922b;
  --ok: #18793f;
  --warn: #a86b14;
  --bad: #b92828;
  --ok-bg: #d9efe2;
  --warn-bg: #f8e8cb;
  --bad-bg: #f8dada;
  --info-bg: #dae6fb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .07);
  /* banner illustration */
  --sky-1: #dce9ff;
  --sky-2: #f6f9ff;
  --wall: #c9d4e5;
  --rack: #2c4a7a;
  --rack-beam: #f29d38;
  --pallet: #b88a57;
  --box-1: #d9a86c;
  --box-2: #c8925a;
  --box-3: #e6bf88;
  --floor: #a9b6ca;
  --truck: #1f5fd1;
  --truck-cab: #17458f;
  --glass: #bfe0ff;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e131b;
  --surface: #161d28;
  --surface-2: #1d2634;
  --border: #2a3545;
  --text: #e6ebf2;
  --muted: #9aa6b8;
  --brand: #5b93f5;
  --brand-ink: #0b1220;
  --accent: #f5ad55;
  --ok: #4cc584;
  --warn: #e6b44f;
  --bad: #f07272;
  --ok-bg: #12301f;
  --warn-bg: #33270f;
  --bad-bg: #3a1717;
  --info-bg: #15264a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  --sky-1: #0f1a2e;
  --sky-2: #1a2740;
  --wall: #22304a;
  --rack: #6f95d6;
  --rack-beam: #f5ad55;
  --pallet: #8a6a45;
  --box-1: #a67c4b;
  --box-2: #8f6a40;
  --box-3: #b98f5c;
  --floor: #2b3850;
  --truck: #5b93f5;
  --truck-cab: #3d6fc7;
  --glass: #2f4e78;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color .2s, color .2s;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg, var(--surface));
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1600px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: var(--brand-ink); }
.brand small { font-weight: 500; color: var(--muted); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; font-weight: 500; font-size: .92rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--info-bg); color: var(--brand); }
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-chip { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.user-chip b { color: var(--text); font-weight: 600; }

.theme-toggle {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--brand); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.menu-btn { display: none; }

/* ---------- sidebar menu (signed-in pages) ---------- */
.app-shell { max-width: 1600px; margin: 0 auto; padding: 20px 20px 0; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.app-shell > .container { max-width: none; margin: 0; padding: 4px 0 60px; }
.sidebar {
  position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.side-user { display: flex; gap: 12px; align-items: center; padding: 18px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); border-radius: 14px 14px 0 0; }
.avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #1a1205; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; letter-spacing: .5px; }
.side-user-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.side-user-text b { font-size: .98rem; line-height: 1.2; overflow-wrap: anywhere; }
.side-user-text small { color: var(--muted); font-size: .8rem; }
.role-pill { font-size: .72rem; font-weight: 700; color: var(--accent); background: var(--bg); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
  color: var(--text); font-weight: 600; font-size: .95rem; border-left: 3px solid transparent;
}
.side-nav a svg { flex: none; color: var(--muted); }
.side-nav a:hover { background: var(--surface-2); text-decoration: none; }
.side-nav a.active { background: color-mix(in srgb, var(--accent) 18%, transparent); border-left-color: var(--accent); color: var(--accent); }
.side-nav a.active svg { color: var(--accent); }
.nav-count { margin-left: auto; font-size: .8rem; font-weight: 700; color: var(--bad); }
.side-scrim { display: none; }
.side-signout { display: none; padding: 4px 12px 14px; }
.side-account { font-size: .78rem; font-weight: 600; }
.user-actions summary { list-style: none; cursor: pointer; } .user-actions summary::-webkit-details-marker { display: none; }
.user-actions-box { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; max-width: 260px; }
.user-actions-box form { flex-wrap: wrap; }
.user-actions-box input { flex: 1 1 140px; min-width: 0 !important; }

/* ---------- layout ---------- */
.container { max-width: 1600px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--block-bg, var(--surface)); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 18px;
}
.card h2 { margin-bottom: 12px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--brand); }

/* ---------- forms & buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.lg { padding: 13px 22px; font-size: 1rem; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
.field { margin-bottom: 14px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid var(--border); }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.alert.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------- home banner: 1600 × 700 ---------- */
.hero {
  position: relative; width: 100%; max-width: 1600px; margin: 0 auto;
  aspect-ratio: 1600 / 700; max-height: 700px; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.hero svg.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-copy {
  position: absolute; left: 6%; top: 50%; transform: translateY(-50%);
  max-width: 560px; padding: 30px 34px; border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.hero-copy .eyebrow { color: var(--accent); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; }
.hero-copy h1 { font-size: clamp(1.7rem, 3.2vw, 3rem); margin: 8px 0 12px; }
.hero-copy p { color: var(--muted); font-size: 1.05rem; margin: 0 0 22px; }
.hero-copy .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.section { max-width: 1600px; margin: 0 auto; padding: 48px 20px 0; }
.section > h2 { font-size: 1.5rem; margin-bottom: 6px; }
.section > p.lead { color: var(--muted); margin: 0 0 22px; }
.feature .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--info-bg); color: var(--brand); display: grid; place-items: center; margin-bottom: 10px; }
.feature h3 { font-size: 1.05rem; }
.feature p { color: var(--muted); margin: 0; font-size: .93rem; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.flow span.step { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .9rem; }
.flow span.arrow { color: var(--muted); }
/* home: feature blocks, comparison checklist, closing band */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.feature-grid .feature { border-top: 3px solid var(--tone, var(--brand)); }
.feature-grid .feature .ico { background: var(--tone-bg, var(--info-bg)); color: var(--tone, var(--brand)); }
.tone-blue   { --tone: var(--brand);  --tone-bg: var(--info-bg); }
.tone-green  { --tone: var(--ok);     --tone-bg: var(--ok-bg); }
.tone-orange { --tone: var(--warn);   --tone-bg: var(--warn-bg); }
.tone-purple { --tone: #6d4bc4;       --tone-bg: #e9e2fa; }
:root[data-theme="dark"] .tone-purple { --tone: #b49cf5; --tone-bg: #2a2147; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tone-purple { --tone: #b49cf5; --tone-bg: #2a2147; } }
.compare-card { padding: 0; overflow: hidden; }
.compare-card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
table.compare { width: 100%; border-collapse: collapse; min-width: 640px; }
table.compare th, table.compare td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
table.compare .c-short { display: none; }
table.compare th[scope="row"], :root[data-theme] table.compare th[scope="row"] { text-align: left; font-weight: 600; text-transform: none; letter-spacing: normal; font-size: .92rem; color: var(--text); background: transparent; white-space: normal; }
#features, #compare, #workflow { scroll-margin-top: 80px; }
table.compare thead th { font-size: .85rem; color: var(--muted); }
table.compare thead th { text-align: center; white-space: normal; }
table.compare thead th.us, :root[data-theme] table.compare thead th.us { color: var(--brand-ink); background: var(--brand); }
table.compare td.us { background: color-mix(in srgb, var(--brand) 8%, transparent); }
table.compare tbody tr:last-child > * { border-bottom: 0; }
.mk { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; }
.m-yes .mk { background: var(--ok-bg); color: var(--ok); }
.m-part .mk { background: var(--warn-bg); color: var(--warn); }
.m-no .mk { background: var(--bad-bg); color: var(--bad); }
.compare-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); font-size: .85rem; }
.compare-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.compare-legend .mk { width: 20px; height: 20px; }
.cta-band { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding: 28px 30px; border-radius: 16px; background: linear-gradient(120deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #000)); color: #fff; }
.cta-band h2 { margin: 0 0 4px; font-size: 1.4rem; color: #fff; }
.cta-band p { margin: 0; opacity: .9; }
.home-gap { height: 48px; }
@media (max-width: 760px) {
  .feature-grid { grid-template-columns: 1fr; gap: 12px; }
  table.compare { min-width: 0; font-size: .82rem; table-layout: fixed; }
  table.compare thead th:first-child { width: 40%; }
  table.compare .c-long { display: none; }
  table.compare .c-short { display: inline; }
  table.compare th[scope="row"], :root[data-theme] table.compare th[scope="row"] { font-size: .82rem; }
  table.compare th, table.compare td { padding: 9px 6px; }
  table.compare thead th { font-size: .72rem; }
  .mk { width: 20px; height: 20px; }
  .cta-band { padding: 22px 18px; }
  .cta-band .btn { width: 100%; text-align: center; justify-content: center; }
}
.footer { max-width: 1600px; margin: 60px auto 0; padding: 24px 20px; color: var(--muted); border-top: 1px solid var(--border); font-size: .85rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- new-order alarm ---------- */
.bell .bell-slash { display: inline; }
.bell.bell-on { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.bell.bell-on .bell-slash { display: none; }
.order-alert { position: fixed; z-index: 60; left: 50%; top: 70px; transform: translateX(-50%); width: min(720px, calc(100vw - 24px));
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 14px 18px; border-radius: 12px; background: #c53030; color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-size: 1.05rem; animation: order-pulse 1s ease-in-out infinite alternate; }
.order-alert .btn { background: #fff; color: #c53030; border-color: #fff; }
.order-alert-actions { display: flex; gap: 8px; }
@keyframes order-pulse { from { box-shadow: 0 0 0 0 rgba(197, 48, 48, .7); } to { box-shadow: 0 0 0 14px rgba(197, 48, 48, 0); } }
@media (prefers-reduced-motion: reduce) { .order-alert { animation: none; } }

.email-status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: .9rem; }

/* ---------- branding ---------- */
.brand-logo { display: inline-flex; align-items: center; border-radius: 5px; background: #fff; }
.brand-logo img { max-height: 60px; max-width: 179px; width: auto; height: auto; display: block; }
.logo-preview { min-width: 200px; min-height: 80px; padding: 12px; border-radius: 10px; border: 1px dashed var(--border); background: #fff; display: grid; place-items: center; }
.logo-preview img { max-width: 240px; max-height: 60px; }

/* ---------- printable documents (order / invoice): always paper-white ---------- */
.doc-paper { max-width: 860px; margin: 0 auto; background: #fff; color: #1a2230; border-radius: 10px; padding: 40px 44px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.doc-paper h1 { font-size: 1.7rem; margin: 0; color: #1a2230; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; flex-wrap: wrap; border-bottom: 2px solid #1a2230; padding-bottom: 16px; margin-bottom: 18px; }
.doc-logo { max-height: 70px; max-width: 280px; }
.doc-company { font-size: .88rem; color: #5b6678; line-height: 1.45; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; font-size: .92rem; }
.doc-meta b { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: #5b6678; }
.doc-paper table { font-size: .92rem; }
.doc-paper th { background: #eef1f5; color: #5b6678; }
.doc-paper th, .doc-paper td { border-bottom: 1px solid #dfe3ea; color: #1a2230; }
.doc-paper tbody tr:hover td { background: transparent; }
.doc-totals { margin-left: auto; width: min(320px, 100%); margin-top: 12px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #dfe3ea; }
.doc-totals .grand { font-size: 1.15rem; font-weight: 800; border-bottom: 2px solid #1a2230; }
.doc-foot { margin-top: 26px; font-size: .82rem; color: #5b6678; }
@media print {
  .doc-paper { box-shadow: none; border: 0; padding: 0; max-width: none; }
}
@media (max-width: 640px) { .doc-paper { padding: 22px 16px; } }

/* ---------- product photos ---------- */
.thumb { box-sizing: content-box; width: 120px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.thumb-empty { display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.thumb-link { display: inline-block; border-radius: 8px; }
.thumb-link:hover .thumb { outline: 2px solid var(--brand); outline-offset: 1px; }
.thumb-sm .thumb { width: 75px; height: 60px; }
.lightbox { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 16px; box-shadow: var(--shadow); text-align: center; }
.lightbox::backdrop { background: rgba(10, 14, 20, .6); }
.lightbox img { display: block; max-width: 450px; max-height: 450px; width: auto; height: auto; margin: 0 auto 10px; border-radius: 8px; }
.lightbox-caption { margin: 0 0 10px; font-weight: 600; }

/* ---------- pull sheet ---------- */
.pull-check { width: 26px; height: 26px; accent-color: var(--ok); cursor: pointer; }
tr.is-pulled td { background: color-mix(in srgb, var(--ok-bg) 60%, transparent); }
.match { font-weight: 700; }
.match.ok { color: var(--ok); }
.match.bad { color: var(--bad); }
@media print {
  .topbar, .no-print, .alert, .sidebar { display: none !important; }
  .app-shell { display: block; padding: 0; }
  body { background: #fff; color: #000; }
  .card, .table-wrap { box-shadow: none; border-color: #999; }
  .container { padding: 0; }
}

/* ---------- field sales ---------- */
.steps { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.step-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.step-btn span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .8rem; }
.step-btn.active { border-color: var(--brand); color: var(--brand); }
.step-btn.active span { background: var(--brand); color: var(--brand-ink); }
.step-btn:disabled { opacity: .45; cursor: default; }
.live-note { margin-left: auto; font-size: .82rem; }
.tile-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; padding: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; box-shadow: var(--shadow); min-height: 92px; }
.tile:hover, .tile:focus-visible { border-color: var(--brand); outline: none; }
.tile b { font-size: 1.05rem; }
.tile-meta { font-size: .82rem; color: var(--muted); }
.product-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(450px, 1fr)); padding-bottom: 90px; }
.pcard { display: flex; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.pcard.in-cart { border-color: var(--ok); }
.pcard-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pdesc { margin: 0; font-size: .82rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.price { font-size: 1.1rem; font-weight: 700; }
.stepper { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stepper .btn { min-width: 44px; min-height: 44px; justify-content: center; padding: 6px 10px; font-size: 1.1rem; }
.stepper .btn.sm { font-size: .85rem; min-width: 0; }
.stepper input { width: 72px; min-height: 44px; text-align: center; font-size: 1.05rem; }
.warn-line { color: var(--bad); font-size: .82rem; font-weight: 600; min-height: 1em; }
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px max(16px, calc((100vw - 1600px) / 2 + 20px)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0, 0, 0, .12); }
.cartbar.has-problem { border-top: 3px solid var(--bad); }
.review { width: min(720px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 18px; }
.review::backdrop { background: rgba(10, 14, 20, .6); }
@media (max-width: 640px) {
  .pcard { flex-direction: column; }
  .pcard .thumb-link, .pcard .thumb-empty { align-self: center; }
  .live-note { margin-left: 0; flex-basis: 100%; }
}

/* ---------- overview dashboard ---------- */
:root { --s1: #2a78d6; --s2: #eb6834; --st-good: #0ca30c; --st-warn: #fab219; --st-crit: #d03b3b; }
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; }
.eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1a1205; font-weight: 700; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.filter-bar > div { min-width: 170px; }
.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 14px 16px; }
.kpi-label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.kpi-value { font-size: 1.7rem; font-weight: 800; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.kpi-hero { border-color: var(--brand); background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--brand) 14%, var(--surface))); }
.kpi-link { color: inherit; } .kpi-link:hover { text-decoration: none; border-color: var(--accent); }
.kpi-delta { font-weight: 700; } .kpi-delta.up { color: var(--ok); } .kpi-delta.down { color: var(--bad); }
.warn-text { color: var(--warn); } .bad-text { color: var(--bad); }
.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
.health-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 4px; border-bottom: 1px solid var(--border); color: inherit; }
.health-item:hover { text-decoration: none; background: var(--surface-2); }
.hi-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 900; color: #fff; background: var(--muted); }
.hi-icon.good { background: var(--st-good); } .hi-icon.watch { background: var(--st-warn); color: #1a1205; } .hi-icon.action { background: var(--st-crit); }
.hi-text { flex: 1; display: flex; flex-direction: column; font-size: .88rem; } .hi-text span { color: var(--muted); font-size: .82rem; }
.hi-status { font-size: .68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; color: var(--muted); }
.hi-status.good { color: var(--ok); } .hi-status.watch { color: var(--warn); } .hi-status.action { color: var(--bad); }
.legend { display: flex; gap: 14px; justify-content: flex-end; font-size: .8rem; color: var(--muted); margin: -26px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; } .sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); }
svg.chart { width: 100%; height: 240px; display: block; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .base { stroke: var(--muted); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
svg.chart .bar.s1 path { fill: var(--s1); } svg.chart .bar.s2 path { fill: var(--s2); }
svg.chart .hit { fill: transparent; } svg.chart .bar:hover path { opacity: .8; } svg.chart .bar:hover .hit { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.chart-table { margin-top: 6px; font-size: .85rem; } .chart-table summary { cursor: pointer; color: var(--muted); }
.hbars { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.hbar-row { display: grid; grid-template-columns: 96px 1fr 120px; gap: 10px; align-items: center; font-size: .88rem; }
.hbar-track { height: 14px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-fill.crit { background: var(--st-crit); }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .health-grid { grid-template-columns: 1fr; } .legend { margin-top: 0; justify-content: flex-start; } }

/* ---------- data import / export ---------- */
.data-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.data-head { font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.data-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 2px; border-bottom: 1px solid var(--border); color: inherit; }
.data-row input[type=file] { flex: 1; min-width: 180px; font-size: .85rem; }
.data-label { flex: 1 1 200px; display: flex; flex-direction: column; } .data-label small { color: var(--muted); font-size: .78rem; }
.data-export:hover { text-decoration: none; background: var(--surface-2); }
.import-errors { max-height: 450px; overflow-y: auto; font-size: .88rem; color: var(--bad); }
@media (max-width: 900px) { .data-grid { grid-template-columns: 1fr; } }

/* ---------- notifications ---------- */
.notif-wrap { position: relative; }
.notif-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--st-crit); color: #fff; font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
.notif-panel { position: absolute; right: 0; top: 46px; width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 50; padding: 6px; }
.notif-panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 10px 4px; }
.notif-item { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: .86rem; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item small { display: block; color: var(--muted); }
.notif-empty { padding: 14px; color: var(--muted); font-size: .88rem; }
.mail-btn { position: relative; color: var(--text); } .mail-btn:hover { text-decoration: none; }
.mail-badge { background: var(--s1); }
.nav-pill { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--s1); color: #fff; font-size: .75rem; font-weight: 800; text-align: center; }

/* ---------- phone item cards (pull sheet + new order search) ---------- */
.img-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--brand); }
.img-icon.none { color: var(--muted); opacity: .45; }
.img-icon:hover { text-decoration: none; border-color: var(--brand); }
.pull-cards { display: none; }
.pull-staging { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.pcard-m { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px; margin-bottom: 10px; }
.pcard-m.is-pulled { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.pm-row1 { display: flex; gap: 0; align-items: flex-start; }
.pm-title { width: 80%; display: flex; flex-direction: column; gap: 3px; padding-right: 8px; min-width: 0; }
.pm-title b { font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }
.pm-meta { font-size: .78rem; color: var(--muted); }
.pm-img { width: 20%; display: flex; justify-content: flex-end; }
.pm-row2 { display: flex; justify-content: space-between; margin-top: 10px; }
.pm-field { width: 49%; display: flex; flex-direction: column; gap: 4px; }
.pm-label { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.pm-avail { display: flex; align-items: center; min-height: 48px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pm-field input { min-height: 48px; font-size: 1.25rem; font-weight: 800; text-align: left; width: 100%; }
.pm-confirm { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 12px; border-radius: 10px; border: 2px solid var(--accent); font-weight: 800; cursor: pointer; justify-content: center; }
.pm-confirm input { width: 24px; height: 24px; }
.is-pulled .pm-confirm { border-color: var(--ok); color: var(--ok); }
.pm-add { width: 100%; justify-content: center; margin-top: 10px; min-height: 44px; }
@media (max-width: 700px) {
  .pull-table { display: none; }
  .pull-cards { display: block; }
  .pull-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .pull-stats .stat { padding: 10px; } .pull-stats .value { font-size: 1.2rem; }
  /* new order: search results become cards */
  .order-steps .psearch-results { max-height: none; border: 0; gap: 10px; overflow: visible; }
  /* (prefixed with .psearch-results so these beat the desktop .psr rules further down) */
  .psearch-results .psr { flex-wrap: wrap; align-items: flex-start; border: 1px solid var(--border); border-radius: 12px; padding: 12px; gap: 0; }
  .psearch-results .psr .psr-thumb { display: none; }
  .psearch-results .psr .psr-main { flex: 0 0 80%; width: 80%; max-width: 80%; padding-right: 8px; }
  .psearch-results .psr .psr-main b { white-space: normal; overflow-wrap: anywhere; }
  .psearch-results .psr .pm-img { display: flex; flex: 0 0 20%; max-width: 20%; justify-content: flex-end; }
  .psearch-results .psr .psr-price { display: none; }
  .psearch-results .psr .pm-row2 { flex: 0 0 100%; width: 100%; }
  .psearch-results .psr > input[type=number], .psearch-results .psr > .psr-addbtn { display: none; }
  /* order lines: compact on phones */
  #order-lines input[type=number] { width: 72px !important; }
}
@media (min-width: 701px) {
  .psr .pm-img, .psr .pm-row2, .psr .pm-add { display: none; }
}
@media print { .pull-cards { display: none !important; } .pull-table { display: block !important; } }

/* ---------- customer profile: allowed categories ---------- */
.cat-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.cat-pick { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 500; }
.cat-pick input { width: auto; margin-top: 3px; }
.cat-pick span { display: flex; flex-direction: column; } .cat-pick small { font-size: .78rem; }
.cat-pick:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.cat-pick.sub { margin-left: 0; border-style: dashed; }

/* ---------- new order: customer first, then search ---------- */
.order-steps { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.order-steps > * { min-width: 0; }
.step-no { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #1a1205; font-size: .85rem; margin-right: 6px; vertical-align: 2px; }
.psr input[type=number] { min-height: 38px; }
.cust-info { display: flex; gap: 14px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-top: 8px; }
.cust-info b { color: var(--text); }
.psearch-results { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 10px; max-height: 420px; overflow-y: auto; }
.psr { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.psr:last-child { border-bottom: 0; }
.psr img, .psr .noimg { width: 60px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-2); }
.psr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.psr-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psr-meta { font-size: .8rem; color: var(--muted); }
.psr-price { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.psr.in-order { background: color-mix(in srgb, var(--ok) 8%, transparent); }
/* simple new-order page: customer search, product search, note + delivery day, Place order */
.order-simple > .card > label { font-size: .95rem; margin-bottom: 6px; }
.order-simple input[type=search] { min-height: 48px; font-size: 1rem; }
.cust-picked { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 6px 8px 6px 14px; border: 2px solid var(--brand); border-radius: 10px; background: var(--info-bg); }
.cust-picked b { font-size: 1.02rem; }
.cust-results { max-height: 320px; }
/* Footer: text in the same colour as the background (shows only when selected) */
.dev-footer, .dev-footer a { background: var(--bg); color: var(--bg); }
.dev-footer { text-align: center; font-size: .8rem; padding: 2px 16px 18px; }
.site-footer { background: var(--bg); }
.copyright { text-align: center; font-size: .78rem; color: var(--muted); padding: 16px 16px 0; }
.dev-footer a { text-decoration: none; }

/* Setup: clear database (Super Admin) */
.danger-zone { margin-top: 24px; border: 2px solid var(--bad); background: color-mix(in srgb, var(--bad) 5%, var(--surface)); }
.dz-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.dz-head h2 { color: var(--bad) !important; }
.dz-icon { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--bad); color: #fff; font-size: 1.4rem; }
.dz-sub { margin: 2px 0 0; font-size: .8rem; font-weight: 700; color: var(--bad); text-transform: uppercase; letter-spacing: .05em; }
.dz-warning { padding: 12px 14px; border-radius: 10px; background: var(--bad-bg); color: var(--text); font-size: .9rem; }
.dz-warning > b { color: var(--bad); }
.dz-warning ul { margin: 8px 0 0; padding-left: 20px; }
.dz-warning li { margin: 3px 0; }
.dz-counts { margin: 12px 0; font-size: .9rem; }
.dz-counts summary { cursor: pointer; }
.dz-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; color: var(--muted); }
.dz-grid b { color: var(--text); }
.dz-form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.dz-form .field { margin: 0; flex: 1 1 220px; }
.dz-check { flex: 1 1 100%; display: flex; gap: 10px; align-items: flex-start; font-weight: 600; margin: 0; cursor: pointer; }
.dz-check input { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.dz-form .btn.danger { flex: 1 1 100%; justify-content: center; }
.dz-form .btn.danger[disabled] { opacity: .45; }
.short-note { flex: 0 0 100%; width: 100%; margin-top: 6px; font-size: .8rem; font-weight: 600; color: var(--warn); }
.acct-line { flex: 1 1 100%; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.acct-bal { display: inline-flex; gap: 4px; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .85rem; background: var(--ok-bg); color: var(--ok); }
.acct-bal b { color: inherit; }
.acct-bal.open { background: var(--info-bg); color: var(--brand); }
.acct-bal.overdue { background: var(--bad-bg); color: var(--bad); }
.acct-bal.credit { background: var(--ok-bg); color: var(--ok); }
.psearch-results:empty { display: none; }
button.psr { width: 100%; text-align: left; background: var(--surface); border: 0; border-bottom: 1px solid var(--border); font: inherit; color: var(--text); cursor: pointer; }
button.psr:hover, button.psr:focus-visible { background: var(--info-bg); }
.place-order { margin-left: auto; display: flex; }
#step-finish .form-row { align-items: flex-start; }
body:has(#order-form.order-simple) .page-foot { display: none !important; }
@media (max-width: 1024px) {
  body:has(#order-form.order-simple) .page-head .page-actions { display: none; }
  .place-order { width: 100%; justify-content: center; min-height: 54px; font-size: 1.1rem; margin-top: 6px; }
  #step-finish .form-row { flex-direction: column; gap: 0; }
  #step-finish .form-row > .field { width: 100%; }
}
@media (max-width: 1024px) {
  body:has(#order-form.order-simple) .jump-btns { display: none; }
}
@media (max-width: 700px) {
  .psearch-results.cust-results .psr .psr-main { flex: 1 1 100%; width: 100%; max-width: 100%; padding-right: 0; }
  /* order lines as a short list: name, then qty | price | total | remove */
  #step-lines .table-wrap { border: 0; overflow: visible; }
  #step-lines thead { display: none; }
  #step-lines table, #step-lines tbody, #step-lines tfoot { display: block; }
  #step-lines tbody tr { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 6px 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
  #step-lines tbody td { display: block; padding: 0; border: 0; background: none !important; text-align: left; }
  #step-lines tbody td:first-child { grid-column: 1 / -1; }
  #step-lines tbody td input { width: 100% !important; }
  #step-lines tbody td:nth-child(4) { font-weight: 700; white-space: nowrap; }
  #step-lines tfoot tr { display: flex; justify-content: space-between; padding: 10px 0 0; }
  #step-lines tfoot td { display: block; padding: 0; border: 0; }
  #step-lines tfoot td:empty { display: none; }
}
.stock-ok { color: var(--ok); } .stock-low { color: var(--warn); } .stock-none { color: var(--bad); }

/* ---------- email ---------- */
.mail-tabs { display: flex; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.mail-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 700; font-size: .92rem; }
.mail-tab:hover { text-decoration: none; border-color: var(--accent); }
.mail-tab.active { background: color-mix(in srgb, var(--accent) 20%, transparent); border-color: var(--accent); color: var(--accent); }
.mail-tab.disabled { opacity: .45; cursor: default; }
.tab-count { min-width: 22px; padding: 1px 8px; border-radius: 999px; background: var(--s1); color: #fff; font-size: .75rem; font-weight: 800; text-align: center; }
.mail-search { display: flex; gap: 8px; margin-bottom: 14px; }
.mail-search input { flex: 1; min-height: 46px; }
.mail-cards { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.mail-card { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); color: var(--text); }
.mail-card:last-child { border-bottom: 0; }
.mail-card:hover { background: var(--surface-2); text-decoration: none; }
.mc-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mc-from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-addr { font-weight: 400; font-size: .85rem; }
.mc-subj { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-card.unread .mc-from { font-weight: 800; }
.mail-card.unread .mc-subj { color: var(--text); font-weight: 700; }
.mc-date { flex: none; font-size: .85rem; color: var(--muted); }
.mail-list tr.unread td { font-weight: 700; }
.mail-list tr.unread td a { color: var(--text); }
.mail-list td a { color: var(--text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--s1); margin-right: 7px; vertical-align: middle; }
.mail-meta { display: flex; flex-direction: column; gap: 2px; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.mail-body { white-space: normal; overflow-wrap: anywhere; line-height: 1.6; max-width: 900px; }
.mail-att { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.inbox-mini a { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); color: var(--text); font-size: .88rem; }
.inbox-mini a:hover { background: var(--surface-2); text-decoration: none; }
.inbox-mini .im-from { width: 34%; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-mini .im-subj { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.inbox-mini .unread .im-from, .inbox-mini .unread .im-subj { font-weight: 700; color: var(--text); }

/* ---------- auth ---------- */
.auth-wrap { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.install-card { max-width: 620px; }
.stock-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px 4px; margin: 4px 0 16px; }
.stock-box legend { font-weight: 600; padding: 0 6px; }
tr.pull-diff td { background: var(--warn-bg); }
.test-data { border-left: 4px solid var(--accent); }
.install-checks { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.install-checks td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 14px; }
.install-checks td:first-child { width: 64px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .app-shell { display: block; padding: 0; }
  .app-shell > .container { padding: 20px 20px 60px; }
  .sidebar { display: none; position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(290px, 85vw); max-height: none; border-radius: 0 14px 14px 0; }
  .sidebar.open { display: block; }
  .sidebar.open + .side-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5, 8, 14, .55); }
  .hero { aspect-ratio: auto; min-height: 520px; }
  .hero svg.hero-art { opacity: .55; }
  .hero-copy { left: 16px; right: 16px; max-width: none; padding: 22px; }
}
@media (max-width: 640px) {
  .topbar-inner, .container, .section { padding-left: 16px; padding-right: 16px; gap: 10px; }
  .topbar-inner { gap: 8px; }
  .top-actions { gap: 6px; }
  .top-actions .theme-toggle { width: 36px; height: 36px; }
  .brand-logo img { max-width: 92px; }
  .side-signout { display: block; }
  .top-signout { display: none; }
  .brand small { display: none; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); } /* minmax(0,…): wide tables scroll inside their card instead of widening the page */
}

/* ---------- page control buttons (top right by the title, repeated at the end) ---------- */
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.page-actions .page-actions { display: contents; }
.page-foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: 22px; padding: 14px 58px 0 0; border-top: 1px solid var(--border); }
.page-foot > div { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rec-nav[aria-disabled="true"] { opacity: .45; cursor: default; }
.rec-nav[aria-disabled="true"]:hover { border-color: var(--border); }
.btn.is-busy { opacity: .6; cursor: progress; }

/* ---------- jump to top / bottom ---------- */
.jump-btns { position: fixed; right: 18px; bottom: 24px; z-index: 30; display: flex; flex-direction: column; gap: 8px; }
.jump-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff; background: var(--brand); box-shadow: 0 4px 14px rgba(16, 24, 40, .25); opacity: .88; }
.jump-btn:hover { opacity: 1; }
.jump-btn[data-jump="bottom"] { background: var(--accent); color: #1a1205; }

/* ---------- phone tab bar + overview tiles ---------- */
.tabbar, .quick-tiles, .phone-more-btn { display: none; }
.qtile { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 92px; padding: 14px; border-radius: 14px; color: #fff; box-shadow: var(--shadow); }
.qtile:hover { text-decoration: none; filter: brightness(1.05); }
.qtile b { font-size: 1.08rem; line-height: 1.2; }
.qtile small { font-size: .78rem; opacity: .92; }
.t-blue { background: linear-gradient(135deg, var(--brand), var(--s1)); }
.t-orange { background: linear-gradient(135deg, var(--s2), var(--accent)); color: #1a1205; }
.t-green { background: linear-gradient(135deg, var(--ok), #2fa865); }
.t-warn { background: linear-gradient(135deg, #f2b33d, var(--accent)); color: #1a1205; }

@media (max-width: 700px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 24, 40, .1);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; color: var(--muted); font: inherit; font-size: .7rem; font-weight: 700; cursor: pointer; padding: 0 2px;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--brand); }
  .tabbar a.active::before { content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tabbar .tab-count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--st-crit); color: #fff; font-style: normal; font-size: .68rem; display: grid; place-items: center; }
  .menu-btn { display: none !important; }
  .jump-btns { right: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .jump-btn { width: 40px; height: 40px; }
  body:has(.page-foot.has-save) .jump-btns { bottom: calc(150px + env(safe-area-inset-bottom)); }

  /* bigger, simpler controls for work on the floor and at the customer */
  .btn { min-height: 44px; justify-content: center; }
  .btn.sm { min-height: 36px; }
  input, select, textarea { font-size: 16px; min-height: 44px; }
  input[type=checkbox], input[type=radio] { min-height: 0; }
  h1 { font-size: 1.35rem; }
  .page-head { align-items: stretch; margin-bottom: 14px; }
  .page-head > div:first-child p.muted { font-size: .85rem; }
  .page-actions { justify-content: flex-start; width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .page-head.foot-saves [data-page-actions] button[form] { display: none; }
  .page-foot { margin-top: 16px; }
  .page-foot .btn { flex: 1 1 40%; }
  .page-foot.has-save {
    position: sticky; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 25;
    margin: 16px -16px 0; padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 14px rgba(16, 24, 40, .1);
  }
  .page-foot.has-save .rec-nav, .page-foot.has-save a.btn:not(.primary) { display: none; }
  .page-foot.has-save button.btn { flex: 1 1 40%; }

  /* overview: big job tiles first, charts on request */
  .quick-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .phone-more-btn { display: flex; width: 100%; margin-bottom: 14px; }
  .phone-more { display: none !important; }
  body.show-more .phone-more { display: grid !important; }
  body.show-more form.phone-more { display: flex !important; }
  body.show-more .card.phone-more { display: block !important; }
  .kpi-grid { gap: 8px; }
  .kpi { padding: 10px 12px; } .kpi-value { font-size: 1.3rem; }
  .grid.grid-3:has(> .card.stat) { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .grid.grid-3 > .card.stat { padding: 10px; }
  .grid.grid-3 > .card.stat .value { font-size: 1.2rem; }
  .grid.grid-3 > .card.stat .label, .grid.grid-3 > .card.stat .muted { font-size: .72rem !important; }
  .page-head:has(+ .quick-tiles) .page-actions { display: none; }
}

/* ---------- order page: products, Add products window, totals ---------- */
.olc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ol-prod { display: flex; gap: 10px; align-items: center; }
.ol-prod > span { display: flex; flex-direction: column; min-width: 0; }
.img-icon.sm { width: 36px; height: 36px; flex: none; border-radius: 8px; }
.ol-qty { width: 96px; text-align: right; }
.ol-qty.saving { border-color: var(--accent); }
.ol-qty.saved { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.order-summary { margin: 14px 0 0 auto; max-width: 360px; display: flex; flex-direction: column; gap: 6px; }
.order-summary > div { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.order-summary > div span { color: var(--muted); }
.order-summary .grand { border-top: 2px solid var(--border); padding-top: 8px; font-size: 1.15rem; }
.order-summary .grand span { color: var(--text); font-weight: 700; }
.os-note { font-size: .78rem; margin: 2px 0 0; text-align: right; }
.os-ship { align-items: center; }
.os-ship label { display: inline; margin: 0; font-weight: 400; font-size: inherit; color: var(--muted); }
.ship-input { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-weight: 700; }
.ship-input input { width: 110px; text-align: right; min-height: 38px; }
.ship-input input.saving { border-color: var(--accent); }
.ship-input input.saved { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.picker { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.picker::backdrop { background: rgba(5, 8, 14, .55); }
.picker-box { display: flex; flex-direction: column; gap: 10px; padding: 16px; max-height: calc(100vh - 50px); }
.picker-head { display: flex; justify-content: space-between; align-items: center; }
.picker #pk-search { min-height: 46px; font-size: 1rem; }
.pk-cols, .pk-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 90px 100px 110px 110px; gap: 10px; align-items: center; }
.pk-cols { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 10px; }
.pk-list { overflow-y: auto; flex: 1; min-height: 160px; border: 1px solid var(--border); border-radius: 10px; }
.pk-row { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.pk-row:last-child { border-bottom: 0; }
.pk-row.on { background: color-mix(in srgb, var(--ok) 9%, transparent); }
.pk-name { display: flex; flex-direction: column; min-width: 0; }
.pk-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-name small { font-size: .78rem; }
.pk-price small { display: block; font-size: .72rem; }
.pk-qty input { width: 100%; text-align: right; min-height: 40px; }
.pk-empty { padding: 14px; margin: 0; }
.picker-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 12px; }
.pk-sum { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.pk-sum b { color: var(--text); }
.pk-actions { display: flex; gap: 8px; }
.tax-box { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
.tax-exempt { display: flex; gap: 8px; align-items: center; min-height: 44px; margin: 0; cursor: pointer; }
.tax-exempt input { width: 22px; height: 22px; }
.tax-rate { margin: 0; } .tax-rate input { width: 140px; }
.tax-rate input:disabled { opacity: .5; text-decoration: line-through; }
.tax-note { flex: 1 1 100%; margin: 0; font-size: .85rem; }
@media (max-width: 1100px) {
  /* order lines become cards: product, then the numbers in two columns */
  .order-lines thead { display: none; }
  .order-lines, .order-lines tbody { display: block; }
  .order-lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); position: relative; }
  .order-lines td { display: flex; justify-content: space-between; align-items: center; padding: 0; border: 0; background: none !important; text-align: left; }
  .order-lines td[data-label]::before { content: attr(data-label); font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-right: 6px; }
  .order-lines td.ol-name { grid-column: 1 / -1; padding-right: 48px; }
  .order-lines td.ol-remove { position: absolute; top: 10px; right: 0; }
  .order-lines .ol-qty { width: 84px; }
  .order-lines-card .table-wrap { border: 0; overflow: visible; }
}
@media (min-width: 701px) and (max-width: 1100px) {
  .order-lines tr { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .order-summary { max-width: none; }
  .picker { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .picker-box { height: 100%; max-height: none; padding: 12px; }
  .pk-cols { display: none; }
  .pk-row { grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 12px 10px; }
  .pk-img { grid-column: 2; grid-row: 1; justify-self: end; }
  .pk-name { grid-column: 1; grid-row: 1; }
  .pk-name b { white-space: normal; }
  .pk-row > [data-label] { display: flex; justify-content: space-between; align-items: center; text-align: left; }
  .pk-row > [data-label]::before { content: attr(data-label); font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
  .pk-qty input { width: 90px; min-height: 44px; font-size: 1.05rem; }
  .picker-foot { flex-direction: column; align-items: stretch; }
  .pk-actions .btn { flex: 1; }
}

/* ---------- product search: suggestions + list icon ---------- */
.search-wrap { position: relative; display: flex; gap: 8px; align-items: stretch; }
.search-wrap > input { flex: 1; min-width: 0; }
.icon-btn { flex: none; width: 48px; min-height: 46px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--brand); cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { border-color: var(--brand); background: var(--info-bg); }
.suggest { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 56px; max-height: min(380px, 60vh); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 24, 40, .22); padding: 4px; }
.sg-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.sg-item:hover, .sg-item.active { background: var(--info-bg); }
.sg-item img, .sg-noimg { width: 40px; height: 34px; flex: none; border-radius: 6px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.sg-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sg-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-text small, .sg-num small { font-size: .76rem; color: var(--muted); }
.sg-num { flex: none; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.sg-num small.stock-ok { color: var(--ok); } .sg-num small.stock-low { color: var(--warn); } .sg-num small.stock-none { color: var(--bad); }
.sg-empty { padding: 12px; color: var(--muted); font-size: .9rem; }
.psr.flash, .pk-row.flash { animation: fb-flash 1.2s ease-out; }
@keyframes fb-flash { from { background: color-mix(in srgb, var(--accent) 35%, transparent); } to { background: transparent; } }
@media (max-width: 700px) {
  .suggest { right: 0; }
  .sg-item { padding: 10px 8px; }
}

/* ---------- light theme: same colours, used more boldly ---------- */
:root[data-theme="light"] {
  --bg: #e6edf8;
  --surface-2: #e3eaf6;
  --border: #c9d4e6;
  --info-bg: #d3e2fb;
  --ok-bg: #d2efdd;
  --warn-bg: #fbe5c0;
  --bad-bg: #f9d3d3;
  --brand-deep: #123f94;
}
:root[data-theme="light"] .topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: linear-gradient(90deg, var(--brand), var(--s1) 50%, var(--accent)); }
:root[data-theme="light"] .brand-mark { background: linear-gradient(135deg, var(--brand), var(--s1)); }
:root[data-theme="light"] .side-user { background: linear-gradient(135deg, var(--brand-deep), var(--brand) 55%, var(--s1)); border-bottom-color: transparent; color: #fff; }
:root[data-theme="light"] .side-user-text small { color: rgba(255, 255, 255, .82); }
:root[data-theme="light"] .side-account { color: #ffd9a6; }
:root[data-theme="light"] .role-pill { background: var(--accent); border-color: var(--accent); color: #1a1205; }
:root[data-theme="light"] .avatar { box-shadow: 0 0 0 3px rgba(255, 255, 255, .55); }
:root[data-theme="light"] .side-nav a svg { color: var(--brand); }
:root[data-theme="light"] .side-nav a:hover { background: var(--info-bg); }
:root[data-theme="light"] .side-nav a.active { background: color-mix(in srgb, var(--accent) 24%, transparent); }
:root[data-theme="light"] .side-nav a.active svg { color: var(--accent); }
:root[data-theme="light"] .page-head h1 { color: var(--brand-deep); }
:root[data-theme="light"] .card h2 { color: var(--brand-deep); }
:root[data-theme="light"] th { background: #d6e3f8; color: var(--brand-deep); }
:root[data-theme="light"] tbody tr:nth-child(even) td { background: #f6f9fe; }
:root[data-theme="light"] tbody tr:hover td { background: #e9f0fc; }
:root[data-theme="light"] .btn { border-color: color-mix(in srgb, var(--brand) 32%, var(--border)); color: var(--brand-deep); }
:root[data-theme="light"] .btn:hover { background: var(--info-bg); border-color: var(--brand); }
:root[data-theme="light"] .btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #fff), var(--brand)); color: var(--brand-ink, #fff); }
:root[data-theme="light"] .btn.accent { color: #1a1205; }
:root[data-theme="light"] .btn.danger { color: #fff; }
:root[data-theme="light"] .kpi-grid > .kpi { border-top: 4px solid var(--s1); }
:root[data-theme="light"] .kpi-grid > .kpi:nth-child(4n+2) { border-top-color: var(--s2); }
:root[data-theme="light"] .kpi-grid > .kpi:nth-child(4n+3) { border-top-color: var(--ok); }
:root[data-theme="light"] .kpi-grid > .kpi:nth-child(4n+4) { border-top-color: var(--accent); }
:root[data-theme="light"] .card.stat { border-left: 4px solid var(--s1); }
:root[data-theme="light"] .grid > .card.stat:nth-child(3n+2) { border-left-color: var(--s2); }
:root[data-theme="light"] .grid > .card.stat:nth-child(3n+3) { border-left-color: var(--ok); }
:root[data-theme="light"] .pm-avail { background: var(--info-bg); color: var(--brand-deep); }
:root[data-theme="light"] .mail-tabs, :root[data-theme="light"] .filter-bar { border-top: 3px solid var(--s1); }
:root[data-theme="light"] input:focus, :root[data-theme="light"] select:focus, :root[data-theme="light"] textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); outline: none; }
:root[data-theme="light"] .tabbar { border-top: 3px solid var(--brand); }

/* ---------- licence (demo limit) ---------- */
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; margin-bottom: 16px; border-radius: 12px; background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--text); }
.demo-banner.full { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.demo-banner .btn { margin-left: auto; }
.demo-tag { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: var(--warn); color: #fff; }
.demo-banner.full .demo-tag { background: var(--bad); }
.license-card.is-demo { border-left: 4px solid var(--warn); }
.license-card.is-licensed { border-left: 4px solid var(--ok); }
.lic-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lic-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 20px; margin: 12px 0 0; }
.lic-facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.lic-facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.lic-form { margin-top: 12px; }
.lic-form textarea, .lic-made textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; word-break: break-all; }
.lic-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.lic-gen { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.lic-gen h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.lic-made { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--ok-bg); }
.lic-made textarea { margin: 6px 0 8px; }

/* ---------- theme colour picker ---------- */
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.preset { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.preset:hover { border-color: var(--brand); }
.preset .pv { display: inline-flex; border-radius: 999px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.preset .pv i { width: 12px; height: 22px; display: block; }
.color-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px 18px; }
.color-row { display: grid; grid-template-columns: 52px 1fr 92px; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.color-row input[type=color] { width: 52px; height: 44px; padding: 2px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.cr-text label { margin: 0; font-weight: 700; }
.cr-text small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.3; }
.cr-text small.cr-warn { color: var(--bad); font-weight: 600; margin-top: 2px; }
.color-row .hex { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: lowercase; padding: 8px; }
@media (max-width: 640px) {
  .color-rows { grid-template-columns: 1fr; }
  .color-row { grid-template-columns: 48px 1fr 84px; gap: 10px; }
  .demo-banner .btn { margin-left: 0; width: 100%; justify-content: center; }
  .lic-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- order approval ---------- */
.alert.warn { background: var(--warn-bg); color: var(--text); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.approval-note { margin: -6px 0 14px; font-size: .88rem; }
.empty-state { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty-state b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }
.approval-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.approval-card { border-left: 4px solid var(--warn); display: flex; flex-direction: column; gap: 8px; }
.ap-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-num { font-weight: 800; font-size: 1.1rem; color: var(--brand); text-decoration: none; }
.ap-when { margin-left: auto; font-size: .82rem; }
.ap-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 2px 0; }
.ap-facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ap-facts dd { margin: 0; font-weight: 600; }
.ap-facts dd.neg { color: var(--bad); }
.ap-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-notes { margin: 0; font-size: .88rem; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.ap-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.ap-actions form { flex: 1 1 auto; }
.ap-actions form .btn { width: 100%; justify-content: center; }
@media (max-width: 640px) {
  .approval-list { grid-template-columns: 1fr; }
  .ap-actions .btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------- Admin: change order status ---------- */
.status-edit { margin-bottom: 16px; border-left: 4px solid var(--brand); }
.status-edit > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; list-style: none; }
.status-edit > summary::-webkit-details-marker { display: none; }
.status-edit > summary::before { content: '▸'; color: var(--brand); transition: transform .15s; }
.status-edit[open] > summary::before { transform: rotate(90deg); }
.status-edit > summary small { font-weight: 500; margin-left: auto; }
@media (max-width: 640px) { .status-edit > summary small { margin-left: 0; width: 100%; } .status-edit .form-row .btn { width: 100%; justify-content: center; } }

/* ---------- popup forms (create / edit over the current page) ---------- */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sec-head h2 { margin: 0; }
dialog.fb-modal { padding: 0; border: 0; border-radius: 16px; width: min(1100px, calc(100vw - 32px)); height: min(92vh, 1000px); max-width: none; max-height: none; background: var(--bg); box-shadow: 0 0 0 1px rgba(10, 20, 40, .18), 0 24px 70px rgba(10, 20, 40, .45); overflow: hidden; }
/* Dark theme: a white glow around the popup so it stands out from the dark page (the light theme keeps the dark shadow). */
:root[data-theme="dark"] dialog.fb-modal { box-shadow: 0 0 0 1px rgba(255, 255, 255, .55), 0 0 36px 4px rgba(255, 255, 255, .28); }
dialog.fb-modal::backdrop { background: rgba(12, 20, 36, .55); backdrop-filter: blur(2px); }
dialog.fb-modal iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
dialog.fb-modal .fb-modal-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; pointer-events: none; }
dialog.fb-modal.loaded .fb-modal-loading { display: none; }
html.modal-open { overflow: hidden; }
@media (max-width: 700px) {
  dialog.fb-modal { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
}
/* inside the popup */
body.in-modal { background: var(--bg); }
body.in-modal main.container { padding-top: 14px; padding-bottom: 14px; max-width: none; }
body.in-modal main.container > .page-head { display: none; }
body.in-modal .page-foot { display: none; }
.modal-bar { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
.modal-bar.bottom { margin: 14px 0 0; }
.modal-bar.top { position: sticky; top: 0; z-index: 5; padding: 10px 0; background: var(--bg); margin-top: -10px; }
.modal-bar .btn { min-width: 110px; justify-content: center; }
body.in-modal form.card { max-width: none !important; }
@media (max-width: 640px) { .modal-bar .btn { flex: 1 1 0; } }
/* fields that failed validation */
.is-invalid, input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--bad) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent) !important; }
.field-error { display: block; color: var(--bad); font-size: .8rem; font-weight: 600; margin-top: 4px; }

/* popup title, top left (the page's own heading) */
.modal-bar.top.has-title { justify-content: flex-end; }
.modal-title { margin-right: auto; min-width: 0; display: flex; flex-direction: column; }
.modal-title h1 { margin: 0; font-size: 1.3rem; line-height: 1.25; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.modal-title .eyebrow { margin-bottom: 0; }
:root[data-theme="light"] .modal-title h1 { color: var(--brand-deep); }
@media (max-width: 640px) {
  .modal-bar.top.has-title .modal-title { flex: 1 1 100%; }
  .modal-title h1 { font-size: 1.1rem; }
}
/* Deliveries: a pulled order waiting for a driver */
.card.delivery-new { border-left: 4px solid var(--warn); }

/* ---------- product list: every column visible, no side scrolling ---------- */
.products-wrap { container-type: inline-size; overflow-x: visible; }
table.products-table { width: 100%; }
table.products-table th { white-space: normal; vertical-align: bottom; }
table.products-table th, table.products-table td { padding: 8px 8px; }
table.products-table td { vertical-align: top; }
table.products-table .thumb { width: 64px; height: 54px; }
table.products-table .thumb-empty { font-size: .68rem; text-align: center; }
table.products-table .c-photo { width: 72px; }
table.products-table .c-sku { width: 12%; overflow-wrap: anywhere; }
table.products-table .c-name { min-width: 160px; }
table.products-table .c-name .desc { font-size: .82rem; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
table.products-table .c-cat { width: 11%; }
table.products-table .c-pack { width: 13%; }
table.products-table .num { white-space: nowrap; }
table.products-table .c-avail .badge { white-space: normal; font-size: .7rem; }
table.products-table .c-act { width: 1%; }
table.products-table .c-act .btn { display: flex; justify-content: center; margin: 0 0 4px; }
table.products-table .sm-text { font-size: .78rem; }
table.products-table tr.inactive { opacity: .6; }

/* Not enough room for the table (side menu, tablet, phone, popup): one labelled card per product. */
@container (max-width: 900px) {
  table.products-table, table.products-table tbody { display: block; }
  table.products-table thead { display: none; }
  table.products-table tbody tr { display: grid; grid-template-columns: 72px repeat(4, minmax(0, 1fr)); gap: 0 14px; padding: 12px 12px 4px; border-bottom: 1px solid var(--border); align-items: start; }
  table.products-table tbody tr:last-child { border-bottom: 0; }
  table.products-table tbody td { display: block; padding: 0 0 8px; border: 0; width: auto; min-width: 0; text-align: left; background: transparent !important; }
  table.products-table tbody td.c-photo, table.products-table tbody td.c-sku, table.products-table tbody td.c-cat, table.products-table tbody td.c-pack, table.products-table tbody td.c-act { width: auto; }
  table.products-table tbody td.c-photo { grid-column: 1; grid-row: 1 / span 12; } /* the photo keeps its own column; every field sits to its right */
  table.products-table tbody td.c-name { grid-column: 2 / -1; grid-row: 1; min-width: 0; }
  table.products-table tbody td.c-act { grid-column: 2 / -1; display: flex; gap: 8px; }
  table.products-table .c-act .btn { margin: 0; flex: 0 0 auto; }
  table.products-table td[data-label]::before { content: attr(data-label); display: block; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  table.products-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--brand) 4%, transparent); }
}
@container (max-width: 560px) {
  table.products-table tbody tr { grid-template-columns: 64px repeat(2, minmax(0, 1fr)); }
  table.products-table tbody td.c-photo { grid-row: 1 / span 12; }
  table.products-table .thumb { width: 56px; height: 48px; }
}

/* product list: Clone button and the copy just made */
table.products-table .clone-form { margin: 0; }
table.products-table .c-act .clone-form .btn { width: 100%; }
table.products-table tr.just-cloned > td, table.products-table tbody tr.just-cloned { background: color-mix(in srgb, var(--accent) 16%, transparent) !important; }
table.products-table tr.just-cloned { opacity: 1; outline: 2px solid var(--accent); outline-offset: -2px; }

/* product list: tick boxes + "Clone selected" above and below the list */
.bulk-bar { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 10px 14px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.bulk-bar.bottom { margin: 10px 0 0; }
.bulk-bar .bulk-all { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; cursor: pointer; }
.bulk-bar input[type=checkbox], table.products-table .c-sel input { width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--brand); }
.bulk-bar .bulk-count { margin-right: auto; font-size: .9rem; }
table.products-table .c-sel { width: 30px; text-align: center; vertical-align: middle; }
table.products-table tbody tr.is-selected { background: color-mix(in srgb, var(--brand) 9%, transparent); }
table.products-table tbody tr.is-selected > td { background: transparent !important; }
@container (max-width: 900px) {
  table.products-table tbody tr { position: relative; }
  table.products-table tbody td.c-sel { position: absolute; top: 8px; left: 8px; z-index: 1; width: auto; padding: 3px; border-radius: 6px; background: var(--surface) !important; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); line-height: 0; }
}
@media (max-width: 640px) { .bulk-bar .btn { width: 100%; justify-content: center; } }
