/* Big Kit Inventory - one stylesheet, built from the client mockups.
   Tokens first; every colour, size and radius below comes from here. */

:root {
  /* Colour scheme: Admin → Branding sets these per site (src/Core/Brand.php). Defaults: Sabon Station */
  --main: #0095da;
  --accent: #fff200;
  --brand: #0095da;            /* the branch's own colour (locations.brand_color): only the dot by the branch name */
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-2: #e7f3fb;        /* read-only fields, totals band */
  --line: #d9e3ea;
  --line-strong: #b9c8d3;
  --ink: #111417;
  --ink-2: #4e606c;
  --ink-3: #7a8a95;
  --primary: #0077b6;          /* deeper Sabon blue: white button text stays readable */
  --primary-ink: #ffffff;
  --primary-hover: #005f92;
  --primary-text: #0077b6;     /* links and highlighted text on white */
  --ok: #1f7a4d;   --ok-bg: #e5f4eb;
  --warn: #9a5b00; --warn-bg: #fdf1dc;
  --bad: #b42318;  --bad-bg: #fdeceb;
  --info: #3b5566; --info-bg: #e8eff4;
  --focus: #0087c7;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(19, 35, 46, .04);
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 var(--font); font-feature-settings: "tnum" 1;
}
a { color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.1; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Top bar ---------- */
.brandband { height: 6px; background: linear-gradient(var(--main) 0 4px, var(--accent) 4px 6px); }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 24px; padding: 0 28px; min-height: 64px; }
.logo { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 19px; text-decoration: none; white-space: nowrap; }
.logo img { height: 44px; width: auto; max-width: 200px; object-fit: contain; flex: none; }
.logo span { color: var(--ink-2); font-weight: 400; }
.logo-text { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.logo-text b { color: var(--ink); font-weight: 600; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 9px 14px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2);
  font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -3px 0 var(--main); }
.nav .count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-family: var(--mono);
}
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 14px; }
.who .branch { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.who .branch i { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.who .role { font-weight: 600; }
.who .branch-code { display: none; }
.menu { position: relative; }
.menu > button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 50%; width: 34px; height: 34px;
  font: 600 13px var(--font); color: var(--ink); cursor: pointer;
}
.menu-pop {
  position: absolute; right: 0; top: 42px; min-width: 240px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(19,35,46,.12); padding: 8px; display: none;
}
.menu.open .menu-pop { display: block; }
.menu-pop a, .menu-pop button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 6px; border: 0;
  background: none; font: 400 14px var(--font); color: var(--ink); text-decoration: none; cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg); }
.menu-pop .label { padding: 8px 10px 4px; font: 500 11px var(--mono); letter-spacing: .12em; color: var(--ink-3); text-transform: uppercase; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- Page ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 40px 28px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.eyebrow { font: 500 12px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }
.page-head p { margin-top: 10px; color: var(--ink-2); font-size: 16px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 20px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.g-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: start; }
@media (max-width: 1080px) { .g-main, .g-split { grid-template-columns: minmax(0, 1fr); } .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) {
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 24px 16px 64px; }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 16px 18px; }
  .kpi .k-val { font-size: 34px; margin-top: 6px; }
  .page-head { margin-bottom: 20px; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 24px 28px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 28px; border-bottom: 1px solid var(--line); }
.card-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 28px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.card + .card { margin-top: 20px; }
.grid > .card + .card, .grid > *, .drums > .card { margin-top: 0; }
.stack > * + * { margin-top: 20px; }

