/* Buffalo POS — touch-first styles for tablet, phone and desktop */
:root {
  --bg: #f2f6f9;
  --surface: #ffffff;
  --surface-2: #e8f1f7;
  --text: #13222e;
  --muted: #5b6d7b;
  --border: #d3dee6;
  --brand: #0b5f8a;
  --brand-2: #0e7ab0;
  --brand-ink: #ffffff;
  --accent: #36b3e0;
  --success: #1e7a4c;
  --success-bg: #e3f4ea;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
  --info-bg: #e6f2fa;
  --warn-bg: #fff4dc;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 42, 60, .06), 0 4px 14px rgba(16, 42, 60, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1820;
    --surface: #14232e;
    --surface-2: #1a2e3b;
    --text: #e4eef5;
    --muted: #93a8b7;
    --border: #274050;
    --brand: #3aa6dc;
    --brand-2: #58b8e6;
    --brand-ink: #06202e;
    --success: #6fd49f;
    --success-bg: #173327;
    --danger: #ff8a80;
    --danger-bg: #3a1d1b;
    --info-bg: #16303f;
    --warn-bg: #3a3017;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 var(--font);
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
@media (prefers-color-scheme: dark) { .topbar { background: #0a3a55; } }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.18); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { font-size: .95rem; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.45); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }
.role-chip { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.2); margin-left: 4px; white-space: nowrap; }
@media (max-width: 520px) { .who .role-chip { display: none; } }

.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }

/* ── Flash ── */
.flash { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--info-bg); }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .input:focus-visible, .tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-lg { min-height: 54px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Forms ── */
.form { display: grid; gap: 14px; }
.form label { display: grid; align-content: start; gap: 6px; font-weight: 600; font-size: .95rem; }
.form .help { font-weight: 400; color: var(--muted); font-size: .85rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea.input { min-height: 90px; resize: vertical; }
.input-xl { min-height: 60px; font-size: 1.4rem; text-align: center; letter-spacing: .08em; }
.check { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid .span-all { grid-column: 1 / -1; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.narrow { max-width: 480px; margin: 40px auto; }
.card h2 { margin-bottom: 12px; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.back { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-size: 1.3rem; color: var(--text); }
.page-head .spacer { flex: 1; }

/* ── Home tiles ── */
.home-head { margin-bottom: 18px; }
.home-head h1 { margin-bottom: 2px; }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
@media (max-width: 440px) { .tiles { grid-template-columns: 1fr 1fr; gap: 10px; } }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  min-height: 140px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; transition: transform .08s ease, border-color .15s;
}
a.tile:hover { border-color: var(--brand); }
a.tile:active { transform: scale(.98); }
.tile-icon { font-size: 2rem; line-height: 1; margin-bottom: 8px; }
.tile-title { font-weight: 700; font-size: 1.08rem; }
.tile-sub { color: var(--muted); font-size: .88rem; }
.tile-soon { opacity: .55; }
.soon-badge { position: absolute; top: 12px; right: 12px; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }

/* ── Login ── */
body.bare { background: linear-gradient(160deg, #0b5f8a 0%, #36b3e0 100%); min-height: 100vh; }
@media (prefers-color-scheme: dark) { body.bare { background: linear-gradient(160deg, #071d2a 0%, #0b4a6b 100%); } }
body.bare .wrap { padding-top: 0; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.2); text-align: center; }
.login-card.wide { max-width: 460px; text-align: left; }
.login-card.wide h1, .login-card.wide .login-logo { text-align: center; margin-left: auto; margin-right: auto; }
.login-card form { display: grid; gap: 12px; margin-top: 16px; }
.login-logo { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; background: var(--surface-2); font-size: 2rem; color: var(--brand); }

/* ── Tables / lists ── */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.list tr.inactive td { opacity: .55; }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); }
.pill-manager { background: #dcecf7; color: #0b5f8a; }
.pill-cashier { background: var(--success-bg); color: var(--success); }
.pill-viewer { background: var(--warn-bg); color: #7a5a00; }
.pill-off { background: var(--danger-bg); color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .pill-manager { background: #16354a; color: #8fd0f2; }
  .pill-viewer { color: #f0cf7a; }
}

/* Users as cards on narrow screens */
.user-cards { display: grid; gap: 12px; }
.user-card { display: grid; gap: 10px; }
.user-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.user-card-top h3 { margin: 0; font-size: 1.05rem; }
.user-meta { font-size: .85rem; color: var(--muted); }
.edit-panel { border-top: 1px dashed var(--border); padding-top: 12px; }

/* ── Modal ── */
.modal-bg { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8, 20, 30, .55); }
.modal-bg[hidden] { display: none; }
.modal { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }

/* ── Shared bits ── */
[hidden] { display: none !important; }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.low, .neg { color: var(--danger); }
.is-pos { color: var(--success); }
.pill-warn { background: var(--warn-bg); color: #7a5a00; margin-left: 4px; }
@media (prefers-color-scheme: dark) { .pill-warn { color: #f0cf7a; } }
.label-like { font-weight: 600; font-size: .85rem; color: var(--muted); }
.big-num { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mid-num { font-size: 1.3rem; font-weight: 700; }
.input-lg { min-height: 54px; font-size: 1.25rem; }
.empty { text-align: center; padding: 32px 18px; }
.empty p { max-width: 460px; margin: 8px auto 16px; }
.danger-zone { display: flex; justify-content: flex-end; background: transparent; box-shadow: none; border-style: dashed; }

/* ── Filters + segmented control ── */
.filters { display: grid; gap: 10px; grid-template-columns: 1fr 220px; align-items: center; }
.filters .seg { grid-column: 1 / -1; }
@media (max-width: 600px) { .filters { grid-template-columns: 1fr; } }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 99px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer;
}
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; }
.seg-btn.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.seg-btn.warn:not(.on) { border-color: #e0b44a; }

/* ── Product list ── */
.plist { padding: 6px 18px; }
.pcat { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 16px 0 6px; }
.prow {
  display: grid; grid-template-columns: minmax(0, 1fr) 100px 100px 72px 150px 150px;
  gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.prow:last-child { border-bottom: 0; }
.prow-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 12px; }
.prow.inactive { opacity: .55; }
.pname { display: grid; gap: 2px; min-width: 0; }
.pname a { color: var(--text); font-weight: 700; text-decoration: none; }
.pname a:hover { color: var(--brand); }
.pactions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 720px) {
  .prow-head { display: none; }
  .prow { grid-template-columns: 1fr auto; row-gap: 4px; }
  .prow .pname { grid-column: 1 / -1; }
  .prow > [data-label] { display: flex; justify-content: space-between; gap: 8px; text-align: left; font-size: .92rem; }
  .prow > [data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; }
  .prow > [data-label] { grid-column: 1 / -1; }
  .pactions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 4px; }
}

/* ── Stock ── */
.stock-summary { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.stock-summary .btn { margin-left: auto; }
.stock-form { margin-top: 14px; }
.bulk-list { padding-top: 4px; }
.bulk-row { display: grid !important; grid-template-columns: 1fr 120px; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-weight: 400 !important; }
.bulk-row:last-child { border-bottom: 0; }
.bulk-qty { text-align: right; font-size: 1.15rem; }

/* Page head wraps on phones: buttons drop to their own row */
.page-head { flex-wrap: wrap; }
.back { flex-shrink: 0; }
@media (max-width: 560px) {
  .page-head .spacer { flex-basis: 100%; height: 0; }
  .page-head > .btn { flex: 1; }
}
.list th.num, .list td.num { text-align: right; }

/* ═════════ New sale (POS) ═════════ */
body.modal-open { overflow: hidden; }
.modal-wide { max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }

.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.wrap:has(.pos) { max-width: 1400px; padding-bottom: 16px; }
.pos-search { display: flex; gap: 10px; margin-bottom: 12px; }
.pos-search .input { min-height: 50px; font-size: 1.05rem; }
.pos-cats { margin-bottom: 12px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.pos-cats .seg-btn { flex-shrink: 0; }

.pgrid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pbtn {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  min-height: 104px; padding: 14px; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); font: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.pbtn:hover { border-color: var(--brand); }
.pbtn:active { transform: scale(.97); }
.pbtn.bump { animation: bump .25s ease; }
@keyframes bump { 50% { transform: scale(.94); background: var(--surface-2); } }
.pbtn-name { font-weight: 700; line-height: 1.25; }
.pbtn-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.pbtn-foot strong { color: var(--brand); font-size: 1.05rem; }
.pstock { font-size: .75rem; color: var(--muted); }
.pstock.out { color: var(--danger); font-weight: 700; }
.pbadge { position: absolute; top: -7px; right: -7px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 99px; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: .85rem; display: grid; place-items: center; }

.pos-cart {
  position: sticky; top: 72px; display: flex; flex-direction: column;
  max-height: calc(100vh - 88px); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.cart-head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.cart-close { display: none; align-self: flex-start; }
.cust-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; text-align: left; cursor: pointer; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; }
.cust-icon { font-size: 1.4rem; }
.cart-lines { flex: 1; overflow-y: auto; padding: 4px 12px; min-height: 120px; }
.cart-empty { padding: 30px 0; text-align: center; }
.line { padding: 10px 0; border-bottom: 1px solid var(--border); }
.line:last-child { border-bottom: 0; }
.line-top { display: flex; justify-content: space-between; gap: 8px; }
.line-name { font-weight: 600; }
.line-total { font-variant-numeric: tabular-nums; }
.line-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.line-price { width: 110px; min-height: 38px; padding: 6px 8px; text-align: right; }
.override { color: #7a5a00; margin-top: 4px; }
@media (prefers-color-scheme: dark) { .override { color: #f0cf7a; } }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; }
.stepper { display: flex; align-items: center; gap: 4px; }
.step { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.2rem; cursor: pointer; touch-action: manipulation; }
.step:active { background: var(--surface-2); }
.step-qty { width: 64px; min-height: 40px; padding: 6px; text-align: center; font-weight: 700; }
.cart-foot { padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.tot-row { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.tot-big { font-size: 1.35rem; font-weight: 800; padding: 6px 0 10px; }
.cart-actions { display: grid; grid-template-columns: auto 1fr; }

.cart-bar {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 20;
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 60px; padding: 0 18px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-size: 1.05rem; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.cart-bar-go { font-weight: 700; }

@media (max-width: 899px) {
  .pos { grid-template-columns: 1fr; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding-bottom: 90px; }
  .cart-bar:not([hidden]) { display: flex; }
  .pos-cart { position: fixed; inset: 0; top: 0; z-index: 30; max-height: none; border-radius: 0; border: 0; transform: translateY(100%); transition: transform .2s ease; visibility: hidden; }
  .pos-cart.open { transform: none; visibility: visible; }
  .cart-close { display: inline-flex; }
  .cart-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) { .pgrid { grid-template-columns: 1fr 1fr; gap: 8px; } .pbtn { min-height: 96px; padding: 12px; } }

/* Customer picker */
.cust-list { display: grid; gap: 6px; margin-top: 10px; max-height: 40vh; overflow-y: auto; }
.cust-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; text-align: left; cursor: pointer; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.cust-item:hover { border-color: var(--brand); }
.cust-new { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }

/* Payment */
.due { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.due strong { font-size: 2rem; font-variant-numeric: tabular-nums; }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pay-methods.dim { opacity: .45; pointer-events: none; }
.pay-m { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; font-size: 1.5rem; cursor: pointer; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-family: inherit; touch-action: manipulation; }
.pay-m[hidden] { display: none; }
.pay-m span { font-size: .9rem; font-weight: 700; }
.pay-m.on { border-color: var(--brand); background: var(--info-bg); }
.pay-m:disabled { opacity: .35; cursor: not-allowed; }
@media (max-width: 420px) { .pay-methods { grid-template-columns: 1fr 1fr; } }
.split-toggle { margin: 12px 0 4px; font-weight: 600; }
.split-rows { display: grid; gap: 8px; margin: 8px 0; }
.split-row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; font-weight: 600; }
.split-row .input { text-align: right; }
.cash-box { margin: 14px 0 6px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); display: grid; gap: 10px; }
.cash-box label { display: grid; gap: 6px; font-weight: 600; }
.cash-box .input { text-align: right; }
.quick-cash { display: flex; flex-wrap: wrap; gap: 6px; }
.change-row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.change-row strong { font-size: 1.6rem; }
.acct-note { margin: 8px 0; }
#pay-err { margin: 12px 0 0; }
#complete-btn { margin-top: 14px; }

/* Done */
.done { text-align: center; }
.done-tick { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; font-weight: 800; background: var(--success-bg); color: var(--success); }
.change-big { margin: 12px 0; padding: 14px; border-radius: var(--radius); background: var(--warn-bg); display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.change-big strong { font-size: 2rem; }
.done-actions { display: grid; gap: 10px; margin-top: 16px; }
.wa-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.btn-wa { background: #1faa53; border-color: #1faa53; color: #fff; }
.btn-wa:hover { background: #1b9649; }
.input.bad { border-color: var(--danger); outline: 2px solid var(--danger); }
@media (max-width: 420px) { .wa-box { grid-template-columns: 1fr; } }

/* ═════════ Sales history ═════════ */
.sales-filters { display: grid; gap: 12px; grid-template-columns: 1fr; }
.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.date-row label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.quick-dates { gap: 6px; }
.filter-row { display: grid; gap: 8px; grid-template-columns: 2fr repeat(3, 1fr) auto; }
.filter-row:has(> :nth-child(2):last-child) { grid-template-columns: 1fr auto; }
@media (max-width: 760px) { .filter-row { grid-template-columns: 1fr 1fr; } .filter-row > .input[type=search] { grid-column: 1 / -1; } }

.stat-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat:first-child { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.stat:first-child .stat-label, .stat:first-child .muted { color: inherit; opacity: .85; }
.stat-muted { opacity: .7; }

.slist { padding: 4px 18px; }
.srow { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto 110px; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.srow:last-child { border-bottom: 0; }
.srow:hover .smain strong { color: var(--brand); }
.srow.voided { opacity: .55; }
.srow.voided .stotal { text-decoration: line-through; }
.stime { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.smain { display: grid; min-width: 0; }
.smain .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smethods { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.stotal { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .srow { grid-template-columns: 44px minmax(0, 1fr) auto; row-gap: 4px; }
  .smethods { grid-column: 2 / 4; justify-content: flex-start; grid-row: 2; }
}
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0 20px; }

/* Sale detail */
.sale-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .sale-grid { grid-template-columns: minmax(0, 1fr); } }
.kv-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 16px; margin-bottom: 12px; }
.kv-list > div { display: grid; }
.kv-list span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.sale-totals { max-width: 320px; margin-left: auto; padding-top: 8px; }
.void-card { border-color: var(--danger); }
.void-card h2 { color: var(--danger); }

/* ═════════ Till entries & cash-up ═════════ */
.type-grid { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .type-grid { grid-template-columns: 1fr 1fr; } }
.type-tile { position: relative; display: grid !important; gap: 4px; align-content: start; padding: 14px; cursor: pointer; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); font-weight: 400 !important; }
.type-tile input { position: absolute; opacity: 0; pointer-events: none; }
.type-tile.on { border-color: var(--brand); background: var(--info-bg); }
.type-tile:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.type-icon { font-size: 1.6rem; line-height: 1; }
.type-title { font-weight: 700; }
.type-help { font-size: .8rem; color: var(--muted); }
@media (max-width: 420px) { .type-help { display: none; } .type-tile { padding: 12px; } }
.till-fields { display: grid; gap: 14px; }
#method-seg .seg-btn[hidden] { display: none; }

.day-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.day-pick .input { width: auto; min-height: 40px; }

.tlist { display: grid; }
.trow { display: grid; grid-template-columns: 52px minmax(0, 1fr) 120px 44px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.trow:last-child { border-bottom: 0; }
.tact { display: flex; justify-content: flex-end; }
@media (max-width: 520px) { .trow { grid-template-columns: 44px minmax(0, 1fr) auto 40px; gap: 8px; } }

.cashup-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 760px) { .cashup-grid { grid-template-columns: 1fr; } }
.variance { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 700; }
.variance strong { font-size: 1.4rem; }
.variance.even { background: var(--success-bg); color: var(--success); }
.variance.over { background: var(--warn-bg); color: #7a5a00; }
.variance.short { background: var(--danger-bg); color: var(--danger); }
.warn-text { color: #7a5a00; }
@media (prefers-color-scheme: dark) { .variance.over, .warn-text { color: #f0cf7a; } }

.den-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.den { display: grid !important; grid-template-columns: 64px 14px 1fr 90px; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.den-label { font-weight: 800; font-size: 1.05rem; }
.den-x { color: var(--muted); }
.den-qty { min-height: 44px; text-align: center; font-size: 1.15rem; font-weight: 700; }
.den-sum { text-align: right; font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.count-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-bg); font-weight: 700; }
.count-total strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.done-card { text-align: center; }
@media (max-width: 520px) {
  .trow { grid-template-columns: minmax(0, 1fr) auto 36px; grid-template-areas: "main amt act" "time amt act"; row-gap: 0; }
  .trow .smain { grid-area: main; }
  .trow .stime { grid-area: time; font-size: .78rem; font-weight: 400; }
  .trow .stotal { grid-area: amt; }
  .trow .tact { grid-area: act; }
  .trow .smain strong { font-size: .95rem; }
}

/* ═════════ Customers ═════════ */
.crow { display: grid; grid-template-columns: minmax(0, 1fr) auto 150px; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.crow:last-child { border-bottom: 0; }
.crow:hover strong:first-child { color: var(--brand); }
.crow.voided { opacity: .55; }
.cbal { display: grid; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .crow { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .crow .smethods { grid-column: 1; grid-row: 2; justify-content: flex-start; }
  .crow .cbal { grid-column: 2; grid-row: 1 / 3; }
}
.stat-alert { border-color: var(--danger); }
.stat-alert strong { color: var(--danger); }
.bal-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.bal-meta { display: grid; gap: 2px; text-align: right; font-size: .92rem; }
.ageing { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.ageing > div { display: grid; gap: 2px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.ageing span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.ageing strong { font-variant-numeric: tabular-nums; }
.ageing .aged { background: var(--warn-bg); }
@media (max-width: 480px) { .ageing { grid-template-columns: 1fr 1fr; } }
.stmt-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.stmt-head h2 { margin: 0; }
.stmt-range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stmt-range .input { width: auto; min-height: 38px; padding: 6px 8px; }
.stmt td, .stmt th { padding: 9px 8px; }
.stmt-close td { border-top: 2px solid var(--text); }
.kv-list.one-col { grid-template-columns: 1fr; }
.pre { white-space: pre-line; }
.btn-row .wa-box { flex: 1; min-width: 240px; }
.list td.num, .list th.num, .tot-row span:last-child { white-space: nowrap; }
@media (max-width: 860px) {
  .cust-grid > div { display: contents; }
  .cust-grid .card { margin-bottom: 0; }
  .o-bal { order: 1; } .o-pay { order: 2; } .o-stmt { order: 4; } .o-recent { order: 5; } .o-details { order: 6; }
}

/* ═════════ Dashboard ═════════ */
:root {
  --series-1: #2a78d6;       /* validated on #fff surface */
  --c-grid: #e4ebf0;
  --c-base: #b9c6d0;
  --delta-good: #1e7a4c;
  --delta-bad: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root { --series-1: #3987e5; --c-grid: #22394a; --c-base: #3a5566; --delta-good: #6fd49f; --delta-bad: #ff8a80; }
}
.dash-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 6px; }
.dash-presets { flex: 1 1 auto; }
.dash-presets .seg-btn, .basis .seg-btn { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.dash-custom { display: flex; align-items: center; gap: 6px; }
.dash-custom .input { width: auto; min-height: 36px; padding: 4px 8px; }
.dash-period { margin: 0 0 14px; }
@media (max-width: 700px) {
  .dash-presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .dash-presets .seg-btn { flex-shrink: 0; }
  .dash-custom { flex: 1 1 100%; }
  .dash-custom .input { flex: 1; min-width: 0; }
}

.dash-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; margin-bottom: 16px; }
.dash-top > .card { margin: 0; }
@media (max-width: 860px) { .dash-top { grid-template-columns: 1fr; } }
.hero { display: grid; align-content: center; gap: 6px; }
.hero-num { font-size: clamp(2.6rem, 6vw, 3.4rem); font-weight: 700; line-height: 1.05; letter-spacing: -.01em; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile-stat { display: grid; gap: 4px; margin: 0; align-content: start; }
.tile-stat strong { font-size: 1.45rem; }
.delta { font-weight: 700; font-size: .88rem; }
.delta-good { color: var(--delta-good); }
.delta-bad { color: var(--delta-bad); }

.chart-card { padding-bottom: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.chart-head h2 { margin: 0 0 8px; }
.bar-chart { position: relative; width: 100%; touch-action: pan-y; }
.bar-chart svg { display: block; outline: none; overflow: visible; }
.bar-chart svg:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.c-grid { stroke: var(--c-grid); stroke-width: 1; }
.c-base { stroke: var(--c-base); stroke-width: 1; }
.c-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.c-label { fill: var(--text); font-size: 12px; font-weight: 700; }
.c-bar { fill: var(--series-1); transition: opacity .12s; }
.c-bar.dim { opacity: .45; }
.c-hl { fill: var(--surface-2); }
.chart-tip { position: absolute; top: 0; display: grid; gap: 1px; padding: 6px 10px; border-radius: 8px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(0,0,0,.14); white-space: nowrap; z-index: 2; }
.chart-tip strong { font-size: 1rem; }
.chart-tip span { font-size: .8rem; color: var(--muted); }
.table-view { margin-top: 10px; }
.table-view summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; }
.table-view .table-wrap { max-height: 320px; overflow-y: auto; margin-top: 8px; }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.dash-grid > .card { margin: 0; }
.mbars { display: grid; gap: 14px; }
.mbar-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: .95rem; }
.mbar-track { height: 10px; border-radius: 0 4px 4px 0; background: var(--surface-2); }
.mbar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); }

.viewer-panel summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.viewer-panel[open] summary { margin-bottom: 14px; }
.viewer-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
@media (max-width: 700px) {
  .dash-filters { display: grid; grid-template-columns: minmax(0, 1fr); }
  .dash-presets { min-width: 0; }
  .dash-custom { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; }
  .basis { justify-self: start; }
}
.tile-stat strong, .hero-num { white-space: nowrap; }
@media (max-width: 700px) {
  .dash-custom { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .dash-custom .dash-to { display: none; }
  .dash-custom .input { font-size: .9rem; padding: 4px 6px; }
}
@media (max-width: 420px) {
  .tile-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile-stat { padding: 14px; }
  .tile-stat strong { font-size: 1.15rem; }
  .hero-num { font-size: 2.6rem; }
}

/* ═════════ Import & clean-up ═════════ */
.import-types { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.import-types .type-tile a { margin-top: 6px; font-weight: 600; }
.import-types .type-help { display: block !important; }
.import-preview { max-height: 420px; overflow-y: auto; margin-top: 12px; }
.row-bad td { background: var(--danger-bg); }
.bulk-src { display: flex; gap: 18px; flex-wrap: wrap; }
.bulk-result { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-bg); display: grid; }
.bulk-result.none { background: var(--surface-2); }
.danger-card { border-color: var(--danger); }
.danger-card summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.danger-card summary strong { color: var(--danger); }
.danger-card[open] summary { margin-bottom: 10px; }
.pill-driver { background: #efe6fb; color: #5b3aa7; }
@media (prefers-color-scheme: dark) { .pill-driver { background: #2c2344; color: #c7b5f2; } }

/* ═════════ Deliveries ═════════ */
.drow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.drow:last-child { border-bottom: 0; }
.drow.status-delivered, .drow.status-cancelled { opacity: .7; }
.dmain { display: grid; gap: 3px; min-width: 0; }
.dtop { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dside { display: grid; gap: 6px; justify-items: end; align-content: start; }
.dside .btn-row { justify-content: flex-end; }
.dpill-planned { background: var(--info-bg); color: var(--brand); }
.dpill-delivered { background: var(--success-bg); color: var(--success); }
.dpill-failed { background: var(--danger-bg); color: var(--danger); }
.dpill-cancelled { background: var(--surface-2); color: var(--muted); }
.replan { display: flex; gap: 6px; align-items: center; }
.replan .input { width: auto; min-height: 36px; padding: 4px 8px; }
.overdue-card { border-color: #e0b44a; }
@media (max-width: 640px) {
  .drow { grid-template-columns: 1fr; }
  .dside { justify-items: start; }
  .dside .btn-row { justify-content: flex-start; }
}
.day-pick select.input { width: auto; min-height: 40px; }
.dlines { display: grid; gap: 8px; margin-bottom: 10px; }
.dline { display: grid; grid-template-columns: minmax(0, 1fr) 90px 40px; gap: 8px; align-items: center; }

/* Driver */
.stops { display: grid; gap: 14px; margin-bottom: 16px; }
.stop-card { margin: 0; display: grid; gap: 10px; }
.stop-head { display: flex; gap: 12px; align-items: center; }
.stop-head h2 { margin: 0; }
.stop-num { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 800; flex-shrink: 0; }
.stop-addr { font-size: 1.02rem; }
.stop-items { margin: 0; padding-left: 18px; font-size: 1.05rem; }
.stop-note { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-bg); }
.stop-actions { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; }
.stop-actions .btn-lg { min-height: 48px; }
.collected { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.collected > div { display: grid; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.deliver-form .pay-methods { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.fail-card summary { cursor: pointer; color: var(--danger); font-weight: 700; }
.deliver-form .pay-methods { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
.deliver-form .pay-m { padding: 10px 4px; font-size: 1.3rem; }
.deliver-form .pay-m span { font-size: .8rem; }

/* ═════════ Books export & backups ═════════ */
.export-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.export-form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.export-form .input { width: auto; min-height: 42px; }
.jday { border-bottom: 1px solid var(--border); padding: 10px 0; }
.jday:last-child { border-bottom: 0; }
.jday summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.jday .table-wrap { margin-top: 8px; }
.backup-list .tot-row { padding: 8px 0; border-bottom: 1px solid var(--border); align-items: center; }
.backup-list .tot-row:last-child { border-bottom: 0; }
code.block { display: block; padding: 10px 12px; margin: 6px 0; overflow-x: auto; white-space: nowrap; font-size: .85rem; }
.backup-list .tot-row { flex-wrap: wrap; gap: 6px; }
.backup-list .tot-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }

/* ═════════ Price lists & quotes ═════════ */
.pl-table .input { width: 110px; min-height: 38px; padding: 6px 8px; text-align: right; margin-left: auto; display: block; }
.quick-fill { align-items: center; }
.quick-fill .input { min-height: 36px; padding: 4px 8px; }
.qpill-open { background: var(--info-bg); color: var(--brand); }
.qpill-accepted { background: var(--success-bg); color: var(--success); }
.qpill-declined, .qpill-expired { background: var(--danger-bg); color: var(--danger); }
.qpill-converted { background: var(--surface-2); color: var(--muted); }
.qline { display: grid; grid-template-columns: minmax(0, 1fr) 80px 110px 110px 40px; gap: 8px; align-items: center; }
.qline .input { min-height: 40px; padding: 6px 8px; }
.qline .qamt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.qhead { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
@media (max-width: 640px) {
  .qline { grid-template-columns: minmax(0, 1fr) 70px 40px; }
  .qline .qprice-wrap { grid-column: 1; } .qline .qamt { grid-column: 2; }
  .qhead { display: none; }
}

/* ── Driver screen: offline status ── */
.drv-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 10px 12px; margin: 0 0 12px; border-radius: var(--radius-sm); font-size: .95rem; }
.drv-off { display: block; background: var(--surface-2); border: 1px solid var(--border); }
.drv-wait { background: var(--warn-bg); position: sticky; top: 8px; z-index: 5; }
.drv-saved { margin: -6px 0 10px; }
.drv-attn { border-color: var(--danger); display: grid; gap: 6px; }
.drv-attn p { margin: 0; }
.drv-pin { display: grid; gap: 10px; max-width: 420px; margin-inline: auto; text-align: center; }
.drv-pin h2, .drv-pin p { margin: 0; }
.drv-done { align-items: center; gap: 10px; }
.tick-wait { background: var(--warn-bg); color: #7a5a00; }
.sync-note { margin-top: 2px; }
@media (prefers-color-scheme: dark) { .tick-wait, .drv-wait { color: #f1d488; } }

/* ── Accounting ── */
.aline { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 120px 130px 40px; gap: 8px; align-items: center; }
.aline.no-vat { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 120px 40px; }
.jline { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) 110px 110px 40px; gap: 8px; align-items: center; }
.aline .input, .jline .input { min-height: 40px; padding: 6px 8px; }
.ahead { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.input.num { text-align: right; }
.acc-filters { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.acc-filters label { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; }
.acc-list .pill { margin-left: 6px; }
.brows { display: grid; gap: 10px; margin-bottom: 16px; }
.brow { margin: 0; display: grid; gap: 8px; }
.brow-done { color: inherit; text-decoration: none; }
.b-top { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; }
.b-date { color: var(--muted); font-size: .9rem; }
.b-desc { overflow-wrap: anywhere; }
.b-amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.b-act { display: grid; grid-template-columns: minmax(0, 1fr) 130px auto auto auto; gap: 8px; }
.b-act.no-vat { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.b-act .input, .b-act .btn { min-height: 42px; }
.b-rem { font-weight: 400; }
.b-rem input { width: 18px; height: 18px; }
.b-match .input { margin-top: 4px; }
.plain-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.report-head { display: grid; gap: 2px; margin-bottom: 12px; }
.report-head h2 { margin: 0; }
.report h3 { margin: 16px 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rrow { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.rrow span:last-child { white-space: nowrap; }
.rtotal { font-weight: 700; border-bottom: 0; }
.rgrand { font-weight: 800; font-size: 1.1rem; border-top: 2px solid var(--text); border-bottom: 0; margin-top: 4px; }
@media (max-width: 700px) {
  .aline, .aline.no-vat { grid-template-columns: minmax(0, 1fr) 110px 40px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .aline .a-target { grid-column: 1 / -1; }
  .aline.no-vat > input[name="memo[]"] { grid-column: 1 / 2; }
  .aline:not(.no-vat) > input[name="memo[]"] { grid-column: 1 / -1; }
  .aline:not(.no-vat) .a-vat { grid-column: 1 / 2; grid-row: 3; }
  .aline:not(.no-vat) .a-amt { grid-column: 2 / 3; grid-row: 3; }
  .aline:not(.no-vat) [data-remove] { grid-row: 3; }
  .jline { grid-template-columns: 1fr 1fr 40px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .jline select, .jline .j-partywrap, .jline input[name="memo[]"] { grid-column: 1 / -1; }
  .ahead { display: none; }
  .b-act, .b-act.no-vat { grid-template-columns: 1fr 1fr 1fr; }
  .b-act .b-target { grid-column: 1 / -1; }
  .b-act .b-vat { grid-column: 1 / -1; }
}
@media print { .no-print, .topbar, .flash { display: none !important; } .card { box-shadow: none; border: 0; } body { background: #fff; } }

/* ── Vehicle trips ── */
.day-nav { display: flex; gap: 8px; align-items: center; }
.day-nav .input { max-width: 220px; }
.trip-del { padding: 10px 0; border-bottom: 1px solid var(--border); font-weight: 400; align-items: flex-start; }
.trip-del:last-of-type { border-bottom: 0; }
.trip-del input { margin-top: 3px; flex-shrink: 0; }
.bulk-row3 { grid-template-columns: 1fr 90px 90px !important; }
.bulk-row3.ahead { padding: 0 0 2px; border-bottom: 0; margin: 0; }
.bulk-row3.ahead span { text-align: center; }

/* ── Route on a trip ── */
.route-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; }
.route-stop { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.route-stop:last-child { border-bottom: 0; }
.route-stop .smain { display: grid; min-width: 0; }
.route-move { display: flex; gap: 6px; }
.wa-preview { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .9rem; background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); margin: 8px 0; }

/* ── Scanned slips ── */
.scan-split { display: grid; grid-template-columns: minmax(280px, 42%) minmax(0, 1fr); gap: 16px; align-items: start; }
.scan-side { position: sticky; top: 12px; margin: 0; max-height: calc(100vh - 24px); overflow: auto; display: grid; gap: 12px; }
.scan-view { display: grid; gap: 6px; }
.scan-img { width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.scan-pdf { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.scan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.scan-card { margin: 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; }
.scan-thumb { display: block; width: 96px; height: 128px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.scan-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-pdf-ico { display: grid; place-items: center; width: 100%; height: 100%; font-weight: 800; color: var(--muted); }
.scan-meta { display: grid; gap: 6px; min-width: 0; }
.scan-attached { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.scan-chip { display: block; width: 56px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.scan-chip img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 860px) {
  .scan-split { grid-template-columns: minmax(0, 1fr); }
  .scan-side { position: static; max-height: 46vh; }
}
.bulk-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; position: sticky; top: 8px; z-index: 4; }
.bulk-bar .input { width: auto; min-width: 180px; flex: 1; }
.dpick { width: 20px; height: 20px; accent-color: var(--brand); flex-shrink: 0; }

/* Unpaid deliveries & collect-payment stops */
.pill-collect, .pill-ok { background: var(--success-bg); color: var(--success); }
.stop-collect { border-left: 4px solid var(--success); }
.unpaid-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.unpaid-row:last-child { border-bottom: 0; }
.unpaid-cust { margin-bottom: 14px; }
.unpaid-cust h2 { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.unpaid-cust h2 .spacer { flex: 1; }
.unpaid-actions { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 10px; }
.unpaid-actions form { display: grid; gap: 8px; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.unpaid-actions .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Bulk add & change */
.bulk-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.bulk-grid { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.bulk-grid th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; padding: 6px 6px; white-space: nowrap; font-size: 12px; border-bottom: 1px solid var(--border); }
.bulk-grid th.req::after { content: " *"; color: var(--danger); }
.bulk-grid td { padding: 2px 3px; border-bottom: 1px solid var(--border); vertical-align: middle; background: var(--surface); }
.bulk-grid .input { min-height: 32px; padding: 4px 6px; font-size: 13px; border-radius: 6px; width: 100%; min-width: 60px; }
.bulk-grid .bulk-tick { width: 30px; text-align: center; position: sticky; left: 0; z-index: 1; }
.bulk-grid th.bulk-tick { z-index: 3; }
.bulk-grid .bulk-id { white-space: nowrap; padding: 0 6px; }
.bulk-grid .bulk-ro { display: inline-block; padding: 0 6px; white-space: nowrap; }
.bulk-grid .bulk-msg { min-width: 160px; max-width: 320px; }
.bulk-grid tr.dirty td { background: var(--warn-bg); }
.bulk-grid tr.has-err td { background: var(--danger-bg); }
.bulk-grid tr.locked td { opacity: .75; }
.bulk-grid .input.changed { border-color: #c79a00; }
.bulk-grid .input.bad, #ba-input.bad { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-bg); }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulk-actions .input { width: auto; min-width: 140px; }
.bulk-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulk-filters .input { width: auto; }
.bulk-up > summary { list-style: none; display: inline-flex; }
.bulk-up > summary::-webkit-details-marker { display: none; }
.bulk-save { align-items: center; }
.bulk-save { z-index: 20; }
.match-pay { padding: 12px 0; border-bottom: 1px solid var(--border); } .match-pay:last-child { border-bottom: 0; }
.till-pick { display: inline-flex; } .till-pick .input { width: auto; min-height: 40px; padding: 4px 8px; }
.doc-logo-preview { max-height: 60px; max-width: 200px; display:block }

/* Driver: two-step delivery, notes to the office, paper-book photo */
.step-box { margin-top: 14px; padding: 12px; border: 1px solid var(--border, #d6dde3); border-radius: var(--radius-sm, 10px); text-align: left; background: var(--surface-2, rgba(0,0,0,.03)); position: relative; }
.pay-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.drv-notes summary { cursor: pointer; }
.drv-note { padding: 8px 0; border-top: 1px solid var(--border, #e3e8ec); white-space: pre-wrap; }
.drv-reply { margin-top: 4px; padding: 6px 8px; border-radius: 8px; background: rgba(11,95,138,.08); }
#book-btn { position: relative; cursor: pointer; }
#done-today summary { cursor: pointer; }
.book-box { margin: 10px 0; padding: 8px 10px; border: 1px dashed var(--border, #c8d1d8); border-radius: 10px; }
.book-box summary { cursor: pointer; font-weight: 600; }
@media (max-width: 640px) { .bb-grid { grid-template-columns: 1fr !important; } }

/* ── Style picker (style.php) ── */
.style-pick { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: stretch; }
.style-pick .btn-row { grid-column: 1 / -1; }
.style-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; border: 2px solid var(--border); margin-bottom: 0; }
.style-card.on { border-color: var(--brand); }
.style-card:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.style-swatch { display: flex; height: 54px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.style-swatch i { flex: 1; }

/* ── Driver phone: trips, and what was finished in the last hour ── */
.trip-head { margin: 18px 0 8px; font-size: 1.15rem; display: flex; align-items: baseline; gap: 10px; }
.trip-head .small { font-weight: 400; }
.drv-recent-box { display: grid; gap: 6px; margin: 4px 0 12px; }
.drv-recent { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--success-bg); color: var(--text); text-decoration: none; }
.drv-recent .pill { margin-left: 4px; }

.mode-pick { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.mode-opt { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; }

.disc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); }
.disc-pct { width: 70px; min-height: 36px; padding: 4px 8px; }
.dline-extra { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .85rem; color: var(--muted); }
.dline-extra .input { width: 110px; min-height: 36px; padding: 4px 8px; }

.slip-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.slip-table th, .slip-table td { padding: 5px 3px; text-align: left; border-bottom: 1px solid var(--border); }
.slip-table .num { text-align: right; }
@media print { .drv-bar, .drv-saved, .no-print, #drv-status { display: none !important; } .slip { border: 0; box-shadow: none; max-width: none; } .slip > :first-child { margin-top: 0; } .slip > :last-child { margin-bottom: 0; } }   /* no blank lines at the top or bottom */

.free-box { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--success-bg); color: var(--success); font-size: 1rem; }
.free-li { list-style: none; margin-left: -4px; }

/* Delivery day steps: Plan → On the road → Check-in */
.run-stages{display:flex;flex-wrap:wrap;gap:10px;margin:0 0 14px}
.run-step{flex:1 1 200px;display:flex;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);color:inherit;text-decoration:none}
.run-step.on{border-color:var(--brand);box-shadow:0 0 0 2px rgba(11,111,164,.18)}
.rs-n{width:30px;height:30px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;font-weight:700}
.run-step.on .rs-n{background:var(--brand);color:var(--brand-ink)}
.more-menu{position:relative;display:inline-block}.more-menu summary{list-style:none;cursor:pointer}.more-menu summary::-webkit-details-marker{display:none}
.more-list{position:absolute;right:0;top:100%;z-index:20;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:8px;display:flex;flex-direction:column;gap:6px;min-width:240px;box-shadow:var(--shadow)}
.more-list .btn{justify-content:flex-start}
.road-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:14px;align-items:start;margin-bottom:14px}
.road-bar{height:10px;border-radius:99px;background:var(--surface-2);overflow:hidden;margin:6px 0}.road-bar i{display:block;height:100%;background:var(--brand)}
.road-stop{display:flex;justify-content:space-between;gap:8px;padding:8px 0;border-top:1px solid var(--border);font-size:14px}

/* Driver screen: progress, next stop, trip complete, bottom bar */
.drv-progress{margin:0 0 12px}.drv-progress-top{display:flex;justify-content:space-between;gap:8px;font-size:.95rem}
.drv-pbar{height:10px;border-radius:99px;background:var(--surface-2);overflow:hidden;margin-top:6px}.drv-pbar i{display:block;height:100%;background:var(--brand)}
.stop-next{border:2px solid var(--brand)}.pill-next{background:var(--brand);color:var(--brand-ink);font-weight:700;margin-bottom:4px;display:inline-block}
.trip-done{text-align:center;padding:20px 16px;margin:10px 0}.trip-done .done-tick{font-size:2.2rem;color:var(--success)}
.drv-tabbar{position:sticky;bottom:0;display:flex;justify-content:space-around;gap:6px;background:var(--surface);border-top:1px solid var(--border);padding:8px 6px calc(8px + env(safe-area-inset-bottom));margin:16px -12px -12px;z-index:5}
.drv-tabbar a{flex:1;text-align:center;padding:10px 4px;font-weight:700;color:var(--brand);text-decoration:none;min-height:44px}
.drv-dot{background:var(--danger);color:#fff;border-radius:99px;font-size:.75rem;padding:1px 7px}
#cust-prices{min-width:0;max-width:100%}#cust-prices .table-wrap{max-width:100%;overflow-x:auto}#cust-prices table{min-width:460px}
.pill-pay { background: var(--success-bg); color: var(--success); font-weight: 700; }
.pill-pay-account { background: #fbe9d0; color: #8a4a00; }
.pill-pay-eft, .pill-pay-card { background: #e5ecf9; color: #25498c; }

/* Office bottom bar — phones only */
.bottombar { display: none; }
@media (max-width: 760px) {
  body:not(.bare) { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .bottombar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface, #fff); border-top: 1px solid var(--border, #d5dde4);
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
  .bottombar > a, .bottombar > button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; padding: 6px 0;
    font: inherit; font-size: 11px; font-weight: 700; color: var(--muted, #51606f); background: none; border: 0; text-decoration: none; cursor: pointer; }
  .bottombar > a.on { color: var(--brand, #0b6fa4); }
  .bb-ico { position: relative; font-size: 20px; line-height: 22px; }
  .bb-badge { position: absolute; top: -5px; right: -12px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #d93025; color: #fff; font: 700 11px/18px system-ui, sans-serif; font-style: normal; text-align: center; }
  .bb-sheet { position: absolute; right: 8px; bottom: calc(60px + env(safe-area-inset-bottom)); width: min(260px, calc(100vw - 16px)); max-height: 70vh; overflow: auto; background: var(--surface, #fff);
    border: 1px solid var(--border, #d5dde4); border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.2); padding: 6px; }
  .bb-sheet a { display: block; padding: 12px 14px; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 600; min-height: 20px; }
  .bb-sheet a:hover { background: rgba(127,127,127,.12); }
  .bb-sheet[hidden] { display: none; }
}
@media print { .bottombar { display: none !important; } }

/* Driver phone: office chat bubbles */
.drv-chat { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.drv-bub { max-width: 88%; padding: 7px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--border); }
.drv-bub.me { align-self: flex-end; background: #DCF8C6; }
.drv-bub.office { align-self: flex-start; }
.drv-bub-who { font-size: 11px; font-weight: 700; color: var(--brand, #0b6fa4); }
/* Office chat: names list and WhatsApp-style thread */
.chat-filters { margin-bottom: 10px; }
.chat-list { padding: 0; overflow: hidden; }
.chat-row { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); }
.chat-row:first-child { border-top: 0; }
.chat-row.is-unread .chat-text strong { font-weight: 800; }
.chat-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: inherit; text-decoration: none; }
.chat-av { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--brand-bg, #dceef8); color: var(--brand, #084f76); }
.chat-text { flex: 1; min-width: 0; }
.chat-last { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { text-align: right; flex: none; }
.chat-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #d93025; color: #fff; font-weight: 700; font-size: 12px; }
.chat-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--brand, #0b6fa4); }
.chat-act { padding-right: 8px; }
.chat-thread { background: #ECE5DD; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
.chat-day { align-self: center; background: #fff; border-radius: 8px; padding: 2px 10px; font-size: 12px; color: #667; }
.chat-sys { align-self: center; background: #E1F3FB; border-radius: 8px; padding: 3px 10px; font-size: 12px; color: #334; }
.chat-msg { max-width: 82%; padding: 7px 10px; border-radius: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.12); color: #111; }
.chat-msg.them { align-self: flex-start; background: #fff; }
.chat-msg.me { align-self: flex-end; background: #DCF8C6; }
.chat-msg img { max-width: 220px; max-height: 180px; border-radius: 8px; display: block; margin-bottom: 4px; }
.chat-who { font-size: 11px; font-weight: 700; color: #0b6a41; }
.chat-time { font-size: 11px; color: #667; text-align: right; margin-top: 2px; }
.chat-dl { font-size: 12px; display: inline-block; margin-bottom: 4px; }
.chat-compose { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 4px; background: var(--bg, #f2f5f7); }
.chat-compose textarea { flex: 1; min-height: 44px; resize: vertical; }
.chat-photo { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 20px; }
.chat-photo input { position: absolute; width: 1px; height: 1px; opacity: 0; }
@media (max-width: 760px) { .chat-compose { bottom: calc(60px + env(safe-area-inset-bottom)); } .chat-act { display: none; } }

.plan-card { margin-bottom: 14px; }
.plan-card h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 17px; margin: 0 0 8px; }
.plan-card h2 .spacer { flex: 1; }
.plan-trip { border-left: 4px solid var(--brand, #0b6fa4); }
.to-trip { padding: 0 0 12px; border-bottom: 1px solid var(--border); }
.to-trip select { max-width: 320px; }

/* Plan page: compact stops, menus, send section */
.row-actions { align-items: center; flex-wrap: nowrap; gap: 4px; }
.row-more { position: relative; }
.row-more > summary { list-style: none; cursor: pointer; }
.row-more > summary::-webkit-details-marker { display: none; }
.row-more-list { position: absolute; right: 0; z-index: 15; min-width: 190px; display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.row-order { display: flex; gap: 4px; }
.dpick { display: none; }
body.bulk-on .dpick { display: inline-block; }
.bulk-wrap { margin-bottom: 12px; padding: 10px 14px; }
.bulk-wrap > summary { cursor: pointer; font-weight: 600; }
.inline-form { display: inline; margin: 0; }
.trip-load { margin: 0 0 6px; }
.send-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.put-all { display: flex; gap: 8px; align-items: center; }

.drv-head{margin:0 0 8px}.drv-title{font-size:1.35rem;font-weight:800}
.drv-pbar{height:8px;background:var(--border);border-radius:99px;overflow:hidden;margin-top:6px}.drv-pbar i{display:block;height:100%;background:var(--brand,#0b6fa4)}
.drv-banner{background:#e6f6ec;border:1px solid #9bd3ae;border-radius:10px;padding:10px 12px;font-weight:700;margin:0 0 12px}
.drv-row{display:flex;gap:10px;align-items:center;padding:10px 0;border-top:1px solid var(--border);color:inherit;text-decoration:none}
.drv-row .n{flex:0 0 26px;height:26px;border-radius:50%;background:var(--border);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:.85rem}
.drv-row>span:nth-child(2){flex:1}.drv-chev{flex:0 0 auto;font-size:1.4rem;color:var(--muted,#777)}
.drv-still-head,.drv-next-head{display:flex;justify-content:space-between;padding-bottom:6px}
.drv-donebox summary{display:flex;justify-content:space-between;cursor:pointer}
#change-prev{border:2px dashed var(--border)}
.drv-dot{background:#d33;color:#fff;border-radius:99px;padding:0 6px;font-size:.75rem}
.drv-h2{margin:8px 0}

.drv-newbanner{display:flex;gap:10px;align-items:center;justify-content:space-between;background:#fff4cc;border:2px solid #e0b400;border-radius:10px;padding:10px 12px;margin:0 0 12px;position:sticky;top:0;z-index:6}

.drow{position:relative}
.drag-handle{position:absolute;left:2px;top:50%;transform:translateY(-50%);cursor:grab;touch-action:none;user-select:none;font-size:1.3rem;line-height:1;color:var(--muted,#888);padding:8px 6px;z-index:1}
.drow:has(.drag-handle){padding-left:26px}
.drow.dragging{opacity:.55;outline:2px dashed var(--brand,#0b6fa4)}
.saving{opacity:.7}
#reorder-note{position:fixed;bottom:16px;left:50%;transform:translateX(-50%);background:#1d6b3a;color:#fff;border-radius:99px;padding:8px 16px;z-index:50}

/* Driver changes (change log) */
.fix-log-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 12px; margin-bottom: 10px; }
.fix-log .list td:first-child { width: 50%; }

/* Owner edits */
.flash-warn { background: var(--warn-bg); color: #6b4e00; }
.edit-warn ul { margin: 6px 0 10px; padding-left: 18px; }
.edit-lines select.input { min-width: 180px; }
.edit-lines .num .input { width: 100px; text-align: right; }
.chat-del { display: inline; margin-left: 6px; }
.chat-del-btn { background: none; border: 0; padding: 0; color: inherit; opacity: .6; font: inherit; font-size: 11px; text-decoration: underline; cursor: pointer; }
.chat-del-btn:hover { opacity: 1; }
.cn-head { font-size: 1.05rem; margin: 18px 0 8px; }
.tact { gap: 6px; align-items: center; }
.edit-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.edit-head h2 { margin: 0; }
.till-editing { outline: 2px solid var(--brand); outline-offset: -2px; }
/* till rows: room for Edit + delete */
.trow { grid-template-columns: 52px minmax(0, 1fr) auto auto; }
.trow .stotal { white-space: nowrap; text-align: right; }
@media (max-width: 520px) { .trow { grid-template-columns: minmax(0, 1fr) auto auto; } }
.cn-del { margin: 2px 0 10px; } .cn-del summary { cursor: pointer; color: var(--danger); font-size: .88rem; min-height: 32px; display: inline-flex; align-items: center; }
.cn-del form { margin-top: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.imp-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.imp-row .cn-del { flex: 1 1 260px; margin: 0; }
.bank-del summary { cursor: pointer; color: var(--danger); min-height: 36px; display: flex; align-items: center; }
.j-partywrap select[hidden]{display:none}

/* Unpaid: ageing summary and one compact line per customer */
.up-sum { display: grid; gap: 10px; }
.up-total strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.up-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--border); }
.up-bar i { display: block; height: 100%; }
.up-buckets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.up-bk { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; color: inherit; text-decoration: none; display: block; }
.up-bk.on { border-color: var(--primary, #0b6e9e); background: var(--surface-2); }
.up-bk b { display: block; font-variant-numeric: tabular-nums; }
.up-bk span { font-size: .8rem; color: var(--muted); }
.up-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.up-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.up-tools input[type=search] { flex: 1; min-width: 180px; }
.up-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.up-cust-wrap { border-top: 1px solid var(--border); }
.up-cust-wrap:first-child { border-top: 0; }
.up-line { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 14px; cursor: pointer; list-style: none; }
.up-line::-webkit-details-marker { display: none; }
.up-line:hover { background: var(--surface-2); }
.up-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.up-name small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.up-amt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.up-age { font-size: .82rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; border: 1px solid currentColor; justify-self: start; white-space: nowrap; }
.up-a0 { color: var(--ok, #1d7a4d); } .up-a30 { color: #b26a00; } .up-a60 { color: #c2611a; } .up-a90 { color: var(--bad, #b3261e); }
.up-last { font-size: .82rem; color: var(--muted); }
.up-body { padding: 4px 14px 14px; background: var(--surface-2); }
.up-body .unpaid-cust { margin-bottom: 8px; }
.up-more { margin-top: 6px; }
@media (max-width: 640px) {
  .up-buckets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .up-line { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .up-line .up-age, .up-line .up-last { grid-column: 1; }
  .up-line .up-amt { grid-row: 1; grid-column: 2; }
}

/* ── From the paper book (book_bulk.php) ── */
.bk-up { padding: 12px; }
.bk-drop { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 2px dashed var(--border-strong, #c3cdd6); border-radius: 12px; cursor: pointer; background: var(--surface-2, transparent); }
.bk-drop:hover, .bk-drop.over { border-color: var(--brand, #0B1F33); background: color-mix(in srgb, var(--brand, #0B1F33) 6%, transparent); }
.bk-drop-ico { font-size: 28px; }
.bk-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.bk-mode-card h2 { margin: 0 0 8px; }
.bk-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.bk-mode { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border: 1.5px solid var(--border-strong, #c3cdd6); border-radius: 19px; font-weight: 600; cursor: pointer; }
.bk-mode input { position: absolute; opacity: 0; pointer-events: none; }
.bk-mode.on { background: var(--brand, #0B1F33); border-color: var(--brand, #0B1F33); color: var(--brand-ink, #fff); }
.bk-help { margin: 8px 0 4px; font-size: .92rem; }
.bk-dayall { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 6px 0; }
.bk-dayall label { display: grid; gap: 2px; font-size: .85rem; }
#bb-rows { counter-reset: bk; }
.bk-row { padding: 0; border-left: 4px solid var(--border-strong, #c3cdd6); }
.bk-row.is-ready { border-left-color: #2e9e5b; }
.bk-row.has-error { border-left-color: #d93025; }
.bk-rh { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border, #e3e9ee); }
.bk-no::before { counter-increment: bk; content: "Page " counter(bk); }
.bk-row.is-ready .bk-state { color: #1f7a45; font-weight: 600; }
.bk-err { margin: 8px 12px 0; padding: 8px 10px; border-radius: 8px; background: #fde8e6; color: #8a1c12; font-weight: 600; }
.bk-body { display: grid; grid-template-columns: minmax(150px, 280px) 1fr; gap: 14px; padding: 12px; align-items: start; }
.bk-photo { display: block; }
.bk-photo img { width: 100%; max-height: 460px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border, #d6dde3); background: #f4f6f8; }
.bk-nophoto { border: 1px dashed var(--border-strong, #c3cdd6); border-radius: 8px; padding: 22px 12px; text-align: center; }
.bk-form { display: grid; gap: 10px; min-width: 0; }
.bk-l { display: block; font-size: .8rem; font-weight: 600; color: var(--muted, #6b7782); margin-bottom: 2px; }
.bk-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.bk-fields label { min-width: 0; }
.bk-fields .input, .bk-link .input { width: 100%; min-height: 40px; }
.bk-f-ref { grid-column: span 2; } .bk-f-date { grid-column: span 2; } .bk-f-cust { grid-column: span 2; }
.bk-f-drv { grid-column: span 3; } .bk-f-pay { grid-column: span 3; }
.bk-link { display: grid; gap: 6px; }
.bk-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 10px 14px; background: var(--surface, #fff); border: 1px solid var(--border, #e3e9ee); border-radius: 12px; box-shadow: 0 -2px 12px rgba(0,0,0,.08); }
.bk-count { font-weight: 600; }
.bk-empty { text-align: center; }
.bk-res-h { display: flex; align-items: center; gap: 10px; } .bk-res-h h2 { margin: 0; }
.bk-res-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border, #e3e9ee); }
.bk-res-bad { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: #fde8e6; color: #8a1c12; font-weight: 600; }
@media (max-width: 760px) {
  .bk-body { grid-template-columns: 1fr; }
  .bk-photo img { max-height: 300px; }
  .bk-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bk-f-ref, .bk-f-date, .bk-f-cust, .bk-f-drv, .bk-f-pay { grid-column: span 1; }
  .bk-f-cust { grid-column: 1 / -1; }
  .bk-bar { bottom: 62px; }
}
.bk-lines { display: grid; gap: 6px; margin-bottom: 6px; }
.bk-line { display: grid; grid-template-columns: 1fr 100px 40px; gap: 8px; align-items: center; padding: 4px 6px 4px 10px; border: 1px solid var(--border, #e3e9ee); border-radius: 10px; background: var(--surface-2, transparent); }
.bk-ln { font-weight: 600; overflow-wrap: anywhere; }
.bk-line .input { min-height: 40px; text-align: center; }
.bk-x { min-height: 40px; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted, #6b7782); cursor: pointer; border-radius: 8px; }
.bk-x:hover { background: #fde8e6; color: #8a1c12; }
.bk-pick { position: relative; max-width: 460px; }
.bk-pick .input { width: 100%; min-height: 42px; }
.bk-opts { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; padding: 4px; background: var(--surface, #fff); border: 1px solid var(--border-strong, #c3cdd6); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 320px; overflow: auto; }
.bk-opts[hidden] { display: none; }
.bk-opt { display: block; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bk-opt.on, .bk-opt:hover { background: var(--brand, #0B1F33); color: var(--brand-ink, #fff); }
.bk-none { padding: 8px 12px; }

/* ── Receipts (receipts.php) ── */
.rc-tabs { display: flex; gap: 8px; margin: 0 0 12px; }
.rc-tab { min-height: 38px; padding: 0 18px; border-radius: 19px; border: 1.5px solid var(--border-strong, #c9c9c4); display: inline-flex; align-items: center; font-weight: 600; text-decoration: none; color: inherit; background: var(--surface, #fff); }
.rc-tab.on { background: var(--text, #1d1f21); border-color: var(--text, #1d1f21); color: var(--surface, #fff); }
.rc-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.rc-list { padding: 0; overflow: hidden; }
.rc-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border, #e3e9ee); }
.rc-tools h2 { margin: 0; font-size: 1rem; }
.rc-tools .input { flex: 1 1 220px; min-width: 0; min-height: 36px; }
.rc-chip { min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1.5px solid var(--border-strong, #c9c9c4); background: transparent; color: inherit; font: inherit; font-size: .9rem; cursor: pointer; }
.rc-chip.on { background: var(--brand, #0B1F33); border-color: var(--brand, #0B1F33); color: var(--brand-ink, #fff); }
.rc-none { padding: 14px; }
.rc-tbl td, .rc-tbl th { vertical-align: middle; }
.rc-cust td { background: var(--surface-2, #f1f1ee); padding: 6px 10px; }
.rc-row.on td { background: color-mix(in srgb, var(--brand, #0B1F33) 7%, transparent); }
.rc-row[hidden], .rc-cust[hidden] { display: none; }
.rc-side { display: flex; flex-direction: column; gap: 12px; }
.rc-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
.rc-panel h2 { margin: 0; font-size: 1rem; }
.rc-sum { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rc-l { display: block; font-size: .8rem; font-weight: 600; color: var(--muted, #6b7782); margin-bottom: 3px; }
.rc-grp { display: flex; flex-direction: column; gap: 4px; }
.rc-grp .input { min-height: 40px; }
.rc-seg { display: flex; gap: 6px; }
.rc-seg label, .rc-seg a { flex: 1; }
.rc-seg input { position: absolute; opacity: 0; pointer-events: none; }
.rc-seg span, .rc-seg a { display: flex; align-items: center; justify-content: center; min-height: 38px; border: 1.5px solid var(--border-strong, #c9c9c4); border-radius: 8px; cursor: pointer; color: inherit; text-decoration: none; font-weight: 500; }
.rc-seg input:checked + span { background: var(--brand, #0B1F33); border-color: var(--brand, #0B1F33); color: var(--brand-ink, #fff); }
.rc-opt { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.rc-opt .input { margin-left: auto; min-height: 34px; width: auto; }
.rc-opt span { margin-left: auto; }
.rc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rc-prev { background: var(--surface-2, #f4f4f2); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.rc-line { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; color: var(--text, #1d1f21); }
.rc-warn { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: #fff1da; color: #8a4b00; font-size: .88rem; }
.rc-warn[hidden] { display: none; }
.rc-inv { display: flex; flex-direction: column; border: 1px solid var(--border, #e3e9ee); border-radius: 8px; padding: 2px 10px; max-height: 220px; overflow: auto; }
.rc-bank { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border, #e3e9ee); }
.rc-bank:last-child { border-bottom: 0; }
.rc-bank-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.rc-amt { font-size: 1.1rem; }
.rc-bank-cust { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rc-bank-cust .input { max-width: 300px; min-height: 36px; }
.rc-note { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
@media (max-width: 900px) {
  .rc-grid { grid-template-columns: minmax(0, 1fr); }
  .rc-bank { flex-direction: column; align-items: stretch; }
}
.bk-photo { cursor: zoom-in; }
.bk-zoom { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 12, 16, .94); display: flex; flex-direction: column; }
.bk-zoom[hidden] { display: none; }
.bk-zoom-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: #fff; }
.bk-zoom-bar button { min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.1); color: #fff; font: inherit; font-size: 1.2rem; cursor: pointer; }
.bk-zoom-bar a { color: #cfe6ff; font-size: .9rem; margin-left: 6px; }
.bk-zoom-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: grab; }
.bk-zoom-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; transform-origin: center; will-change: transform; }
.bk-zoom-hint { text-align: center; color: rgba(255,255,255,.65); font-size: .8rem; padding: 6px 12px 12px; }

/* ── Invoice books and missing numbers (invoice_books.php, missing_numbers.php) ── */
.ib-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.ib-list { padding: 0; overflow: auto; }
.ib-list tr.on td { background: color-mix(in srgb, var(--brand, #0B1F33) 7%, transparent); }
.ib-form { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.ib-form h2 { margin: 0; font-size: 1rem; }
.ib-f { display: flex; flex-direction: column; gap: 3px; }
.ib-f .input { min-height: 40px; }
.mn-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; padding: 10px 14px; margin-bottom: 12px; }
.mn-filters label { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted, #6b7782); }
.mn-filters label.check { flex-direction: row; align-items: center; gap: 6px; font-size: .9rem; color: inherit; }
.mn-filters .input { min-height: 38px; }
.mn-book { padding: 0; overflow: hidden; margin-bottom: 12px; }
.mn-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 14px; padding: 12px 14px; border-bottom: 1px solid var(--border, #e3e9ee); }
.mn-head h2 { margin: 0; font-size: 1.05rem; }
.mn-dups { padding: 8px 14px; background: #fde8e6; color: #8a1c12; }
.mn-none { padding: 12px 14px; margin: 0; }
.mn-tbl td { vertical-align: middle; }
.mn-note { min-width: 160px; min-height: 36px; }
.mn-inv { width: 120px; min-height: 36px; }
.mn-acts { white-space: nowrap; }
.mn-acts form { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.mn-slip { width: 120px; min-height: 36px; }
.mn-pending { border: 1.5px solid #e0b44a; background: #fff8e6; margin-bottom: 12px; }
.mn-pending ul { margin: 6px 0 10px 18px; }
.mn-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.mn-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 10px 0; }
.mn-thumb { display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; }
.mn-thumb img { width: 100%; height: 130px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border, #d6dde3); background: #f4f6f8; }
@media (max-width: 900px) { .ib-grid, .mn-two { grid-template-columns: minmax(0, 1fr); } }
.ib-list td:first-child strong { white-space: nowrap; }
.ib-list td:first-child { min-width: 150px; }
.mn-slip { width: 150px; }
.mn-ph-btn { display: block; margin-top: 4px; padding: 2px 8px; border: 1px solid var(--border-strong, #c9c9c4); border-radius: 12px; background: transparent; color: inherit; font: inherit; font-size: .8rem; cursor: pointer; }
.mn-ph-row[hidden] { display: none; }
.mn-ph-row td { background: var(--surface-2, #f4f4f2); padding: 10px 14px; }
.mn-ph { display: flex; flex-wrap: wrap; gap: 10px; }
.mn-ph img { max-height: 260px; max-width: 100%; border-radius: 8px; border: 1px solid var(--border, #d6dde3); background: #fff; }
.mn-ph a { cursor: zoom-in; }

/* Sortable tables: click a heading */
table.sortable thead th:not(.nosort) { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable thead th:not(.nosort):hover { color: var(--ink, #111); }
table.sortable thead th:not(.nosort)::after { content: "\2195"; margin-left: 6px; opacity: .3; font-size: .9em; }
table.sortable thead th[aria-sort=ascending]::after { content: "\25B2"; opacity: .9; }
table.sortable thead th[aria-sort=descending]::after { content: "\25BC"; opacity: .9; }

/* Driver: add a delivery, next trip */
.drv-row-static{cursor:default}
.drv-addcard,.drv-nexttrip{padding:10px 14px;margin-bottom:10px}
.drv-addcard{border:1.5px dashed var(--brand,#0b5f8a)}
.drv-results{display:grid;gap:6px;margin-top:8px}
.drv-result{display:block;width:100%;text-align:left;min-height:48px;padding:8px 12px;border:1px solid var(--border);border-radius:10px;background:#fff;font:inherit;color:inherit}
.drv-results-hint{margin:6px 0;color:var(--muted,#777);font-size:.9rem}
.drv-item{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:8px 0;border-top:1px solid var(--border)}
.drv-item-t{display:grid;gap:2px;min-width:0}
.drv-total{display:flex;justify-content:space-between;padding:10px 0 0;border-top:1px solid var(--border);margin-top:4px}
.drv-lbl{display:grid;gap:4px;font-weight:600}
.drv-card-h{font-weight:700;margin-bottom:4px}

/* Price warnings (R0, or not the customer's own price): both red */
.pw { display: block; font-size: 13px; font-weight: 700; line-height: 1.35; margin-top: 3px; white-space: normal; }
.pw-zero, .pw-special { color: #b42318; }
.pw-box { display: grid; gap: 2px; margin: 8px 0; padding: 10px 12px; border-radius: 10px; border: 2px solid #d92d20; background: #fef0ef; color: #7a140e; font-size: 14px; }
.pw-box[hidden] { display: none; }
.pw-box .pw-zero, .pw-box .pw-special { color: #b42318; }
.pw-sum { margin: 8px 0; padding: 9px 12px; border-radius: 8px; border: 1px solid #d92d20; background: #fef0ef; color: #912018; font-weight: 700; }
