/* ---------- breakpoints (D-005) — literal values only, @media cannot use var()
   phone   (max-width: 480px)   1 column everything, form-grid 1 col
   mobile  (max-width: 768px)   app bar / cards / sheets
   tablet  (max-width: 1024px)  grids 2 col, sidebar visible
   desktop > 1024px             v1 layout
   touch   (pointer: coarse)    44px targets · hover only inside (hover: hover) */
:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e1e5eb;
  --border-strong: #c9d0da;
  --text: #16202c;
  --text-2: #4d5a6a;
  --muted: #7a8696;
  --brand: #1f3a5f;
  --brand-2: #2a78d6;
  --brand-soft: #e8f0fb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e8ebef;
  --ok: #14804a;   --ok-bg: #e5f5ec;
  --warn: #a15c00; --warn-bg: #fff3dc;
  --err: #c0342f;  --err-bg: #fdeceb;
  --info: #3d5a80; --info-bg: #eaf0f7;
  --st-booking: #6b7785;  --st-booking-bg: #eef0f3;
  --st-onhand: #0f7c86;   --st-onhand-bg: #e1f3f4;
  --st-planned: #5a45b5;  --st-planned-bg: #eeebfa;
  --st-handover: #a35a00; --st-handover-bg: #fdf0dc;
  --st-loaded: #17803d;   --st-loaded-bg: #e3f4e8;
  --st-cancelled: #b3312d; --st-cancelled-bg: #fbe9e8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --sidebar: 228px;
  --shell-bg: #14263d;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111418; --surface: #1a1e24; --surface-2: #20252c; --border: #2c323b; --border-strong: #3a424d;
    --text: #eef1f5; --text-2: #b7c0cc; --muted: #8791a0; --brand: #9cc0ee; --brand-2: #3987e5; --brand-soft: #1d2a3b;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2a3038;
    --ok: #5fd08f; --ok-bg: #173424; --warn: #f0b451; --warn-bg: #3a2c12; --err: #ff8a85; --err-bg: #3d1c1b;
    --info: #9cc0ee; --info-bg: #1d2a3b;
    --st-booking: #b3bdc9; --st-booking-bg: #262c34; --st-onhand: #5cc9d2; --st-onhand-bg: #14353a;
    --st-planned: #aa9cf2; --st-planned-bg: #2a2545; --st-handover: #f0b451; --st-handover-bg: #3a2c12;
    --st-loaded: #5fd08f; --st-loaded-bg: #173424; --st-cancelled: #ff8a85; --st-cancelled-bg: #3d1c1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--brand-2); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; } }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

