/* SMH Depot - stylesheet
   Palette: slate ink, concrete grey, loading-bay yellow.
   Built for phones in bright godown light: large text, strong contrast. */

:root {
  --ink: #1D2731;
  --ink-2: #46535F;
  --concrete: #E7EAE8;
  --panel: #FFFFFF;
  --line: #C9D0D3;
  --line-soft: #DDE2E3;
  --bay: #F2B300;
  --bay-press: #D99F00;
  --go: #1D7346;
  --go-bg: #E3F1E8;
  --stop: #A8241B;
  --stop-bg: #FBE7E5;
  --warn-bg: #FFF4D1;
  --wh-itr: #0F6B6B;
  --wh-hrd: #4C43A0;
  --wh-other: #6B5A2E;

  --font: 'Mukta', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Devanagari', sans-serif;
  --font-head: 'Barlow Condensed', 'Arial Narrow', var(--font);

  --r-sm: 6px;
  --r-md: 10px;
  --tap: 48px;
  --pad: 16px;
  --top-h: 56px;
  font-size: 17px;
}
@media (min-width: 900px) { :root { font-size: 16px; --pad: 24px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.45;
  color: var(--ink);
  background: var(--concrete);
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
}
h1, h2, h3 { line-height: 1.15; margin: 0; }
h1 { font-family: var(--font-head); font-weight: 600; font-size: 1.85rem; letter-spacing: .01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--bay); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: .88rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Boot / centred screens ---------- */
.boot { display: grid; place-items: center; min-height: 100dvh; padding: 24px; text-align: center; color: var(--ink-2); }
.center-card {
  max-width: 420px; margin: 0 auto; padding: 28px var(--pad) 24px; background: var(--panel);
  border-radius: var(--r-md); border: 1px solid var(--line);
}

/* ---------- Top bar with the loading-bay stripe ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner { height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 8px 0 4px; }
.topbar::after {
  content: ''; display: block; height: 6px;
  background: repeating-linear-gradient(-45deg, var(--bay) 0 12px, var(--ink) 12px 24px);
}
.brand { font-family: var(--font-head); font-weight: 600; font-size: 1.3rem; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-family: var(--font); font-weight: 400; font-size: .8rem; opacity: .8; margin-left: 6px; }
.brand .b-short { display: none; }
@media (max-width: 599px) { .brand .b-full { display: none; } .brand .b-short { display: inline; } }
@media (min-width: 900px) { .topbar-inner { padding-left: 16px; } }
.pos-lines { display: grid; gap: 1px; font-size: .92rem; }
.pos-lines .p { color: var(--ink-2); margin-right: 4px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  border: 0; background: transparent; color: inherit; border-radius: var(--r-sm); cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.08); }

/* Warehouse chip and switcher */
.wh-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: #fff; background: var(--wh-other); white-space: nowrap;
}
.wh-chip[data-code="ITR"] { background: var(--wh-itr); }
.wh-chip[data-code="HRD"] { background: var(--wh-hrd); }
.wh-chip[data-code="ALL"] { background: transparent; border: 1.5px solid rgba(255,255,255,.7); }
.wh-switch { display: inline-flex; background: rgba(255,255,255,.1); border-radius: 999px; padding: 3px; gap: 2px; }
.wh-switch button {
  border: 0; background: transparent; color: #fff; font: inherit; font-size: .85rem; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; min-height: 36px;
}
.wh-switch button[aria-pressed="true"] { background: var(--bay); color: var(--ink); }
@media (max-width: 599px) { .topbar .wh-switch { display: none; } }
.wh-switch-mobile { display: none; margin: 0 0 14px; }
@media (max-width: 599px) {
  .wh-switch-mobile { display: flex; background: var(--ink); width: 100%; }
  .wh-switch-mobile button { flex: 1; }
}

/* ---------- Shell: sidebar on desktop, drawer on mobile ---------- */
.shell { display: block; }
.sidenav { display: none; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100dvh - var(--top-h) - 6px); }
  .sidenav { display: block; background: var(--panel); border-right: 1px solid var(--line); padding: 12px 8px; }
  .topbar .menu-btn { display: none; }
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list a {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 6px 12px;
  border-radius: var(--r-sm); text-decoration: none; color: var(--ink); font-weight: 600;
}
.nav-list a svg { width: 22px; height: 22px; flex: none; color: var(--ink-2); }
.nav-list a:hover { background: var(--concrete); }
.nav-list a[aria-current="page"] { background: var(--ink); color: #fff; }
.nav-list a[aria-current="page"] svg { color: var(--bay); }
.nav-group { margin: 14px 12px 4px; font-size: .8rem; color: var(--ink-2); font-weight: 600; }

dialog.drawer {
  margin: 0; height: 100dvh; max-height: 100dvh; width: min(86vw, 320px); border: 0; padding: 0;
  background: var(--panel); color: var(--ink);
}
dialog.drawer::backdrop { background: rgba(29,39,49,.55); }
.drawer-head { background: var(--ink); color: #fff; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
.drawer-head .who { font-weight: 700; }
.drawer-body { padding: 8px; overflow-y: auto; }

/* ---------- Page ---------- */
main:focus { outline: none; }
main { padding: var(--pad); padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); max-width: 1120px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.page-head h1 { flex: 1 1 auto; }
.page-head .back { margin-left: -12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--pad); margin-bottom: 16px; }
.panel > h2 { margin-bottom: 12px; }
.panel-note { background: var(--warn-bg); border: 1px solid #E9CF7A; border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 16px; }
.panel-note.bad { background: var(--stop-bg); border-color: #E7B0AA; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 8px 18px; border-radius: var(--r-sm);
  border: 1.5px solid var(--ink); background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { background: var(--concrete); }
.btn.primary { background: var(--bay); border-color: var(--bay); }
.btn.primary:hover { background: var(--bay-press); border-color: var(--bay-press); }
.btn.danger { color: var(--stop); border-color: var(--stop); }
.btn.danger:hover { background: var(--stop-bg); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--line-soft); }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Sticky save bar on long forms */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 10px; justify-content: flex-end;
}
.savebar .btn { flex: 1 1 0; max-width: 260px; }
@media (min-width: 900px) { .savebar { left: 236px; } }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px 18px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .wide { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: .95rem; }
.field .req::after { content: ' *'; color: var(--stop); }
.hint { font-size: .85rem; color: var(--ink-2); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: var(--tap); padding: 8px 12px;
  font: inherit; color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 3px solid rgba(242,179,0,.55); outline-offset: 0; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--stop); background: var(--stop-bg); }