/* KPI tiles */
.kpi { display: block; padding: 22px 26px; text-decoration: none; transition: border-color .15s; }
a.kpi:hover { border-color: var(--line-strong); }
.kpi .k-label { color: var(--ink-2); }
.kpi .k-val { font-size: 48px; line-height: 1.1; margin-top: 12px; font-weight: 500; letter-spacing: -.02em; }
.kpi.alert .k-val { color: var(--bad); }
.kpi .k-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th, .t td { padding: 15px 20px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t th { font-weight: 500; color: var(--ink-2); font-size: 14px; background: var(--surface); white-space: nowrap; }
.t th:first-child, .t td:first-child { padding-left: 28px; }
.t th:last-child, .t td:last-child { padding-right: 28px; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #fafcfd; }
.t td.total, .t th.total { font-weight: 600; }
.t .num, .t th.num { text-align: right; }
.t .code { font: 400 13px var(--mono); color: var(--ink-2); white-space: nowrap; }
.t .sub { display: block; font-size: 12.5px; color: var(--ink-3); }
.t tr.row-link { cursor: pointer; }
.t input.input, .t select.input { height: 42px; }
.t td[data-check] { min-width: 150px; }
.line-check:not(:empty) { margin-top: 6px; }
.t th.wrap { white-space: normal; }
.line-check .chip { white-space: normal; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 999px;
  font: 500 12.5px var(--mono); white-space: nowrap; background: var(--info-bg); color: var(--info);
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-muted { background: #eef2f5; color: var(--ink-2); }

/* ---------- Forms ---------- */
label.lbl, .lbl { display: block; font-weight: 500; margin-bottom: 8px; }
.field + .field { margin-top: 18px; }
.help { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.input {
  width: 100%; height: 48px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); font: 400 15px var(--font); color: var(--ink);
}
textarea.input { height: auto; min-height: 92px; padding: 12px 16px; resize: vertical; }
select.input { appearance: none; padding-right: 40px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2313232e' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 16px center; }
.input:focus { outline: 3px solid rgba(0,149,218,.25); border-color: var(--focus); }
.input[readonly], .input.ro { background: var(--surface-2); border-color: var(--surface-2); }
.input.bad { border-color: var(--bad); outline: 2px solid rgba(180,35,24,.12); }
.input.qty { text-align: right; max-width: 150px; font-variant-numeric: tabular-nums; }
.row-fields { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.row-fields.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 760px) { .row-fields, .row-fields.two { grid-template-columns: 1fr; } }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label {
  display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 18px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 16px; background: var(--surface);
}
.seg input { width: 18px; height: 18px; accent-color: var(--focus); margin: 0; }
.seg label:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 22px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 500 15px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn:focus-visible { outline: 3px solid rgba(0,149,218,.35); outline-offset: 2px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); background: var(--bg); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; justify-content: flex-start; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link { color: var(--primary-text); font-weight: 500; text-underline-offset: 3px; }

/* ---------- Status steps (Request status sidebar) ---------- */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 34px 1fr; gap: 4px 6px; padding: 10px 0; }
.steps .n { font: 500 13px var(--mono); color: var(--ink-3); padding-top: 2px; }
.steps .t1 { font-weight: 600; font-size: 16px; }
.steps .t2 { grid-column: 2; color: var(--ink-2); font-size: 14px; }
.steps li.done .n { color: var(--ok); }
.steps li.now .t1 { color: var(--primary-text); }
.steps li.todo .t1 { color: var(--ink-3); }

/* Sign-off cards */
.sig { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.sig + .sig { margin-top: 14px; }
.sig-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sig-who { font-weight: 600; }
.sig-when { color: var(--ink-2); font-size: 14px; margin-top: 6px; }

/* Notes / callouts */
.callout { background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px 20px; display: flex; justify-content: space-between; gap: 12px; }
.note { color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* Flash */
.flash { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-weight: 500; display: flex; gap: 10px; align-items: flex-start; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-bad { background: var(--bad-bg); color: var(--bad); }
.flash-info { background: var(--info-bg); color: var(--info); }

/* Live badge */
.live { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); font: 500 12.5px var(--mono); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }
.live.stale { background: var(--warn-bg); color: var(--warn); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live i { animation: none; } }

/* ---------- Drums ---------- */
.drums { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.drum { padding: 18px 20px; text-decoration: none; display: block; }
.drum.low { border: 2px solid var(--ink); }
.drum.mixing { border-style: dashed; }
.drum-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.drum-code { font: 500 14px var(--mono); }
.drum-name { font-weight: 600; margin: 14px 0 12px; line-height: 1.3; min-height: 2.6em; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar b { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.drum.low .bar b { background: var(--bad); }
.drum-left { margin-top: 10px; color: var(--ink-2); font-size: 14px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.filters .input { height: 42px; width: auto; min-width: 200px; }

/* Empty state */
.empty { padding: 48px 28px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand i { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.auth .card { border-top: 4px solid var(--main); }
.auth-logo { display: block; height: 104px; width: auto; max-width: 100%; object-fit: contain; margin: 2px auto 22px; }
.print-brand { display: flex; align-items: center; gap: 16px; }
.print-brand img { height: 64px; width: auto; max-width: 220px; object-fit: contain; flex: none; }

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .brandband, .no-print, .actions, .flash { display: none !important; }
  .page { padding: 0; max-width: none; }
  .card { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
  .t th, .t td { padding: 6px 8px; }
  .chip { background: none !important; padding: 0; }
}
.printdoc .sigs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 40px; }
.printdoc .sigs div { border-top: 1px solid #333; padding-top: 6px; font-size: 12px; }

/* ---------- Installer ---------- */
.install { max-width: 820px; margin: 0 auto; padding: 48px 24px 96px; }
.install h1 { margin-bottom: 12px; }
.install .lead { color: var(--ink-2); font-size: 16px; margin-bottom: 28px; max-width: 640px; }
.install .card { margin-bottom: 20px; }
.install .card + .card { margin-top: 0; }
.step { display: grid; grid-template-columns: 36px 1fr; gap: 14px; margin-bottom: 20px; }
.step > span {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff;
  display: grid; place-items: center; font: 500 14px var(--mono);
}
.step p { margin-top: 4px; font-size: 14px; }
.choice { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; }
.choice label, .check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; cursor: pointer; }
.choice label { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 14px 16px; }
.choice label:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }
.choice label.is-disabled { opacity: .55; cursor: not-allowed; }
.choice legend { margin-bottom: 4px; }
.choice input, .check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--focus); }
.choice strong, .check strong { display: block; font-weight: 500; }
.choice .muted, .check .muted { display: block; font-size: 14px; margin-top: 2px; }
ol.next { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 10px; }
.install .note .mono { white-space: nowrap; }

/* ---------- Danger, updates, activity ---------- */
.btn-danger { border-color: var(--bad); color: var(--bad); background: var(--surface); }
.btn-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.danger-zone { border-color: #f1c9c4; }
.blocker { border: 1px solid #f1c9c4; background: var(--bad-bg); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 14px; }
.blocker strong { color: var(--bad); }
.blocker p { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
details.files { font-size: 13px; margin-top: 6px; }
details.files summary { cursor: pointer; color: var(--ink-2); }
details.files ul { margin: 6px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; }
details.files li { word-break: break-all; }
ul.notes { margin: 8px 0 0; padding-left: 20px; }
.t.compact td { padding: 10px 12px; vertical-align: top; }
.t.compact td:first-child { padding-left: 0; }
.upload { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.upload .input[type=file] { flex: 1; min-width: 220px; padding: 10px 12px; height: auto; }
ul.backups { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
ul.backups li { display: grid; gap: 2px; word-break: break-all; }

/* =====================================================================
   Phones and tablets. Staff do transactions on these, so:
   - the main menu becomes a slide-out drawer (nothing hidden off-screen),
   - tables turn into stacked cards on phones (every input reachable, no sideways scroll),
   - tap targets are at least 44px and inputs 16px (no iOS zoom on focus).
   ===================================================================== */
.nav-toggle, .nav-head, .nav-backdrop { display: none; }
.row-fields.fit-auto { grid-template-columns: minmax(0, 1fr) auto; }
.row-fields.cols-a { grid-template-columns: 2fr 1fr 1.4fr; }
.row-fields.cols-b { grid-template-columns: 1fr 1.4fr 1.4fr 110px; }
.row-fields.cols-2-1 { grid-template-columns: 2fr 1fr; }
.g-drum { grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); align-items: start; }
.menu-pop { max-height: calc(100vh - 90px); overflow-y: auto; }

@media (max-width: 1099px) {
  .topbar-in { gap: 8px; padding: 0 12px 0 8px; min-height: 58px; }
  .nav-toggle {
    display: inline-flex; position: relative; align-items: center; justify-content: center; flex: none;
    width: 46px; height: 46px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); cursor: pointer;
  }
  .nav-toggle:focus-visible { outline: 3px solid rgba(0,149,218,.35); }
  .burger { display: grid; gap: 4px; }
  .burger i { display: block; width: 20px; height: 2px; border-radius: 1px; background: currentColor; }
  .nav-toggle .count {
    position: absolute; top: 5px; right: 3px; min-width: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--bad); color: #fff; font: 500 11px/18px var(--mono); text-align: center;
  }
  .logo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 17px; }

  .nav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(330px, 86vw);
    flex-direction: column; gap: 2px; padding: 0 12px calc(24px + env(safe-area-inset-bottom));
    background: var(--surface); overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-104%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
    box-shadow: 0 0 40px rgba(19,35,46,.22);
  }
  body.nav-open .nav { transform: none; visibility: visible; transition: transform .22s ease; }
  .nav a { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 0 14px; font-size: 17px; }
  .nav a.on { box-shadow: inset 4px 0 0 var(--main); }
  .nav-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
    position: sticky; top: 0; z-index: 1; background: var(--surface);
    padding: calc(18px + env(safe-area-inset-top)) 6px 14px 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
  }
  .nav-branch { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; }
  .nav-branch i { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); flex: none; }
  .nav-role { display: block; color: var(--ink-2); font-size: 14px; margin-top: 4px; }
  .nav-close { flex: none; width: 44px; height: 44px; margin: -8px -4px 0 0; border: 0; border-radius: var(--radius-sm); background: none; font-size: 28px; line-height: 1; color: var(--ink-2); cursor: pointer; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(19,35,46,.42); }
  body.nav-open .nav-backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  .who { gap: 8px; }
  .who .sep, .who .role { display: none; }
  .who .branch-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
  .menu > button { width: 42px; height: 42px; }
  .menu-pop { position: fixed; top: 62px; right: 10px; left: auto; min-width: 260px; max-width: calc(100vw - 20px); }
  .menu-pop a, .menu-pop button { padding: 12px 12px; font-size: 16px; }

  .input, .btn, select.input, textarea.input { font-size: 16px; }
  .page { padding-top: 28px; }
}
@media (prefers-reduced-motion: reduce) { .nav { transition: none !important; } }

@media (pointer: coarse) {
  .btn-sm { height: 44px; padding: 0 16px; }
  .t input.input, .t select.input { height: 46px; }
  .filters .input { height: 46px; }
  .seg label { min-height: 48px; }
  .check input, .choice input { width: 22px; height: 22px; margin-top: 0; }
}

@media (max-width: 760px) {
  .row-fields.fit-auto, .row-fields.cols-a, .row-fields.cols-b, .row-fields.cols-2-1 { grid-template-columns: minmax(0, 1fr); }
  .g-drum { grid-template-columns: minmax(0, 1fr); }
  .seg label { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 640px) {
  .who .branch-name { display: none; }
  .who .branch-code { display: inline; font-size: 13px; }
  .logo span { display: none; }
  .card-pad { padding: 20px 16px; }
  .card-head { padding: 16px; flex-wrap: wrap; row-gap: 4px; }
  .card-foot { padding: 14px 16px; }
  .card-head h2 { font-size: 18px; }
  .page-head { gap: 14px; }
  .page-head > .actions { width: 100%; }
  /* Buttons that finish a task fill the width, side by side when there are two */
  .actions > .btn, .actions > form, .card-foot > .btn, .card-foot > form { flex: 1 1 auto; }
  .actions > form .btn, .card-foot > form .btn { width: 100%; }
  .actions > .chip { flex: none; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr); }
  .filters .input, .filters .btn { width: 100%; min-width: 0 !important; }
  .flash { margin-bottom: 16px; }
  .drums { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .drum-name { min-height: 0; }
  .kpi .k-label { font-size: 14px; }
  .sig { padding: 14px 16px; }
  .callout { flex-direction: column; }
}

/* Tables as stacked cards on phones. Labels come from the header (app.js adds data-label). */
@media screen and (max-width: 700px) {
  .table-wrap:has(> table.t:not(.no-stack)) { overflow: visible; }
  table.t:not(.no-stack), table.t:not(.no-stack) > tbody, table.t:not(.no-stack) > tfoot { display: block; width: 100%; }
  table.t:not(.no-stack) > thead { display: none; }
  table.t:not(.no-stack) tr { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  table.t:not(.no-stack) > tbody > tr:last-child { border-bottom: 0; }
  table.t:not(.no-stack) > tfoot > tr { background: var(--surface-2); }
  table.t:not(.no-stack) tr.row-link:active { background: var(--bg); }
  table.t:not(.no-stack) td {
    display: flow-root; padding: 5px 0; border: 0; text-align: right; white-space: normal; min-width: 0 !important; width: auto !important;
  }
  table.t:not(.no-stack) td::before {
    content: attr(data-label); float: left; max-width: 48%; margin-right: 14px; text-align: left;
    color: var(--ink-2); font-size: 14px; font-weight: 400; font-family: var(--font); line-height: 1.6;
  }
  table.t:not(.no-stack) td:empty { display: none; }
  table.t:not(.no-stack) td[data-label=""]::before, table.t:not(.no-stack) td:first-child::before { content: none; }
  table.t:not(.no-stack) td[data-label=""], table.t:not(.no-stack) td:first-child { text-align: left; }
  table.t:not(.no-stack) td:first-child { padding-top: 0; padding-bottom: 8px; font-weight: 500; font-size: 16px; }
  table.t:not(.no-stack) td:first-child .sub { font-weight: 400; }
  table.t:not(.no-stack) td.code { font-size: 13px; }
  table.t:not(.no-stack) td .sub { display: block; }
  /* Fields that need the width (item search, room, remarks, notes) sit under their label */
  table.t:not(.no-stack) td:has(.input:not(.qty)), table.t:not(.no-stack) td:has(textarea) { text-align: left; }
  table.t:not(.no-stack) td:has(.input:not(.qty))::before, table.t:not(.no-stack) td:has(textarea)::before { float: none; display: block; max-width: none; margin: 4px 0 6px; }
  table.t:not(.no-stack) td .input { width: 100%; min-width: 0 !important; max-width: none !important; }
  table.t:not(.no-stack) td .input.qty { width: 140px; max-width: 46% !important; }
  table.t:not(.no-stack) td:has(> .input.qty)::before { line-height: 46px; }
  table.t:not(.no-stack) td form { text-align: left; }
  table.t:not(.no-stack) td[data-label=""] .btn { margin-top: 6px; }
  table.t:not(.no-stack) td[data-check]:not(:has(*)) { display: none; }
  .t.compact td:first-child { padding-left: 0; }
  /* "Needs your action": number and status on top, what to do underneath */
  table.t.inbox tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "code chip" "text open"; gap: 6px 12px; align-items: center; }
  table.t.inbox td { padding: 0; font-size: 15px; font-weight: 400; }
  table.t.inbox td:nth-child(1) { grid-area: code; font-size: 13px; }
  table.t.inbox td:nth-child(2) { grid-area: text; font-weight: 500; }
  table.t.inbox td:nth-child(3) { grid-area: chip; text-align: right; }
  table.t.inbox td:nth-child(4) { grid-area: open; text-align: right; }
  /* Products: two lines per product — name and price, then code · kind · size */
  table.t.plist thead { display: none; }
  table.t.plist, table.t.plist tbody { display: block; }
  table.t.plist tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "name name name price" "code kind size size"; gap: 4px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.t.plist td { padding: 0; border: 0; font-size: 13px; color: var(--ink-2); }
  table.t.plist td:nth-child(1) { grid-area: name; font-size: 15px; font-weight: 500; color: var(--ink); }
  table.t.plist td:nth-child(2) { grid-area: code; }
  table.t.plist td:nth-child(3) { grid-area: kind; }
  table.t.plist td:nth-child(4) { grid-area: size; }
  table.t.plist td:nth-child(5) { grid-area: price; font-size: 15px; color: var(--ink); text-align: right; }
  table.t.plist td .sub { display: block; }
  table.t.plist td:nth-child(3) .sub { display: none; }
  table.t.plist td.edit { display: none; }
}
@media (hover: none) { .t tbody tr:hover td { background: none; } }
@media (min-width: 701px) and (max-width: 1099px) {
  .t th, .t td { padding: 13px 12px; }
  .t th:first-child, .t td:first-child { padding-left: 20px; }
  .t th:last-child, .t td:last-child { padding-right: 20px; }
  .card-pad { padding: 22px 22px; }
  .card-head { padding: 18px 20px; }
}
@media (min-width: 701px) and (max-width: 1099px) {
  .t th.opt, .t td.opt { display: none; }
  /* Item entry tables (receiving): one card per line, item on top, fields side by side */
  .table-wrap:has(> table.t.entry) { overflow: visible; }
  table.t.entry, table.t.entry > tbody { display: block; width: 100%; }
  table.t.entry > thead { display: none; }
  table.t.entry tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
  table.t.entry td { display: block; padding: 0 !important; border: 0; text-align: left; }
  table.t.entry td::before { content: attr(data-label); display: block; margin-bottom: 6px; font-size: 13.5px; color: var(--ink-2); }
  table.t.entry td:first-child { grid-column: 1 / -1; font-weight: 500; }
  table.t.entry td:first-child::before, table.t.entry td[data-label=""]::before { content: none; }
  table.t.entry td:empty { display: none; }
  table.t.entry td[data-check] { grid-column: 1 / -1; }
  table.t.entry td .input { width: 100%; min-width: 0 !important; max-width: none !important; }
  table.t.entry td.num { text-align: left; line-height: 46px; }
}
.menu-pop .menu-role { padding: 0 10px 8px; font-size: 13px; color: var(--ink-2); }
/* Laptops: keep every menu item visible (role is in the avatar menu) */
@media (min-width: 1100px) and (max-width: 1499px) {
  .topbar-in { gap: 16px; padding: 0 20px; }
  .nav a { padding: 9px 11px; }
  .who .sep, .who .role { display: none; }
}
@media (min-width: 1100px) {
  /* Never hide a menu item: wrap to a second row when there are many (Admin inside a branch) */
  .nav { flex-wrap: wrap; overflow: visible; row-gap: 2px; padding: 8px 0; }
}

/* ---------- Opening count ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 12px 16px; text-decoration: none; color: var(--ink-2); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--main); }
.savebar {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -6px 18px rgba(19,35,46,.08);
}
@media (max-width: 640px) { .savebar { margin: 16px -16px 0; border-radius: 0; border-width: 1px 0 0; } .savebar .btn { flex: 1 1 auto; } }
.callout-start { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; border-color: var(--main); }

/* ---------- Selling ---------- */
.sale-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sale-total strong { font-size: 32px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.seg-wrap { border: 0; margin: 0; padding: 0; }
.sale-pay .seg label { height: 44px; padding: 0 14px; font-size: 15px; }
.sale-pay { position: sticky; top: 84px; }
@media (max-width: 1080px) { .sale-pay { position: static; } }
ul.progress-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
ul.progress-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
ul.progress-list .sub { display: block; font-size: 12.5px; color: var(--ink-3); }
.hint-ok { color: var(--ok); } .hint-warn { color: var(--warn); } .hint-bad { color: var(--bad); }
.sigpad { position: relative; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: #fff; height: 200px; touch-action: none; }
.sigpad canvas { width: 100%; height: 100%; display: block; border-radius: var(--radius-sm); }
.sigpad .sigpad-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); pointer-events: none; }
.sigpad.signed .sigpad-hint { display: none; }
.source-opt { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.source-opt + .source-opt { margin-top: 8px; }
.source-opt:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }
.source-opt.no { opacity: .55; }
.source-opt input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--focus); }
.queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.queue-card { display: block; padding: 18px 20px; text-decoration: none; }
.queue-card.alert { border: 2px solid var(--bad); }
.queue-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.queue-name { font-weight: 600; font-size: 18px; margin: 8px 0 10px; }
ul.queue-lines { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
ul.queue-lines li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.queue-foot { margin-top: 10px; }
.nowrap { white-space: nowrap; }
.prep-line { padding: 16px 28px; border-bottom: 1px solid var(--line); }
.prep-what { margin-bottom: 10px; }
.prep-what .sub { display: block; font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 640px) { .queue { grid-template-columns: minmax(0, 1fr); } .prep-line { padding: 14px 16px; } }
.sale-sums { display: grid; gap: 4px; font-size: 14px; }
.sale-sums:empty { display: none; }
.sale-sums div { display: flex; justify-content: space-between; gap: 10px; }
.sale-sums .disc { color: var(--ok); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pager .btn + .btn { margin-left: 6px; }

/* Search-as-you-type dropdown (sale screen: customer and product boxes) */
.combo-list {
  position: absolute; z-index: 60; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(19, 35, 46, .16); padding: 4px 0;
}
.combo-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; min-height: 48px; cursor: pointer; }
.combo-opt + .combo-opt { border-top: 1px solid var(--line); }
.combo-opt.on, .combo-opt:hover { background: var(--surface-2); }
.combo-main { min-width: 0; display: flex; flex-direction: column; }
.combo-main strong { font-weight: 500; overflow-wrap: anywhere; }
.combo-main .sub { color: var(--ink-3); font-size: 13px; }
.combo-main .code { font-family: var(--mono); font-size: 12px; }
.combo-price { text-align: right; white-space: nowrap; font-weight: 500; }
.combo-price .sub { display: block; font-size: 12px; font-weight: 400; color: var(--ink-3); }
.combo-title { padding: 8px 14px 6px; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.combo-new strong { color: var(--primary-text); }
.combo-list mark { background: #fff7a3; color: inherit; border-radius: 2px; padding: 0 1px; }
.combo-list .chip { flex: none; }

/* Admin → Branding */
.brand-logo-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.brand-logo-box { width: 160px; height: 120px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: repeating-conic-gradient(#f1f4f6 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.brand-logo-box img { max-width: 140px; max-height: 100px; object-fit: contain; }
.brand-schemes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.brand-schemes label { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.brand-schemes label input { margin: 0; flex: none; }
.brand-schemes .swatches { display: flex; flex: none; }
.brand-schemes .swatch + .swatch { margin-left: -6px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); flex: none; }
.swatch-any { background: conic-gradient(#e53e3e, #f6e05e, #38a169, #3182ce, #805ad5, #e53e3e); }
.input-color { height: 46px; padding: 4px; cursor: pointer; }
.brand-preview { position: sticky; top: 88px; align-self: start; overflow: hidden; }
.brand-preview-band { height: 6px; background: linear-gradient(var(--main) 0 4px, var(--accent) 4px 6px); }
.brand-preview-bar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); min-height: 68px; }
.brand-preview-bar img { height: 44px; width: auto; max-width: 180px; object-fit: contain; }
.brand-preview-text { font-weight: 600; font-size: 17px; }
.brand-preview-tabs { margin: 0; }
.brand-preview-tabs a { padding: 8px 12px; cursor: default; }
.brand-preview-tint { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
@media (max-width: 1099px) { .brand-preview { position: static; } }

/* Notification bell (top bar, beside the branch) */
.bell { position: relative; }
.bell-btn { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer; }
.bell-btn:hover { background: var(--bg); }
.bell-btn:focus-visible { outline: 3px solid rgba(0,149,218,.35); outline-offset: 2px; }
.bell-count { position: absolute; top: -5px; right: -6px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font: 500 11px/18px var(--mono); text-align: center; border: 2px solid var(--surface); }
.bell.ring .bell-btn svg { animation: bell-ring .9s ease-in-out 1; transform-origin: 50% 10%; }
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 40% { transform: rotate(-12deg); } 60% { transform: rotate(8deg); } 80% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .bell.ring .bell-btn svg { animation: none; } }
.bell-pop { white-space: normal; text-align: left; position: absolute; right: -60px; top: 46px; width: min(380px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(19,35,46,.16); display: none; z-index: 50; overflow: hidden; }
.bell.open .bell-pop { display: block; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.bell-readall { border: 0; background: none; color: var(--primary-text); font: 500 13px var(--font); cursor: pointer; padding: 4px 0; }
.bell-list { max-height: min(420px, 60vh); overflow-y: auto; overscroll-behavior: contain; }
.bell-empty { padding: 28px 16px; text-align: center; color: var(--ink-2); font-size: 14px; }
.bell-item { display: block; padding: 12px 16px 12px 28px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink-2); position: relative; font-size: 13.5px; line-height: 1.4; }
.bell-item:hover { background: var(--bg); }
.bell-item strong { display: block; color: var(--ink); font-weight: 500; font-size: 14px; margin-bottom: 2px; }
.bell-item span { display: block; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bell-item small { display: block; margin-top: 4px; color: var(--ink-3); font-size: 12px; }
.bell-item.unread { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.bell-item.unread strong { font-weight: 600; }
.bell-item.unread::before { content: ""; position: absolute; left: 12px; top: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--main); }
.bell-foot { display: block; text-align: center; padding: 11px; font-size: 13.5px; font-weight: 500; color: var(--primary-text); text-decoration: none; }
.bell-foot:hover { background: var(--bg); }
.notif-list .bell-item:last-child { border-bottom: 0; }
.notif-list .bell-item span { -webkit-line-clamp: unset; }
@media (max-width: 640px) {
  .bell-btn { width: 36px; height: 36px; }
  .bell-pop { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}
/* New-notice toast */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 80; max-width: min(380px, calc(100vw - 32px)); background: var(--ink); color: #fff; border-radius: var(--radius); padding: 12px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); text-decoration: none; display: block; font-size: 14px; animation: toast-in .2s ease-out; }
.toast strong { display: block; font-weight: 600; margin-bottom: 2px; }
.toast span { opacity: .85; font-size: 13px; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Show / hide password */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 52px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 40px; display: grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: var(--radius-sm); }
.pw-eye:hover { color: var(--ink); background: var(--bg); }
.pw-eye:focus-visible { outline: 3px solid rgba(0,149,218,.35); }

/* Admin → Email → Messages */
.msg-group { margin: 26px 0 12px; font-size: 16px; color: var(--ink-2); }
.msg summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; cursor: pointer; list-style: none; }
.msg summary::-webkit-details-marker { display: none; }
.msg summary > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg summary::after { content: "▸"; color: var(--ink-3); margin-left: auto; }
.msg[open] summary::after { content: "▾"; }
.msg[open] summary { border-bottom: 1px solid var(--line); }
.msg-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 24px; padding: 20px; }
.fillins { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); align-items: baseline; }
.fillin code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--ink); }
.msg-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.msg-mail { margin-top: 6px; background: #f4f2ee; border-radius: var(--radius-sm); padding: 12px; }
.msg-subject { font-size: 13px; margin-bottom: 8px; overflow-wrap: anywhere; }
.msg-card { background: #fff; border-radius: 8px; border-top: 4px solid var(--main); padding: 16px; font-family: Arial, Helvetica, sans-serif; color: #1d1d1b; font-size: 14px; line-height: 1.5; }
.msg-card p { margin: 8px 0 0; }
.msg-h { display: block; font-size: 17px; line-height: 1.3; }
.msg-btn { display: inline-block; margin-top: 14px; background: var(--primary); color: var(--primary-ink); font-weight: bold; padding: 9px 16px; border-radius: 8px; font-size: 14px; }
@media (max-width: 900px) { .msg-body { grid-template-columns: 1fr; padding: 16px; } }