/* ---------- layout */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--shell-bg); color: #d6e0ec; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand { padding: 18px 18px 14px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; background: #2a78d6; display: grid; place-items: center; color: #fff; font-weight: 800; }
.brand-name { font-weight: 700; color: #fff; line-height: 1.1; }
.brand-sub { font-size: 11px; color: #9fb1c6; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { color: #c9d5e3; padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
@media (hover: hover) { .nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; } }
.nav a.active { background: #2a78d6; color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav .badge-count { margin-left: auto; background: #c0342f; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 6px; }
.userbox { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.userbox .name { color: #fff; font-weight: 600; }
.userbox button { margin-top: 8px; }
.main { flex: 1; min-width: 0; padding: 22px max(26px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(26px, env(safe-area-inset-left)); }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.appbar, .tabbar, .drawer-backdrop { display: none; }

/* mobile shell (D-006): top app bar + off-canvas drawer + bottom tab bar */
.appbar {
  position: sticky; top: 0; z-index: 30; align-items: center; gap: 4px; background: var(--shell-bg); color: #fff;
  min-height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
}
.appbar-btn { width: 44px; height: 44px; flex: none; border: none; background: transparent; color: inherit; font-size: 22px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.appbar-btn:active { background: rgba(255,255,255,.12); }
.appbar-title { flex: 1; min-width: 0; font-size: 17px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.appbar-actions:empty { display: none; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(10, 18, 30, .5); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }
body.drawer-open { overflow: hidden; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -1px 3px rgba(16, 24, 40, .06);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tab {
  min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); background: none; border: none; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; padding: 6px 2px;
  -webkit-tap-highlight-color: transparent;
}
.tab, .tab:hover { text-decoration: none; }
.tab-ico { position: relative; font-size: 20px; line-height: 1; }
.tab-label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.on { color: var(--brand-2); }
.tab .badge-count { position: absolute; top: -6px; left: 60%; min-width: 18px; background: var(--err); color: #fff; border-radius: 9px; padding: 1px 5px; font-size: 10px; font-weight: 700; line-height: 1.3; text-align: center; }

@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .appbar { display: flex; }
  .tabbar { display: grid; }
  .drawer-backdrop { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: min(84vw, 300px); height: 100vh; height: 100dvh;
    transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
  }
  .sidebar.open { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
  .brand { padding-top: max(18px, env(safe-area-inset-top)); }
  .nav a { min-height: 44px; }
  .userbox { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .userbox .btn.sm { min-height: 44px; }
  .main { padding: 16px max(16px, env(safe-area-inset-right)) calc(80px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .sidebar.open, .drawer-backdrop { transition: none; } }

/* ---------- surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1024px) { .g5, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) { .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; } }
.mt { margin-top: 16px; }

/* ---------- stat tiles */
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.tile .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile .delta.up { color: var(--ok); } .tile .delta.down { color: var(--err); }
@media (max-width: 768px) {
  .grid.tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tiles .tile { padding: 12px; }
  .tiles .tile .value { font-size: 22px; }
}

/* pipeline */
.pipeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.pipe { position: relative; padding: 14px 16px 14px 22px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.pipe:first-child { border-radius: var(--radius) 0 0 var(--radius); padding-left: 16px; }
.pipe:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.pipe + .pipe { border-left: none; }
@media (hover: hover) { .pipe:hover { background: var(--surface-2); } }
.pipe .step { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; }
.pipe .count { font-size: 28px; font-weight: 750; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.pipe .meta { font-size: 12px; color: var(--muted); }
.pipe .arrow { position: absolute; right: -9px; top: 50%; transform: translateY(-50%); z-index: 1; width: 18px; height: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 50%; display: grid; place-items: center; font-size: 10px; color: var(--muted); }
@media (max-width: 1024px) { .pipeline { grid-template-columns: 1fr; } .pipe, .pipe:first-child, .pipe:last-child { border-radius: 0; border-left: 1px solid var(--border); } .pipe + .pipe { border-top: none; } .pipe .arrow { display: none; } }
@media (max-width: 768px) {
  .pipeline { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain; margin: 0 -16px; padding: 0 16px 2px; scroll-padding: 0 16px; }
  .pipeline::-webkit-scrollbar { display: none; }
  .pipe, .pipe:first-child, .pipe:last-child { flex: 0 0 min(168px, 46%); min-width: 0; scroll-snap-align: start; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--border); }
  .pipe + .pipe { border: 1px solid var(--border); }
  .pipe:active { background: var(--surface-2); }
  .pipe .count { font-size: 24px; }
  .pipe .badge { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dash-last { margin-bottom: 10px; }
}

/* ---------- status badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-BOOKING { color: var(--st-booking); background: var(--st-booking-bg); }
.st-ONHAND { color: var(--st-onhand); background: var(--st-onhand-bg); }
.st-PLANNED { color: var(--st-planned); background: var(--st-planned-bg); }
.st-HANDOVER { color: var(--st-handover); background: var(--st-handover-bg); }
.st-LOADED { color: var(--st-loaded); background: var(--st-loaded-bg); }
.st-CANCELLED { color: var(--st-cancelled); background: var(--st-cancelled-bg); }
.dot-st { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.flag { display: inline-flex; gap: 6px; align-items: flex-start; padding: 3px 8px; border-radius: 6px; font-size: 12px; margin: 2px 4px 2px 0; }
.flag .fi { font-weight: 800; }
.flag.error { background: var(--err-bg); color: var(--err); }
.flag.warn { background: var(--warn-bg); color: var(--warn); }
.flag.info { background: var(--info-bg); color: var(--info); }
.flag-count { display: inline-flex; gap: 4px; align-items: center; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
@media (pointer: coarse) { .flag-count { min-height: 44px; min-width: 44px; justify-content: center; } }
.pill { display: inline-block; min-width: 20px; text-align: center; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 6px; }
.pill.error { background: var(--err-bg); color: var(--err); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
/* countdown chips (cutoff / ETD) */
.cd { display: inline-block; border-radius: 10px; font-size: 12px; font-weight: 600; padding: 2px 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cd-ok { background: var(--ok-bg); color: var(--ok); }
.cd-warn { background: var(--warn-bg); color: var(--warn); }
.cd-crit, .cd-passed { background: var(--err-bg); color: var(--err); }
.cd-passed { font-weight: 700; }
.cd-plain { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.cd-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cd-head { margin: -8px 0 14px; }
.cd-head .cd { font-size: 13px; padding: 4px 10px; border-radius: 12px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); font-weight: 650; background: var(--surface-2); padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
@media (hover: hover) { .tbl tbody tr:hover td { background: var(--surface-2); } }
.tbl.sticky-first th:first-child, .tbl.sticky-first td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
.tbl.sticky-first thead th:first-child { z-index: 2; background: var(--surface-2); }
@media (hover: hover) { .tbl.sticky-first tbody tr:hover td:first-child { background: var(--surface-2); } }
.tbl tr.clickable { cursor: pointer; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.tbl .chk { width: 32px; }
/* pattern B: stackTable() rows become cards on mobile */
@media (max-width: 768px) {
  .table-wrap:has(> .tbl.stack) { overflow: visible; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tfoot, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack thead { display: none; }
  .tbl.stack tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
  .tbl.stack tr:last-child { margin-bottom: 0; }
  .tbl.stack td { display: grid; grid-template-columns: minmax(88px, 35%) minmax(0, 1fr); gap: 10px; padding: 5px 0; border: none; overflow-wrap: anywhere; white-space: normal; }
  .tbl.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  .tbl.stack td:not([data-label]), .tbl.stack td[data-label=""] { grid-template-columns: minmax(0, 1fr); }
  .tbl.stack td:not([data-label])::before, .tbl.stack td[data-label=""]::before { display: none; }
  .tbl.stack td + td { border-top: 1px solid var(--border); }
  .tbl.stack td.row-act .btn { width: 100%; min-height: 44px; }
}
@media (max-width: 768px) and (hover: hover) { .tbl.stack tbody tr:hover td { background: none; } }
.cell-2 { color: var(--muted); font-size: 12px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.ellip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- pattern A: mobile card list (shipments, MAWBs, MAWB→HAWBs) */
.ship-mobile { display: flex; flex-direction: column; gap: 12px; }
.ship-mobile .tabs { margin: 0 -16px; padding: 0 16px; }
.list-tools { display: flex; align-items: center; gap: 8px; }
.ship-mobile .list-tools .btn.sm { flex: none; margin-left: auto; min-height: 44px; }
.sum-strip { flex: 1; display: flex; gap: 14px; min-width: 0; }
.sum-strip span { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); line-height: 1.3; }
.sum-strip b { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.mcard-list { display: flex; flex-direction: column; gap: 12px; }
.mcard { position: relative; display: flex; flex-direction: column; gap: 4px; min-height: 72px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mcard:active { background: var(--surface-2); }
.mcard-top, .mcard-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mcard-top .spacer { flex: 1; }
.mcard-top .flag-count { margin: -10px -8px -10px 0; }
.mcard-id { font-size: 15px; }
.mcard-line { justify-content: space-between; font-size: 13px; }
.mcard-line.cell-2 { font-size: 12px; }
.mcard-nums { font-size: 13px; font-variant-numeric: tabular-nums; }
.mcard-flags { display: flex; flex-wrap: wrap; min-width: 0; margin-top: 2px; }
.mcard-flags .flag { min-width: 0; overflow-wrap: anywhere; }
.exc-tools { display: flex; align-items: center; gap: 10px; }
.exc-tools > span { flex: 1; min-width: 0; }
.exc-tools select { flex: none; width: auto; max-width: 55%; }
.exc-sum { margin: 0 -16px; padding: 0 16px; }
.exc-sum .flag { flex: none; white-space: nowrap; align-items: center; margin: 0; }
.mcard-list.selecting .mcard { padding-left: 46px; }
.mcard-list.selecting .mcard::before { content: ""; position: absolute; left: 14px; top: 14px; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border-strong); background: var(--surface); }
.mcard.sel { border-color: var(--brand-2); background: var(--brand-soft); }
.mcard-list.selecting .mcard.sel::before { background: var(--brand-2); border-color: var(--brand-2); box-shadow: inset 0 0 0 3px var(--surface); }
.more-box { display: flex; justify-content: center; }
.more-box:empty { display: none; }
.load-more { width: 100%; justify-content: center; min-height: 44px; }
.select-bar[hidden], .fab[hidden] { display: none; }
.select-bar .sel-n { flex: 1; }
.select-bar .sel-x { min-width: 44px; min-height: 44px; justify-content: center; }
.select-bar .btn.primary { min-height: 44px; }
.check-row { min-height: 44px; font-weight: 600; }
.list-title { font-size: 15px; margin: 0 0 10px; }
.c-err { color: var(--err); }
.c-warn { color: var(--warn); }

/* ---------- forms & buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
@media (hover: hover) { .btn:hover { background: var(--surface-2); text-decoration: none; } }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
@media (hover: hover) { .btn.primary:hover { filter: brightness(1.07); } }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger.solid { background: var(--err); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.sidebar .btn { background: transparent; color: #c9d5e3; border-color: rgba(255,255,255,.2); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn + .btn { border-left: none; }
@media (pointer: coarse) {
  .btn { min-height: 44px; justify-content: center; }
  .btn.sm { min-height: 36px; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .tabs button { min-height: 44px; }
}
@media (pointer: coarse) and (max-width: 768px) { .btn.sm { min-height: 44px; min-width: 44px; } }
.btn-group .btn.on { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg button { min-height: 44px; padding: 6px 4px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.seg button.on { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.seg button.danger { color: var(--err); }
.seg button.danger.on { background: var(--err); border-color: var(--err); color: #fff; }
.seg-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.dt-now { display: flex; gap: 8px; }
.dt-now input { flex: 1; }
.dt-now .btn { flex: none; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand-2) 40%, transparent); border-color: var(--brand-2); }
textarea { resize: vertical; min-height: 60px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
label.field input, label.field select, label.field textarea { font-weight: 400; font-size: 13.5px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span4 { grid-column: 1 / -1; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }
@media (max-width: 1024px) { .form-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) { input, select, textarea, label.field input, label.field select, label.field textarea { font-size: 16px; } }
@media (max-width: 768px) { .form-grid.m1 { grid-template-columns: 1fr; } .form-grid.m1 .span2 { grid-column: auto; } }
@media (max-width: 480px) { .form-grid, .form-grid.cols-2 { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; } }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { width: 260px; max-width: 100%; }
.rep-filters .date-nav input[type=date] { width: auto; }
@media (max-width: 768px) {
  .rep-filters .period-btns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .rep-filters .period-btns .btn { padding-left: 4px; padding-right: 4px; }
  .rep-filters .date-nav, .rep-filters .date-range { width: 100%; flex-wrap: nowrap; }
  .rep-filters .date-nav input[type=date], .rep-filters .date-range input[type=date] { flex: 1; min-width: 0; }
  .rep-filters .date-nav .btn { min-width: 44px; }
}
.filter-bar { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 8px; align-items: center; }
.filter-row input[type=search] { flex: 1; width: auto; }
.filter-btn { flex: none; }
.filter-btn .pill.count { background: var(--brand-2); color: #fff; }
.chips-scroll { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 6px 4px 12px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--brand-soft); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.chip-x { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 11px; color: var(--text-2); }
@media (pointer: coarse) { .chip { min-height: 44px; } }
.tabs { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain; box-shadow: inset 0 -1px var(--border); padding: 0 12px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; white-space: nowrap; scroll-snap-align: start; background: none; border: none; padding: 10px 12px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--brand-2); border-bottom-color: var(--brand-2); }
.tabs .cnt { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 6px; margin-left: 4px; color: var(--muted); }

/* ---------- detail */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dt { font-size: 12px; } .kv dd { margin-bottom: 8px; } }
.stepper { display: flex; gap: 0; margin: 4px 0 8px; }
.stp { flex: 1; text-align: center; position: relative; padding-top: 30px; font-size: 12px; }
.stp::before { content: ""; position: absolute; top: 11px; left: 0; right: 0; height: 3px; background: var(--border); }
.stp:first-child::before { left: 50%; } .stp:last-child::before { right: 50%; }
.stp.done::before { background: var(--ok); }
.stp .c { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 3px solid var(--border-strong); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--muted); z-index: 1; }
.stp.done .c { background: var(--ok); border-color: var(--ok); color: #fff; }
.stp.current .c { border-color: var(--brand-2); color: var(--brand-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-2) 20%, transparent); }
.stp .t { font-weight: 650; }
.stp .d { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.dwell { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-top: 6px; }
.pre-line { white-space: pre-line; }
@media (max-width: 768px) {
  /* vertical stepper: dot + label + time per row */
  .stepper { flex-direction: column; margin: 0 0 4px; }
  .stp { display: flex; align-items: center; gap: 12px; text-align: left; min-height: 40px; padding: 0 0 0 36px; font-size: 14px; }
  .stp::before { top: 0; bottom: 0; left: 10.5px; right: auto; width: 3px; height: auto; }
  .stp:first-child::before { top: 50%; left: 10.5px; }
  .stp:last-child::before { bottom: 50%; right: auto; }
  .stp .c { top: 50%; left: 0; transform: translateY(-50%); }
  .stp .t { flex: 1; }
  .stp .d { margin-top: 0; font-size: 12.5px; white-space: nowrap; }
  .dwell { justify-content: flex-start; gap: 6px; margin-top: 10px; }
  .dwell-item { padding: 4px 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
  .sib-chips { margin: 2px 0; }
}
/* accordion sections (mobile detail & form) */
.acc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.acc + .acc, .card + .acc, .acc + .card { margin-top: 12px; }
.grid > .acc { margin-top: 0; }
.acc > summary { list-style: none; display: flex; align-items: center; min-height: 48px; padding: 0 16px; font-size: 15px; font-weight: 650; -webkit-tap-highlight-color: transparent; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: "›"; margin-left: auto; font-size: 20px; color: var(--muted); transform: rotate(90deg); transition: transform .15s; }
.acc[open] > summary { border-bottom: 1px solid var(--border); }
.acc[open] > summary::after { transform: rotate(-90deg); }
.acc-body { padding: 14px 16px; }
.acc-list { gap: 12px; }
@media (prefers-reduced-motion: reduce) { .acc > summary::after { transition: none; } }
/* MAWB readiness checklist: tap rows (desktop = row of tiles, mobile = one per line) */
.checklist { margin-top: 12px; }
.check-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.check-head h2 { margin: 0; }
.check-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.check-item { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; -webkit-tap-highlight-color: transparent; }
button.check-item { cursor: pointer; }
.check-item:disabled { opacity: .6; }
.check-box { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid var(--border); border-radius: 50%; font-weight: 800; font-size: 14px; }
.check-text { display: flex; flex-direction: column; min-width: 0; }
.check-item.done { border-color: var(--ok); background: var(--ok-bg); }
.check-item.done .check-box { border-color: var(--ok); background: var(--ok); color: var(--surface); }
.check-item.late { border-color: var(--warn); background: var(--warn-bg); }
@media (hover: hover) { button.check-item:hover { border-color: var(--brand-2); } }
@media (max-width: 768px) {
  .check-list { grid-template-columns: 1fr; }
  .check-item { min-height: 60px; padding: 10px 12px; }
  .check-item b { font-size: 15px; }
}
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--border); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); }
.timeline .when { color: var(--muted); font-size: 12px; }

/* ---------- modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(10, 18, 30, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { width: min(960px, 100%); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; flex: none; position: relative; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex: none; background: var(--surface); position: sticky; bottom: 0; }
@media (max-width: 768px) {
  .modal-back { place-items: end stretch; padding: 0 0 var(--kb, 0px); }
  .modal, .modal.wide { width: 100%; max-height: calc(92vh - var(--kb, 0px)); max-height: calc(92dvh - var(--kb, 0px)); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.25); animation: sheet-up .22s ease-out; }
  .modal.full { height: calc(100vh - var(--kb, 0px)); height: calc(100dvh - var(--kb, 0px)); max-height: none; border-radius: 0; }
  .modal-head { padding: 18px 16px 12px; }
  .modal-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border-strong); }
  .modal.full .modal-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .modal.full .modal-head::before { display: none; }
  .modal-head .modal-x { min-width: 44px; min-height: 44px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none !important; } }
.popover { position: fixed; z-index: 70; max-width: min(320px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; }
.flag-list { display: flex; flex-direction: column; align-items: flex-start; }
.flag-list .flag { margin: 2px 0; }
.menu { display: flex; flex-direction: column; min-width: 180px; margin: -4px; }
.menu-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; border: none; border-radius: 6px; background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; white-space: nowrap; }
.menu-item, .menu-item:hover { text-decoration: none; }
.menu-item.danger { color: var(--err); }
.menu-item:disabled { opacity: .5; cursor: not-allowed; }
@media (hover: hover) { .menu-item:hover { background: var(--surface-2); } }
.menu-item:focus-visible { background: var(--surface-2); outline: 2px solid var(--brand-2); outline-offset: -2px; }
@media (pointer: coarse) { .menu-item { min-height: 48px; } }
.act-ico { width: 18px; text-align: center; }
.more-btn { font-size: 18px; line-height: 1; min-width: 40px; justify-content: center; }
/* mobile page actions: sticky bar above the tab bar, and a floating + button */
.action-bar, .fab { display: none; }
@media (max-width: 768px) {
  .action-bar {
    display: flex; gap: 8px; align-items: center; position: fixed; z-index: 25; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom));
    padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 8px rgba(16, 24, 40, .08);
  }
  .action-bar .action-main { flex: 1; min-height: 44px; }
  .action-bar .spacer { flex: 1; }
  .action-bar .more-btn { min-width: 44px; min-height: 44px; }
  .main:has(.action-bar) { padding-bottom: calc(144px + env(safe-area-inset-bottom)); }
  .form-bar .btn { flex: 1; min-height: 44px; }
  .form-bar .btn.primary { flex: 2; }
  /* keyboard open: hide the tab bar, action bar sits on the keyboard (--kb set by core.js, iOS) */
  body.kb-open .tabbar { display: none; }
  body.kb-open .action-bar { bottom: var(--kb, 0px); }
  body:has(.action-bar) .toast { bottom: calc(136px + env(safe-area-inset-bottom)); }
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 25; right: max(16px, env(safe-area-inset-right)); bottom: calc(80px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 50%; background: var(--brand-2); color: #fff; font-size: 28px; line-height: 1; border: none; cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 24, 40, .3); -webkit-tap-highlight-color: transparent;
  }
  .fab, .fab:hover { text-decoration: none; }
  .fab:active { filter: brightness(.92); }
  .main:has(.fab) { padding-bottom: calc(148px + env(safe-area-inset-bottom)); }
}
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(20px); background: #16202c; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #b3312d; }
@media (max-width: 768px) { .toast { bottom: calc(76px + env(safe-area-inset-bottom)); } }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #14263d, #1f3a5f 60%, #2a78d6); }
.login { background: var(--surface); padding: 28px; border-radius: 14px; width: min(380px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

/* ---------- charts */
.chart { position: relative; }
.chart svg { display: block; max-width: 100%; overflow: visible; touch-action: pan-y; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: absolute; pointer-events: none; max-width: 100%; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 12px; white-space: nowrap; z-index: 5; display: none; }
.tip b { display: block; margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 6px; }
.tip .row .v { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr 90px; gap: 8px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.hbar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 14px; background: transparent; position: relative; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.hbar .vl { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.hbar.tap { cursor: pointer; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
.hbar.open { background: var(--surface-2); }
.hbar-sub { grid-column: 1 / -1; font-size: 12px; color: var(--text-2); padding: 0 4px 4px; overflow-wrap: anywhere; }
@media (hover: hover) { .hbar.tap:hover { background: var(--surface-2); } }
@media (pointer: coarse) { .hbar { min-height: 44px; font-size: 13px; } }
@media (max-width: 480px) { .hbar { grid-template-columns: minmax(70px, 34%) 1fr auto; } }

.dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 34px; text-align: center; background: var(--surface-2); cursor: pointer; transition: .15s; }
.dropzone.over { border-color: var(--brand-2); background: var(--brand-soft); }
.dropzone .big { font-size: 16px; font-weight: 650; margin-bottom: 4px; }
@media (pointer: coarse) { .dropzone { padding: 22px 16px; } }
.dims-table input { width: 72px; }
/* dimension lines on mobile: L × W × H · Ctn ✕ */
.dim-head { margin-bottom: 6px; }
.dim-rows { display: flex; flex-direction: column; gap: 8px; }
.dim-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) 44px; align-items: center; gap: 4px; }
.dim-row input { width: 100%; padding: 7px 6px; text-align: center; }
.dim-op { color: var(--muted); font-weight: 700; }
.dim-row .dim-x { min-width: 44px; min-height: 44px; justify-content: center; padding: 0; }
.dim-calc { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* ---------- attachments (photos & documents) */
.att-tools { margin-bottom: 10px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.att-thumb { display: flex; flex-direction: column; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.att-thumb img, .att-thumb .att-pdf { width: 100%; aspect-ratio: 1; object-fit: cover; }
.att-thumb img { display: block; }
.att-pdf { display: grid; place-items: center; background: var(--surface); color: var(--err); font-weight: 800; font-size: 18px; letter-spacing: .05em; }
.att-cap { display: flex; flex-direction: column; padding: 6px 8px; font-size: 11.5px; line-height: 1.3; min-width: 0; }
.att-cap span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-form { display: flex; flex-direction: column; gap: 12px; }
.att-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.att-file { display: none; }
.att-preview { display: flex; gap: 10px; align-items: center; min-height: 64px; padding: 8px; border: 1px dashed var(--border-strong); border-radius: 8px; min-width: 0; }
.att-preview > div { min-width: 0; }
.att-preview img, .att-preview .att-pdf { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }
.viewer { position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; background: rgba(8, 12, 18, .96); color: #fff; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px; padding-top: calc(6px + env(safe-area-inset-top)); }
.viewer-count { font-size: 13px; opacity: .75; }
.viewer-bar .spacer { flex: 1; }
.viewer-x { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: #fff; font-size: 20px; cursor: pointer; }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; touch-action: pan-y pinch-zoom; user-select: none; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-user-drag: none; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 30px; cursor: pointer; }
.viewer-nav.prev { left: 8px; }
.viewer-nav.next { right: 8px; }
.viewer-nav[hidden] { display: none; }
.viewer-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 13px; }
.viewer-meta { flex: 1; min-width: 0; opacity: .85; }
.viewer-foot .btn:not(.danger) { background: rgba(255, 255, 255, .12); color: #fff; border-color: transparent; }
@media (max-width: 768px) {
  .att-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .viewer-nav { display: none; }
}
@media (max-width: 480px) {
  .att-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* ---------- truck planner (trips) */
.tst-PLANNED { color: var(--st-planned); background: var(--st-planned-bg); }
.tst-LOADING { color: var(--st-onhand); background: var(--st-onhand-bg); }
.tst-DISPATCHED { color: var(--st-handover); background: var(--st-handover-bg); }
.tst-DELIVERED { color: var(--st-loaded); background: var(--st-loaded-bg); }
.cbm-bar { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cbm-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.cbm-track { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.cbm-fill { height: 100%; background: var(--ok); transition: width .2s; }
.cbm-bar.warn .cbm-fill { background: var(--warn); }
.cbm-bar.err .cbm-fill { background: var(--err); }
.cbm-bar.warn .cbm-top span { color: var(--warn); font-weight: 700; }
.cbm-bar.err .cbm-top span { color: var(--err); font-weight: 700; }
.cbm-cell { min-width: 150px; }
.trip-sum { display: flex; flex-direction: column; gap: 8px; }
.trip-sum .cbm-top { font-size: 15px; }
.trip-sum .cbm-track { height: 12px; border-radius: 6px; }
.trip-flags { display: flex; flex-wrap: wrap; }
.trip-form { display: flex; flex-direction: column; gap: 12px; }
.trip-foot { flex: 1; justify-content: flex-end; }
.trip-foot .spacer { flex: 1; }
.check-row { display: flex; align-items: center; gap: 8px; }
.load-groups { display: flex; flex-direction: column; gap: 12px; }
.load-group { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.load-group.due { border-color: var(--err); }
.lg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 32px; }
.lg-head .spacer { flex: 1; }
.lrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.lrow-main, .lrow-nums { display: flex; flex-direction: column; min-width: 0; }
.lrow-nums { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.lrow-act { display: flex; gap: 6px; }
.truck-list .lrow:first-child { border-top: 0; }
@media (prefers-reduced-motion: reduce) { .cbm-fill { transition: none; } }
@media (max-width: 768px) {
  .trip-sum { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5; }
  .trip-head { flex-wrap: nowrap; gap: 8px; }
  .trip-head h1 { font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 480px) {
  .lrow { grid-template-columns: minmax(0, 1fr) auto; }
  .lrow-act { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---------------------------------------------------------------- group messages (S17) */
.msg-form { display: flex; flex-direction: column; gap: 12px; }
.msg-text { width: 100%; min-height: 280px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; line-height: 1.45; white-space: pre; overflow-x: auto; resize: vertical; }
.cons-list { display: flex; flex-direction: column; gap: 12px; }
.cons-row { display: grid; grid-template-columns: 90px 1fr 44px; gap: 8px; align-items: start; }
.cons-row textarea { min-height: 96px; }
.cons-row input { text-transform: uppercase; }
@media (max-width: 768px) {
  .msg-text { min-height: 45dvh; font-size: 16px; }
}
@media (max-width: 480px) {
  .cons-row { grid-template-columns: 1fr 44px; }
  .cons-row textarea { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------------------------------------------------------------- factories / CnF (S22) */
.fac-tools { display: flex; align-items: center; gap: 8px; }
.fac-tools .fac-search { flex: 1; min-width: 0; }
.fac-bar { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.fac-bar .fac-search { max-width: 360px; }
.chip.on { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.fac-miss { padding-right: 12px; }
.fac-count { padding: 8px 12px; }
.ship-mobile .fac-count { padding: 0; }
.mcard:not([role]) { cursor: default; }
.cnf-lines { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.cnf-line { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-width: 0; }
.cnf-tel { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cnf-info { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.cnf-info .cnf-lines { flex: 1; min-width: 0; }
.cnf-row { font-size: 13px; }
.cnf-edit { min-height: 28px; padding: 0 8px; }
button.pill.cnf-miss { border: 1px solid var(--warn); cursor: pointer; font: inherit; font-size: 11px; font-weight: 700; padding: 2px 8px; }
.cnf-pick .lrow:first-child { border-top: 0; }
.cnf-add { display: flex; gap: 8px; }
.cnf-add select { flex: 1; min-width: 0; }
.cnf-new { align-self: flex-start; }
@media (pointer: coarse) {
  .cnf-tel { display: inline-flex; align-items: center; min-height: 44px; }
  .cnf-edit, button.pill.cnf-miss { min-height: 44px; min-width: 44px; }
}

/* ---------------------------------------------------------------- PDF read (S19) */
.pdf-pick { display: flex; flex-direction: column; gap: 12px; }
.pdf-pick p { margin: 0; }
.pdf-choose { min-height: 48px; }
.pdf-att { display: flex; flex-direction: column; gap: 8px; }
.pdf-att-btn { display: flex; justify-content: space-between; gap: 8px; min-height: 44px; text-align: left; }
.pdf-preview { display: flex; flex-direction: column; gap: 12px; }
.pdf-head { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.pdf-head .cell-2 { overflow-wrap: anywhere; }
.pdf-group, .pdf-plan { display: flex; flex-direction: column; gap: 6px; }
.pdf-gh { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0 0; }
.pdf-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; min-height: 44px; }
.pdf-row input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.pdf-row.conflict { border-color: var(--warn); }
.pdf-row.same, .pdf-row.info { border-style: dashed; }
.pdf-row.info { padding-left: 40px; }
label.pdf-row { cursor: pointer; }
.pdf-body { flex: 1; min-width: 0; }
.pdf-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.pdf-val { overflow-wrap: anywhere; }
.pdf-val s { margin-right: 2px; }
.pdf-same summary { cursor: pointer; padding: 6px 0; }
.pdf-same .pdf-row { margin-top: 6px; }
.pdf-plan .alert { margin: 0; }
.pdf-plan-list { display: flex; flex-direction: column; gap: 4px; }
.pdf-plan-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); color: inherit; text-decoration: none; }
@media (pointer: coarse) and (max-width: 768px) {
  .pdf-plan-row { min-height: 44px; }
  .pdf-row input[type=checkbox] { width: 24px; height: 24px; }
}
.loading { padding: 40px; text-align: center; color: var(--muted); }
.hide { display: none !important; }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.only-mobile { display: none !important; }
@media (max-width: 768px) {
  .only-mobile { display: revert !important; }
  .only-desktop { display: none !important; }
  .stack-sm { flex-direction: column; align-items: stretch; }
  .stack-sm > * { width: 100%; }
}
details summary { cursor: pointer; font-weight: 600; }

/* ---------- fixes */
.grid > .card, .grid > div > .card:first-child { margin-top: 0; }
.mono { white-space: nowrap; }
h1.mono { font-size: 20px; }
.kv dd { overflow-wrap: anywhere; min-width: 0; }
.grid > * { min-width: 0; }
.card { min-width: 0; }


/* Settings → Danger zone / reset sheet (S23) */
.card.danger-zone { border-color: var(--err); }
.reset-form { display: grid; gap: 12px; }
.reset-form h3 { margin: 0; }
.reset-counts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 16px; }
.reset-counts li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding: 4px 0; }