.err-msg { display: none; color: var(--stop); font-size: .88rem; font-weight: 600; }
.field:has(:user-invalid) .err-msg { display: block; }
input[readonly] { background: var(--concrete); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }

/* Date field: typed DD-MM-YYYY with a calendar button */
.datefield { position: relative; display: flex; }
.datefield input[data-date] { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.datefield .cal {
  position: relative; flex: none; width: var(--tap); border: 1.5px solid var(--line); border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--concrete); display: grid; place-items: center; color: var(--ink);
}
.datefield .cal svg { width: 22px; height: 22px; pointer-events: none; }
.datefield .cal input[type=date] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; min-height: 0;
}

/* Opening balance grid in dealer form */
.ob-row { display: grid; grid-template-columns: 1fr; gap: 6px 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.ob-row:first-of-type { border-top: 0; }
.ob-row .prod { font-weight: 700; }
.ob-inputs { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.ob-mt { font-size: .9rem; color: var(--ink-2); }
@media (min-width: 700px) { .ob-row { grid-template-columns: 160px 1fr 120px; align-items: center; } }

/* ---------- Filters ---------- */
.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.filters .search { grid-column: 1 / -1; }
@media (min-width: 800px) { .filters { grid-template-columns: 2fr 1fr 1fr; } .filters .search { grid-column: auto; } }
.count-line { margin: 4px 2px 10px; color: var(--ink-2); font-size: .92rem; }

/* ---------- Lists: rows that become cards on phones ---------- */
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.list-head, .row { display: grid; gap: 4px 16px; padding: 12px 16px; align-items: center; }
.list-head { display: none; background: var(--concrete); font-size: .85rem; font-weight: 700; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.row { border-top: 1px solid var(--line-soft); text-decoration: none; color: inherit; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; font: inherit; cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: #F5F7F6; }
.row .title { font-weight: 700; }
.row .sub { color: var(--ink-2); font-size: .92rem; }
.row .cell-label { display: inline; color: var(--ink-2); font-size: .85rem; margin-right: 4px; }
@media (min-width: 800px) {
  .list-head { display: grid; }
  .row .cell-label { display: none; }
  .cols-dealers { grid-template-columns: 2.2fr 1.2fr 1.2fr 1.5fr 1fr; }
  .cols-users { grid-template-columns: 2fr 1.2fr 1.2fr 1.6fr 1fr; }
  .cols-masters { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .cols-transporters { grid-template-columns: 2fr 1.4fr 1.2fr 1fr; }
  .cols-audit { grid-template-columns: 150px 1.2fr 2.8fr; align-items: start; }
}
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); }
.empty .btn { margin-top: 12px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  border: 1.5px solid currentColor; white-space: nowrap; line-height: 1.5;
}
.badge.ok { color: var(--go); background: var(--go-bg); }
.badge.off { color: var(--stop); background: var(--stop-bg); }
.badge.warn { color: #7A5800; background: var(--warn-bg); }
.badge.neutral { color: var(--ink-2); }

/* Balance figures */
.bal { font-weight: 700; }
.bal.lift { color: var(--go); }
.bal.excess { color: var(--stop); }

/* ---------- Home tiles ---------- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
@media (min-width: 800px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
.tile .big { font-family: var(--font-head); font-weight: 600; font-size: 2.3rem; line-height: 1; }
.tile .lbl { color: var(--ink-2); font-weight: 600; font-size: .92rem; margin-top: 4px; }
.tile.alert { border-color: #E9CF7A; background: var(--warn-bg); }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.checklist li:first-child { border-top: 0; }
.checklist .tick { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-weight: 700; font-size: .9rem; }
.checklist .done .tick { background: var(--go); border-color: var(--go); color: #fff; }
.checklist .done .what { color: var(--ink-2); }

/* Balance table for dealer home */
.baltable { width: 100%; border-collapse: collapse; }
.baltable th, .baltable td { text-align: left; padding: 10px 6px; border-top: 1px solid var(--line-soft); vertical-align: top; }
.baltable th { font-size: .85rem; color: var(--ink-2); border-top: 0; }
.baltable td.r, .baltable th.r { text-align: right; }

/* ---------- Dialog (forms and confirms) ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0;
  border-radius: var(--r-md); color: var(--ink); background: var(--panel);
}
dialog.modal::backdrop { background: rgba(29,39,49,.55); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 12px 8px 12px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; max-height: calc(100dvh - 160px); }
.modal-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: #FAFBFA; }
@media (max-width: 599px) {
  dialog.modal { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .modal-body { max-height: none; flex: 1; }
  dialog.modal[open] { display: flex; flex-direction: column; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot .btn { flex: 1 1 0; }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 60; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none;
}
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-sm); font-weight: 600; border-left: 6px solid var(--bay); }
.toast.bad { border-left-color: #FF6B5E; }
.toast.good { border-left-color: #5BD08A; }

/* ---------- Audit ---------- */
.diff { margin: 4px 0 0; padding: 0; list-style: none; font-size: .92rem; }
.diff li { padding: 2px 0; }
.diff .from { color: var(--stop); text-decoration: line-through; }
.diff .to { color: var(--go); font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; }
.login-top { background: var(--ink); color: #fff; padding: 36px 24px 28px; padding-top: calc(36px + env(safe-area-inset-top, 0px)); }
.login-top::after { content: ''; display: block; height: 6px; margin: 22px -24px -28px; background: repeating-linear-gradient(-45deg, var(--bay) 0 12px, var(--ink) 12px 24px); }
.login-top .firm { font-family: var(--font-head); font-weight: 600; font-size: 2.1rem; line-height: 1.05; }
.login-top .place { opacity: .85; margin-top: 4px; }
.login-form { padding: 24px; max-width: 440px; width: 100%; margin: 0 auto; display: grid; gap: 16px; }
.login-foot { margin-top: auto; padding: 16px 24px 24px; text-align: center; color: var(--ink-2); font-size: .85rem; }

/* ---------- Phase 2: inward, stock ---------- */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 4px 2px 10px; }
.stock-section { margin-bottom: 18px; }
.stock-cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .stock-cards { grid-template-columns: repeat(3, 1fr); } }
.stock-card { background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--ink); border-radius: var(--r-md); padding: 12px 16px; }
.stock-card .prod { font-weight: 700; }
.stock-card .big { font-family: var(--font-head); font-weight: 600; font-size: 2.6rem; line-height: 1.05; margin-top: 2px; }
.stock-card .big.neg { color: var(--stop); }
.stock-card .lbl { color: var(--ink-2); font-size: .92rem; }
.stock-card .dmg { margin-top: 6px; font-size: .9rem; color: var(--ink-2); }
.stock-card .dmg.has { color: var(--stop); font-weight: 600; }
.stock-card .split { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: .9rem; align-items: center; }
.big-action { min-height: 60px; font-size: 1.15rem; margin-bottom: 16px; }
.big-action svg { width: 26px; height: 26px; }

.seg { border: 0; padding: 0; margin: 0; }
.seg legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: 6px; }
.seg legend.req::after { content: ' *'; color: var(--stop); }
.seg .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { flex: 1 1 0; min-width: 96px; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: 6px 12px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; font-weight: 700; cursor: pointer;
}
.seg label:hover span { border-color: var(--ink-2); }
.seg input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--bay); outline-offset: 2px; }
.seg:has(input:user-invalid) legend { color: var(--stop); }
.static { min-height: var(--tap); display: flex; align-items: center; }
.sub-grid { display: grid; gap: 14px 18px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .sub-grid { grid-template-columns: 1fr 1fr; } .sub-grid .wide { grid-column: 1 / -1; } }
.sub-grid p.hint { margin: -6px 0 0; }
.with-btn { display: flex; gap: 8px; }
.with-btn select { flex: 1; min-width: 0; }
.unit-in { display: flex; align-items: stretch; }
.unit-in input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.unit-in span { display: grid; place-items: center; padding: 0 12px; background: var(--concrete); border: 1.5px solid var(--line); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-weight: 600; color: var(--ink-2); min-width: 56px; }
.qty-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.summary-box { margin-top: 14px; background: var(--concrete); border-radius: var(--r-sm); padding: 12px 14px; display: grid; gap: 4px; }
.summary-box .good { color: var(--go); font-weight: 700; font-size: 1.1rem; }
.summary-box .bad { color: var(--stop); font-weight: 700; }

.filters-5 { grid-template-columns: 1fr 1fr; }
@media (max-width: 899px) { .filters-5 > :last-child { grid-column: 1 / -1; } }
@media (min-width: 900px) { .filters-5 { grid-template-columns: repeat(5, 1fr); } }
.totals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-bottom: 12px; }
.totals:empty { display: none; }
.totals > div { background: var(--panel); padding: 10px 14px; display: flex; flex-direction: column; }
.totals .k { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
.totals .v { font-family: var(--font-head); font-weight: 600; font-size: 1.6rem; line-height: 1.1; }
.totals .u { font-size: .85rem; color: var(--ink-2); }
.totals .good .v { color: var(--go); }
@media (min-width: 800px) { .totals { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 799px) { .totals .good { grid-column: 1 / -1; } }
@media (min-width: 800px) { .cols-inward { grid-template-columns: 1.2fr .9fr 1.7fr 1.6fr .7fr; } }
.row.cancelled .title { text-decoration: line-through; color: var(--ink-2); }
.row .badge { margin-left: 4px; }
.dl { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--ink-2); font-weight: 600; }
.dl dd { margin: 0; }
.dl .good-strong { color: var(--go); font-weight: 700; }
.history { list-style: none; margin: 6px 0 0; padding: 0; }
.history li { padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: .95rem; }
.history .from { color: var(--stop); text-decoration: line-through; }
.history .to { color: var(--go); font-weight: 600; }
.os-head, .os-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; align-items: start; }
.os-head { font-size: .85rem; color: var(--ink-2); font-weight: 700; margin-bottom: 6px; }
.os-row { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.os-row .prod { font-weight: 700; padding-top: 12px; }

/* ---------- Phase 3: dispatch ---------- */
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.big-actions .big-action { margin-bottom: 0; }
.seg.modes .opts { flex-direction: column; }
@media (min-width: 800px) { .seg.modes .opts { flex-direction: row; } }
.seg.modes label span { flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 10px 14px; }
.seg.modes label span small { font-weight: 400; font-size: .85rem; color: var(--ink-2); }
.seg.modes input:checked + span small { color: #DDE3E7; }
.mode-tag { display: inline-block; padding: 1px 9px; border-radius: var(--r-sm); font-size: .8rem; font-weight: 700; color: #fff; background: var(--ink-2); }
.mode-tag.mode-warehouse { background: var(--ink); }
.mode-tag.mode-railhead { background: #7A4E12; }
.mode-tag.mode-diverted { background: #2F5D8A; }
@media (min-width: 800px) { .cols-dispatch { grid-template-columns: 1.1fr 1.5fr 1.4fr 1.5fr 1.2fr; } }
.search-in { position: relative; }
.search-in svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-2); pointer-events: none; }
.search-in input { padding-left: 40px; }
.dealer-results { display: grid; gap: 6px; margin-top: 8px; }
.dealer-results .hint { margin: 4px 0 0; }
.dealer-hit { text-align: left; font: inherit; color: inherit; background: #fff; border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; min-height: var(--tap); cursor: pointer; }
.dealer-hit:hover, .dealer-hit:focus-visible { border-color: var(--ink); }
.dealer-hit .sub { color: var(--ink-2); font-size: .9rem; }
.dealer-chosen { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: var(--r-sm); background: #F7F9F8; }
.dealer-chosen .sub { color: var(--ink-2); font-size: .92rem; }
.prod-rows { display: grid; gap: 0; }
.prod-row { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.prod-row:first-child { border-top: 0; }
.prod-row .prod { font-weight: 700; }
.prod-row .prod-info { grid-column: 2; display: flex; justify-content: space-between; gap: 8px; font-size: .88rem; color: var(--ink-2); }
.prod-row .prod-info .over { color: var(--stop); font-weight: 700; }
@media (min-width: 700px) { .prod-row { grid-template-columns: 140px 220px 1fr; } .prod-row .prod-info { grid-column: auto; justify-content: flex-start; gap: 16px; } }
.unit-in.pre > span:first-child { border-left: 1.5px solid var(--line); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); min-width: 40px; }
.unit-in.pre input { border-radius: 0; }
.freight-amt { font-size: 1.1rem; }
.dealer-freight { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.dealer-freight .form-grid { margin-top: 8px; }
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.today-grid a { display: flex; flex-direction: column; text-decoration: none; color: inherit; background: var(--concrete); border-radius: var(--r-sm); padding: 10px 14px; }
.today-grid .v { font-family: var(--font-head); font-weight: 600; font-size: 2rem; line-height: 1.1; }
.today-grid .k { font-weight: 600; }
.today-grid .u { font-size: .85rem; color: var(--ink-2); }
.baltable tr.total td { border-top: 2px solid var(--ink); }
.dl .due { color: var(--stop); font-weight: 700; }
.scroll-x { overflow-x: auto; }

/* ---------- Phase 4: EPOD, shortages, returns ---------- */
.badge.info { color: #1F4E79; background: #E3EEF8; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--line); margin: 4px 0 14px; }
.tabs button { flex: none; font: inherit; font-weight: 700; color: var(--ink-2); background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 14px; min-height: var(--tap); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--bay); }
.tabs .count:not(:empty) { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--ink); color: #fff; font-size: .8rem; line-height: 1.6; text-align: center; }
.case { border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px; background: #FCFDFC; }
.case.cancelled { opacity: .65; }
.case-head { margin-bottom: 6px; }
.steps { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: grid; grid-template-columns: 120px 1fr; gap: 8px; align-items: start; padding-left: 12px; border-left: 3px solid var(--line); }
.steps .step-k { color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.steps .badge { white-space: normal; }
@media (max-width: 599px) { .steps li { grid-template-columns: 1fr; gap: 2px; } .steps .step-k { font-size: .82rem; } }
.epod-choice { display: grid; gap: 10px; margin-top: 8px; }
.epod-choice .big-action { margin-bottom: 0; }
.epod-line, .ret-line { padding: 12px 0; border-top: 1px solid var(--line-soft); }
.epod-line:first-child, .ret-line:first-child { border-top: 0; }
.epod-line-head { margin-bottom: 8px; }
.epod-inputs { display: grid; gap: 8px; grid-template-columns: 1fr; }
.epod-inputs label { font-weight: 600; font-size: .9rem; display: grid; gap: 4px; }
@media (min-width: 640px) { .epod-inputs { grid-template-columns: repeat(3, 1fr); } .epod-inputs.two { grid-template-columns: repeat(2, 1fr); } }
.epod-good { margin-top: 6px; font-size: .92rem; color: var(--go); }
.epod-good .bad, .bad { color: var(--stop); font-weight: 700; }
.epod-full { display: flex; align-items: center; gap: 8px; color: var(--go); font-size: 1.1rem; }
.epod-full svg { width: 26px; height: 26px; }
td.bad { color: var(--stop); font-weight: 700; }
.cards { display: grid; gap: 10px; }
@media (min-width: 800px) { .cards { grid-template-columns: 1fr 1fr; } }
.dcard { display: grid; gap: 4px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: inherit; }
.dcard.todo { border: 2px solid var(--bay); }
.dcard-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.dcard .sub { color: var(--ink-2); font-size: .92rem; }
.dcard-todo { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-weight: 700; color: #7A5800; }
.dcard-todo svg { width: 18px; height: 18px; }
.attn-list { display: grid; gap: 8px; margin-bottom: 16px; }
.attn { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--warn-bg); border: 1px solid #E9CF7A; color: var(--ink); text-decoration: none; margin-bottom: 10px; }
.attn-list .attn { margin-bottom: 0; }
.attn svg { width: 24px; height: 24px; flex: none; }
.attn b { font-family: var(--font-head); font-size: 1.4rem; margin-right: 4px; }
.attn.big { padding: 16px; font-size: 1.05rem; }
.attn.bad { background: var(--stop-bg); border-color: #E7B0AA; }
.inline-setting { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); }
.inline-setting input[type=text] { width: 64px; text-align: center; }
.inline-setting .check { min-height: 0; margin-left: auto; }
.row.overdue { background: #FFF9E6; }
.row a { text-decoration: none; color: inherit; }
.days { font-weight: 700; }
.days.late { color: var(--stop); }
@media (min-width: 800px) {
  .cols-epod { grid-template-columns: 1.1fr 2.2fr .7fr 1.3fr; }
  .cols-case { grid-template-columns: 1.2fr 2fr 1.3fr 1.2fr; }
}
.disp-options { display: grid; gap: 8px; }
.disp-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; cursor: pointer; }
.disp-opt input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ink); flex: none; }
.disp-opt:has(input:checked) { border-color: var(--ink); background: #F7F9F8; }
.disp-opt .sub { color: var(--ink-2); font-size: .9rem; }
.delivery-link { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.delivery-link h2 { display: inline; margin-right: 8px; }
.filters-6 { grid-template-columns: 1fr 1fr; }
@media (min-width: 1000px) { .filters-6 { grid-template-columns: repeat(6, 1fr); } }

/* ---------- Phase 5: stock ---------- */
.tabs a { flex: none; font-weight: 700; color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 14px; min-height: var(--tap); display: inline-flex; align-items: center; white-space: nowrap; }
.tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--bay); }
.section-head .spacer { flex: 1; }
.range-form { grid-template-columns: 1fr 1fr; }
.range-form .quick-range { grid-column: 1 / -1; }
.range-form .quick-range .btn { min-height: 38px; padding: 4px 12px; }
@media (min-width: 900px) { .range-form { grid-template-columns: 1fr 1fr 2fr; } .range-form .quick-range { grid-column: auto; } }
.stock-sum { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 10px; }
@media (min-width: 760px) { .stock-sum { grid-template-columns: repeat(3, 1fr); } }
.sum-card .total-line { margin-top: 6px; font-size: .95rem; }
.mv-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .92rem; }
.mv-table td { padding: 4px 0; border-top: 1px solid var(--line-soft); }
.mv-table td.r { text-align: right; }
.reg-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.reg-controls .field { min-width: 160px; }
.reg-controls .spacer { flex: 1; }
.reg-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); }
.reg-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.reg-table th, .reg-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.reg-table th { background: var(--concrete); font-size: .8rem; color: var(--ink-2); text-align: left; position: sticky; top: 0; }
.reg-table .r { text-align: right; }
.reg-table td.zero { color: #A9B2B8; }
.reg-table td.strong { font-weight: 700; }
.reg-table tfoot td { font-weight: 700; border-top: 2px solid var(--ink); background: #F7F9F8; }
@media (min-width: 800px) {
  .cols-transfer { grid-template-columns: 1.1fr 1.8fr .9fr 1.3fr 1.3fr; }
  .cols-adj { grid-template-columns: 1.3fr 1.6fr .8fr 1.4fr 1.6fr; }
}

/* ---------- Phase 6: billing, hisab, statement ---------- */
.lift { color: var(--go); }
.excess { color: var(--stop); }
.totals .lift .v { color: var(--go); }
.totals .excess .v { color: var(--stop); }
.pos-pill { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--concrete); color: var(--ink-2); white-space: nowrap; }
.pos-pill.lift { background: var(--go-bg); color: var(--go); }
.pos-pill.excess { background: var(--stop-bg); color: var(--stop); }
.pos-cards { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 8px; }
@media (min-width: 760px) { .pos-cards { grid-template-columns: repeat(3, 1fr); } }
.pos-card { background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--line); border-radius: var(--r-md); padding: 14px; }
.pos-card.lift { border-left-color: var(--go); color: inherit; }
.pos-card.excess { border-left-color: var(--stop); color: inherit; }
.pos-card .prod { font-weight: 800; font-size: 1.05rem; }
.pos-card .big { font-size: 2rem; font-weight: 800; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.pos-card.lift .big, .pos-card.lift .pos-label { color: var(--go); }
.pos-card.excess .big, .pos-card.excess .pos-label { color: var(--stop); }
.pos-card .pos-label { font-weight: 700; }
.mv-table tr.strong td { font-weight: 800; border-top: 2px solid var(--ink); }
.mv-table tr.sub td { color: var(--ink-2); font-size: .85rem; }
.stmt-filters { grid-template-columns: 1fr 1fr; }
.stmt-filters .stmt-actions { grid-column: 1 / -1; }
@media (min-width: 900px) { .stmt-filters { grid-template-columns: 1fr 1fr 1fr 1.6fr; } .stmt-filters .stmt-actions { grid-column: auto; } }
.stmt-table tr.open-row td { background: #F7F9F8; font-weight: 700; }
.stmt-table td.lift, .hisab-table td.lift { color: var(--go); }
.stmt-table td.excess, .hisab-table td.excess { color: var(--stop); }
.hisab-filters { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .hisab-filters { grid-template-columns: 1fr 1fr 1.6fr 1fr 1fr; } }
.hisab-table td:first-child, .hisab-table th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; min-width: 170px; white-space: normal; }
.hisab-table thead th:first-child { background: var(--concrete); }
.hisab-table tr.click { cursor: pointer; }
.hisab-table tr.click:hover td { background: #F7F9F8; }
.hisab-table .sub { font-size: .8rem; color: var(--ink-2); }
.hisab-table .zero { color: #A9B2B8; }
button.sort { background: none; border: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; padding: 6px 0; min-height: 36px; }
.badge.warn { background: var(--warn-bg); color: #7A5A00; }
.bill-filters { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .bill-filters { grid-template-columns: 1fr 1fr 2fr 1fr; } }
.bill-lines { display: grid; gap: 10px; margin: 8px 0 12px; }
.bill-line { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: #FBFCFB; }
.bill-line .pname { grid-column: 1 / -1; display: flex; gap: 8px; align-items: baseline; }
.bill-line .pname .sub { color: var(--ink-2); font-size: .85rem; }
@media (min-width: 760px) { .bill-line { grid-template-columns: 1.1fr 1fr 1fr 1.2fr; } .bill-line .pname { grid-column: auto; flex-direction: column; } }
.fr-totals .v.bad { color: var(--stop); }
.fr-totals .v { font-size: 1.2rem; word-break: break-word; }
@media (max-width: 799px) { .totals.four > .good { grid-column: auto; } }
.dealer-quick { margin-bottom: 14px; }
.dealer-quick .btn { flex: 1; justify-content: center; }
@media (min-width: 800px) {
  .cols-bill { grid-template-columns: 1.2fr 1.6fr 1.6fr 1fr 1fr; }
}

@media (min-width: 800px) { .totals.three { grid-template-columns: repeat(3, 1fr); } }
.hisab-table tfoot td:first-child { background: #F7F9F8; }
@media (max-width: 799px) { .totals.three > div:last-child { grid-column: 1 / -1; } }
@media (min-width: 800px) { .totals.four { grid-template-columns: repeat(4, 1fr); } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.chips button { font: inherit; font-weight: 700; font-size: .92rem; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips button:focus-visible { outline: 3px solid var(--bay); outline-offset: 2px; }

/* ---------- Phase 7: freight hisab ---------- */
.panel-note.warn-note { background: var(--warn-bg); border-color: #E8CF7A; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--line-soft); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list li.cancelled { color: var(--ink-2); text-decoration: line-through; }
.plain-list li.cancelled .badge, .plain-list li.cancelled .btn { text-decoration: none; }
.btn.small-btn { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.badge.pay-unpaid { background: var(--stop-bg); color: var(--stop); }
.badge.pay-part { background: var(--warn-bg); color: #7A5A00; }
.badge.pay-paid { background: var(--go-bg); color: var(--go); }
.badge.pay-cancelled { background: var(--concrete); color: var(--ink-2); }
.fr-range { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .fr-range { grid-template-columns: 220px 220px; } }
.trip-filters, .tds-filters, .adv-filters { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .trip-filters { grid-template-columns: 1fr 1fr 1.6fr 1fr 1.6fr; } .tds-filters { grid-template-columns: 220px 1fr; } .adv-filters { grid-template-columns: 260px; } }
.fr-table td:first-child, .fr-table th:first-child { min-width: 180px; white-space: normal; }
.fr-table td.excess { color: var(--stop); } .fr-table td.lift { color: var(--go); }
.fr-table tr.click { cursor: pointer; }
.fr-table tr.click:hover td { background: #F7F9F8; }
.stmt-sum.totals { margin-top: 4px; }
.mv-table.calc td { padding: 7px 0; }
.pay-info { background: #F7F9F8; border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 10px 12px; display: grid; gap: 4px; }
.quick-amt { margin-bottom: 12px; max-width: 420px; }
.pay-line { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.pay-line:last-child { border-bottom: 0; }
.pay-line .check span .sub { display: block; color: var(--ink-2); font-size: .85rem; }
.pay-line .amt { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.pay-line .amt input { max-width: 170px; text-align: right; font-variant-numeric: tabular-nums; }
@media (min-width: 760px) { .pay-line { grid-template-columns: 1fr 320px; align-items: center; } }
@media (min-width: 800px) {
  .cols-transporters2 { grid-template-columns: 1.8fr 1fr 1fr 1.3fr 1.2fr; }
  .cols-trip { grid-template-columns: 1fr 1.3fr 1.6fr 1.3fr 1.3fr; }
  .cols-adv { grid-template-columns: 1.4fr 1.3fr 1fr 1.1fr 1.3fr; }
  .cols-pay { grid-template-columns: 1fr 1.4fr 1.2fr 1.6fr .8fr; }
}
.tds-q td.excess { color: var(--stop); }
@media (max-width: 799px) {
  .totals.four .v, .totals.three .v { font-size: 1.2rem; overflow-wrap: anywhere; }
  .totals.four > div { padding: 8px 10px; }
}

/* ---------- Phase 8: wishes ---------- */
#topnote:empty { display: none; }
.wish-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #FFF6D6; border-bottom: 1px solid #E8CF7A;
  padding: 8px max(14px, env(safe-area-inset-left)) 8px 14px; color: var(--ink); font-size: .95rem; }
.wish-banner > svg { width: 22px; height: 22px; color: #B07800; flex: none; }
.wish-banner > span { flex: 1 1 220px; }
.wish-banner .icon-btn { margin-left: auto; }
.wish-card h2 svg, .wish-group h2 svg { width: 20px; height: 20px; vertical-align: -3px; color: #B07800; }
.wish-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.wish-row:last-child { border-bottom: 0; }
.wish-row .wish-ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--concrete); color: var(--ink-2); }
.wish-row .wish-ic svg { width: 20px; height: 20px; }
.wish-row.today .wish-ic { background: #FFE9A8; color: #8A5A00; }
.wish-row.late .wish-ic { background: var(--stop-bg); color: var(--stop); }
.wish-row .sub { font-size: .85rem; color: var(--ink-2); }
.wish-row .wa-btn { grid-column: 1 / -1; justify-self: start; }
@media (min-width: 700px) { .wish-row { grid-template-columns: 34px 1fr auto; } .wish-row .wa-btn { grid-column: auto; } }
.btn.wa-btn { background: #1F8F4E; border-color: #1F8F4E; color: #fff; }
.btn.wa-btn:hover { background: #18773F; }
.btn.wa-btn svg { color: #fff; }
.wish-group.today { border-left: 5px solid #E2A300; }
.wish-group.late { border-left: 5px solid var(--stop); }
.wish-group h2 .count { font-size: .85rem; background: var(--concrete); border-radius: 999px; padding: 1px 9px; vertical-align: 2px; }
.wish-done svg { width: 16px; height: 16px; color: var(--go); vertical-align: -3px; }
.plain-list li > svg { width: 16px; height: 16px; color: var(--go); }
.wish-hist { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.wish-hist .title svg { width: 16px; height: 16px; vertical-align: -2px; color: #B07800; }
.wish-msg { white-space: pre-wrap; background: #F7F9F8; border-radius: var(--r-sm); padding: 8px 10px; }
.wish-who { margin: 0 0 8px; }
.wa-bubble { background: #DCF8C6; border-radius: 10px 10px 10px 2px; padding: 10px 12px; margin-top: 4px; white-space: pre-wrap; max-width: 520px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
button.pulse { animation: pulse 1.4s ease-in-out 3; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242,183,5,.7); } 50% { box-shadow: 0 0 0 8px rgba(242,183,5,0); } }
@media (prefers-reduced-motion: reduce) { button.pulse { animation: none; outline: 3px solid var(--bay); } }

/* ---------- Phase 9A: orders, notifications ---------- */
.badge.ost-pending_approval, .badge.ost-sent_back { background: var(--warn-bg); color: #7A5A00; }
.badge.ost-approved, .badge.ost-loading, .badge.ost-partly_loaded { background: #E2ECF8; color: #1F4E8C; }
.badge.ost-fully_loaded, .badge.ost-delivered { background: var(--go-bg); color: var(--go); }
.badge.ost-rejected { background: var(--stop-bg); color: var(--stop); }
.badge.ost-closed, .badge.ost-cancelled { background: var(--concrete); color: var(--ink-2); }
.order-row { display: grid; gap: 3px; }
.order-row .o-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.order-row .sub { font-size: .85rem; color: var(--ink-2); }
.order-lines { display: grid; gap: 8px; margin: 8px 0 12px; }
.order-line { display: grid; grid-template-columns: 1fr 170px; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: #FBFCFB; }
.order-line .sub { color: var(--ink-2); font-size: .85rem; font-weight: 400; }
.order-line.over { border-color: var(--stop); background: var(--stop-bg); }
@media (max-width: 480px) { .order-line { grid-template-columns: 1fr 130px; } }
.order-actions { margin: 4px 0 12px; }
.approve-panel { border: 2px solid var(--bay); }
.ap-table .ap-in { width: 100px; text-align: right; font-variant-numeric: tabular-nums; min-height: 40px; }
td.changed { color: #8A5A00; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 3px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ''; position: absolute; left: -22px; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); border: 3px solid var(--bay); }
.timeline .t-when, .timeline .tl-when { font-size: .8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.truck-list li { display: block; }
.truck-list .sub { font-size: .85rem; color: var(--ink-2); margin-top: 2px; }
.icon-btn.bell { position: relative; }
.bell-count { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #D93A2B; color: #fff;
  font-size: .72rem; font-weight: 800; line-height: 18px; text-align: center; }
.bell-panel { max-width: 520px; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li button { display: grid; gap: 2px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft); padding: 10px 4px; font: inherit; color: inherit; cursor: pointer; }
.notif-list li.unread button { background: #FFF8E0; }
.notif-list li button:hover { background: #F7F9F8; }
.notif-list .nb { font-size: .9rem; }
.notif-list .nt { font-size: .78rem; color: var(--ink-2); }
.order-card h2 svg { width: 20px; height: 20px; vertical-align: -3px; }
.order-card h2 .count { font-size: .85rem; background: var(--concrete); border-radius: 999px; padding: 1px 9px; vertical-align: 2px; }
.order-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.order-counts a { display: grid; padding: 10px; border-radius: var(--r-sm); background: #F7F9F8; border: 1px solid var(--line-soft); text-decoration: none; color: inherit; }
.order-counts a b { font-size: 1.5rem; font-family: var(--font-head); }
.order-counts a span { font-size: .8rem; color: var(--ink-2); }
.order-counts a.hot { background: var(--warn-bg); border-color: #E8CF7A; }
.order-counts a.warn { background: var(--stop-bg); border-color: #E7B3AD; }
.order-mini { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: inherit; }
.order-mini:last-child { border-bottom: 0; }
.order-mini .sub { display: block; font-size: .85rem; color: var(--ink-2); }
.order-card.toload { border-left: 5px solid #1F4E8C; }
.assign-list { display: grid; gap: 4px; margin: 10px 0 80px; }
.assign-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-sm); cursor: pointer; }
.assign-item input { width: 20px; height: 20px; margin-top: 2px; }
.assign-item .sub { display: block; font-size: .8rem; color: #8A5A00; }
.sp-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.dealer-quick { flex-wrap: wrap; }

/* ---------- Phase 9B: push and SMS ---------- */
.push-block { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: var(--r-sm);
  background: #F7F9F8; border: 1px solid var(--line-soft); margin-bottom: 10px; font-size: .92rem; }
.push-block svg { width: 18px; height: 18px; vertical-align: -4px; }
.push-block.off { background: var(--warn-bg); border-color: #E8CF7A; }
.push-block.on { background: var(--go-bg); border-color: #A9D8B6; }
.push-block.blocked, .push-block.unsupported { background: var(--stop-bg); border-color: #E7B3AD; }
.sms-switch { font-size: 1.05rem; }
.sms-switch input { width: 22px; height: 22px; }
.var-list { margin: 4px 0 8px 18px; padding: 0; columns: 2; }
.sms-bubble { background: #EEF2F5; border-radius: 10px; padding: 10px 12px; margin-top: 4px; max-width: 560px; white-space: pre-wrap; }
.sms-login, .test-sms { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; max-width: 460px; }
.sms-login h3, .test-sms h3 { margin: 0 0 8px; font-size: 1rem; }
.sms-login { max-width: 560px; }
.sms-login .form-grid { margin-top: 8px; }
.badge.sms-sent, .badge.sms-test { background: var(--go-bg); color: var(--go); }
.badge.sms-failed, .badge.sms-no_mobile { background: var(--stop-bg); color: var(--stop); }
.badge.sms-queued, .badge.sms-sending { background: var(--warn-bg); color: #7A5A00; }
.badge.sms-off { background: var(--concrete); color: var(--ink-2); }
.sms-log .sms-msg { min-width: 260px; max-width: 420px; white-space: normal; }
.msg-btns { margin-top: 6px; }
.sms-state { margin-top: 4px; }

/* ---------- Phase 9C: CRM, leads, order dashboard ---------- */
.panel-note.good-note { background: var(--go-bg); border-color: #A9D8B6; color: var(--ink); }
.crm-row { display: block; }
.crm-row .crm-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crm-row .crm-top svg { width: 18px; height: 18px; color: var(--ink-2); }
.crm-row .crm-notes { margin: 6px 0; white-space: pre-wrap; }
.crm-row.late { border-left: 4px solid var(--stop); }
.fu-group.late h2 { color: var(--stop); }
.fu-group.today h2 { color: #7A5A00; }
.fu-card { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.fu-card svg { width: 26px; height: 26px; flex: none; }
.fu-card.late { background: var(--stop-bg); border-color: #E7B3AD; }
.fu-card.today { background: var(--warn-bg); border-color: #E8CF7A; }
.quick-dates { gap: 6px; }
.badge.lead-new { background: #E6EEF7; color: #1F4E79; }
.badge.lead-in_discussion { background: var(--warn-bg); color: #7A5A00; }
.badge.lead-converted { background: var(--go-bg); color: var(--go); }
.badge.lead-lost { background: var(--concrete); color: var(--ink-2); }
.lead-row .r b { font-size: 1.05rem; }
.dash-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.dash-card { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 12px; border-radius: var(--r-md); background: #fff;
  border: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); min-height: 92px; }
.dash-card span { font-size: .85rem; color: var(--ink-2); }
.dash-card b { font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; }
.dash-card.warn { background: var(--warn-bg); border-color: #E8CF7A; }
.dash-card.bad { background: var(--stop-bg); border-color: #E7B3AD; }
.dash-card.bad b { color: var(--stop); }
.dash-card.ok b { color: var(--go); }
.crm-filters { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 380px) { .dash-cards { grid-template-columns: 1fr; } .dash-card { min-height: 0; flex-direction: row; align-items: center; } }

/* ---------- Phase 10A: site customers ---------- */
.gps-box { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: #F7F9F8; border: 1px solid var(--line-soft); }
.gps-box svg { width: 18px; height: 18px; vertical-align: -3px; }
.gps-box.ok { background: var(--go-bg); border-color: #A9D8B6; }
.gps-box.bad { background: var(--stop-bg); border-color: #E7B3AD; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line-soft); display: block; background: #eee; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; }
.badge.cst-new { background: #E6EEF7; color: #1F4E79; }
.badge.cst-follow_up { background: var(--warn-bg); color: #7A5A00; }
.badge.cst-interested { background: #FCE8D6; color: #8A4B08; }
.badge.cst-converted { background: var(--go-bg); color: var(--go); }
.badge.cst-lost { background: var(--stop-bg); color: var(--stop); }
.badge.cst-completed { background: var(--concrete); color: var(--ink-2); }
.badge.int-hot { background: var(--stop-bg); color: var(--stop); }
.badge.int-warm { background: var(--warn-bg); color: #7A5A00; }
.badge.int-cold { background: #E6EEF7; color: #1F4E79; }
.badge.bad-badge { background: var(--stop-bg); color: var(--stop); }
a.badge { text-decoration: none; }
.cust-row { display: flex; gap: 10px; align-items: center; }
.cust-row .cust-main { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.cust-row .r { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.cust-search { margin-bottom: 12px; }
.dl dd svg, .timeline a svg, .panel-note svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 3px; }
.tl-item .tl-notes { margin: 4px 0; white-space: pre-wrap; }
.tl-item.move .tl-what { color: var(--ink-2); }
.rate-change { background: var(--warn-bg); border-radius: 6px; padding: 2px 6px; display: inline-block; }
.move-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; position: sticky; top: 64px; z-index: 5; }
.pick-wrap { display: flex; align-items: center; gap: 8px; }
.pick-wrap .pick { width: 22px; height: 22px; flex: none; }
.pick-wrap > .row { flex: 1; }

/* ---------- Phase 10B: site visits dashboard ---------- */
.dash-cards.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .dash-cards.four { grid-template-columns: repeat(2, 1fr); } }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; margin: 6px 0 8px; }
.site-map { height: 62vh; min-height: 320px; border-radius: var(--r-md); border: 1px solid var(--line-soft); overflow: hidden; background: #E8ECEA; }
.site-map .leaflet-popup-content { font-size: .9rem; line-height: 1.45; }
.reg-table tr.ours td { background: #FFF8E1; }
.share-bar { height: 5px; background: var(--concrete); border-radius: 3px; margin-top: 3px; min-width: 60px; }
.share-bar span { display: block; height: 100%; background: var(--bay); border-radius: 3px; }
.mkt-areas summary { cursor: pointer; font-weight: 600; margin: 10px 0 4px; min-height: 44px; display: flex; align-items: center; }
.sp-head { font-size: 1rem; margin: 12px 0 6px; }
.small-seg { display: flex; gap: 4px; }
.btn-row.quick-dates .btn[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- Phase 11A: SMS messages ---------- */
.sms-tpl { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 14px; }
.sms-tpl .tpl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }
.sms-tpl .tpl-head h3 { margin: 0; font-size: 1.02rem; }
.sms-tpl .tpl-head .check { min-height: 44px; }
.sms-switches td input[type=checkbox] { width: 22px; height: 22px; }
.sms-switches th { white-space: normal; min-width: 70px; }

/* Printing */
@media print {
  .order-actions, #approvebox, #topnote, .topbar, .sidenav, .savebar, .btn, .filters, .tabs, .reg-controls, .wh-switch, .page-head .btn-row, .chips, .icon-btn.back { display: none !important; }
  .pos-cards { grid-template-columns: repeat(3, 1fr); }
  .hisab-table td:first-child, .hisab-table th:first-child { position: static; }
  .reg-table { font-size: 9pt; }
  body { background: #fff; }
  main { padding: 0; }
}

/* =====================================================================
   SMH brand theme (cosmetic only). Colours are taken from the SMH logo:
   navy mountain mark, red "smh" letters, blue tagline, near-black rule.
   Placed last so it overrides the earlier theme without changing layout.
   ===================================================================== */
:root {
  --brand-navy: #2B3E70;
  --brand-navy-press: #22325C;
  --brand-navy-tint: #E4E9F3;
  --brand-red: #BE3842;
  --brand-blue: #2A6ABC;
  --ink: #1C2333;
  --ink-2: #4A5468;
  --concrete: #EEF1F6;
  --line: #C8CFDB;
  --line-soft: #DDE2EB;
  /* the old accent now follows the brand everywhere it was used */
  --bay: #2B3E70;
  --bay-press: #22325C;
}
:focus-visible, .seg input:focus-visible + span, .chips button:focus-visible { outline-color: var(--brand-blue); }
h1 { color: var(--brand-navy); }

/* Header: white, with the logo and the navy + red rule from the logo */
.topbar { background: #fff; color: var(--brand-navy); }
.topbar::after { height: 5px; background: linear-gradient(var(--brand-navy) 0 3px, var(--brand-red) 3px 5px); }
.topbar .icon-btn:hover { background: var(--concrete); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--brand-navy); }
.brand-logo { height: 36px; width: auto; flex: none; display: block; }
.brand small { color: var(--ink-2); opacity: 1; margin-left: 0; }
.brand .b-full, .brand .b-short { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 599px) { .brand .b-short { display: none; } .brand-logo { height: 32px; } }
@media (max-width: 339px) { .brand small { display: none; } }
.bell-count { background: var(--brand-red); }

/* Warehouse chip and switch on the white header */
.wh-chip[data-code="ALL"] { border-color: var(--brand-navy); color: var(--brand-navy); }
.wh-switch { background: var(--concrete); }
.wh-switch button { color: var(--brand-navy); }
.wh-switch button[aria-pressed="true"] { background: var(--brand-navy); color: #fff; }
@media (max-width: 599px) { .wh-switch-mobile { background: var(--concrete); } }

/* Menu: the open page is navy with a red edge */
.nav-list a[aria-current="page"] { background: var(--brand-navy); color: #fff; box-shadow: inset 4px 0 0 var(--brand-red); }
.nav-list a[aria-current="page"] svg { color: #fff; }
.nav-list a:hover:not([aria-current="page"]) { background: var(--brand-navy-tint); }

/* Buttons: primary is SMH navy with white text */
.btn.primary { color: #fff; }
.btn.primary:hover { color: #fff; }
.btn.primary { background: var(--brand-navy); border-color: var(--brand-navy); }
.btn.primary:hover { background: var(--brand-navy-press); border-color: var(--brand-navy-press); }

/* Small accents */
.toast { border-left-color: var(--brand-red); }
.tabs button[aria-selected="true"], .tabs a[aria-selected="true"] { color: var(--brand-navy); }

/* Login: full logo on white, the same navy + red rule */
.login-top { background: #fff; color: var(--brand-navy); text-align: center; padding-bottom: 22px; }
.login-top::after { margin: 22px -24px -22px; height: 5px; background: linear-gradient(var(--brand-navy) 0 3px, var(--brand-red) 3px 5px); }
.login-logo { display: block; width: min(300px, 76vw); height: auto; margin: 0 auto 14px; }
.login-top .firm { font-size: 1.55rem; color: var(--brand-navy); }
.login-top .place { color: var(--ink-2); opacity: 1; }

/* Selected choices and the menu header in SMH navy */
.seg input:checked + span { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; }
.drawer-head { background: var(--brand-navy); box-shadow: inset 0 -3px 0 var(--brand-red); }

/* Login logo: proportionate size on every screen */
.login-top { padding-top: calc(26px + env(safe-area-inset-top, 0px)); padding-bottom: 18px; }
.login-top::after { margin-bottom: -18px; }
.login-logo { width: clamp(140px, 42vw, 190px); margin-bottom: 10px; }
.login-top .firm { font-size: 1.45rem; }
