/* ADMIN DYNASTY · Order Router — the quiet operations console
   ------------------------------------------------------------------
   DESIGN TOKENS. The eight colours below are fixed (PROJECT DYNASTY spec);
   every other colour in this file is one of them, a transparent tint of one
   of them, or a darker shade of the accent for its hover state.
   Contrast rules (WCAG AA, checked): --accent and --info are never used for
   small text — only for backgrounds, borders, markers and large numbers. */
:root {
  /* colour — fixed tokens */
  --bg:         #0E0F11;
  --surface:    #16181B;
  --surface-2:  #1D2024;
  --border:     #26292E;
  --text:       #E6E7E9;
  --text-muted: #9AA0A6;
  --accent:     #C7413C;
  --ok:         #3E9B6B;
  --warn:       #C08A2E;
  --danger:     #C7413C;
  --info:       #4A7DB5;

  /* derived: tints for quiet backgrounds, one shade for pressed/hover accent */
  --accent-hover: color-mix(in srgb, var(--accent) 84%, #000);
  --accent-soft:  color-mix(in srgb, var(--accent) 14%, transparent);
  --ok-soft:      color-mix(in srgb, var(--ok) 14%, transparent);
  --warn-soft:    color-mix(in srgb, var(--warn) 14%, transparent);
  --info-soft:    color-mix(in srgb, var(--info) 16%, transparent);
  --border-strong: color-mix(in srgb, var(--text-muted) 32%, var(--border)); /* buttons, switch */
  --border-input:  color-mix(in srgb, var(--text-muted) 55%, var(--border)); /* form fields: 3.3–3.5:1 (AA for UI parts) */
  --on-accent: #FFFFFF; /* text on red buttons: 4.94:1 (AA) */
  --on-ok:     var(--bg); /* text on green buttons: 5.58:1 (AA) */

  /* type: system fonts only (no web fonts). Bengali falls back to the
     platform's own Bengali font: Nirmala UI (Windows), Noto Sans Bengali
     (Android), Kohinoor/Bangla Sangam (Apple). */
  --font-body: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Nirmala UI", "Noto Sans Bengali", "Kohinoor Bangla", "Bangla Sangam MN", sans-serif;
  --font-head: var(--font-body);
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Roboto Mono", Menlo,
               "Nirmala UI", "Noto Sans Bengali", monospace;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-15: 15px;
  --fs-20: 20px;
  --fs-28: 28px;
  --lh-body: 1.5;
  --lh-head: 1.2;

  /* spacing: 8px grid */
  --s-4: 4px;
  --s-8: 8px;
  --s-12: 12px;
  --s-16: 16px;
  --s-24: 24px;
  --s-32: 32px;
  --s-48: 48px;

  /* shape, depth, motion */
  --radius: 6px;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .45);
  --t: 160ms ease-out;
  --focus-ring: 2px solid var(--accent);

  /* control sizes */
  --control-h: 36px;
  --control-h-sm: 28px;

  /* legacy names still used by app.js and older rules — kept as aliases */
  --muted:        var(--text-muted);
  --primary:      var(--accent);
  --primary-hover: var(--accent-hover);
  --primary-soft: var(--accent-soft);
  --success:      var(--ok);
  --success-soft: var(--ok-soft);
  --warning:      var(--warn);
  --warning-soft: var(--warn-soft);
  --bg-grid:      var(--bg);

  color-scheme: dark;
 --radius-card: var(--radius); --wash: color-mix(in srgb, var(--text) 3.5%, transparent); --hair: color-mix(in srgb, var(--border) 80%, transparent); --line: color-mix(in srgb, var(--text-muted) 30%, var(--border)); --bad-soft: color-mix(in srgb, var(--danger) 15%, transparent); }

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-13);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { line-height: var(--lh-head); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--text); }
/* One focus ring everywhere: 2px accent, 2px away from the element. Never removed. */
:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; min-height: 100vh; }
.sidebar {

  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand svg { flex: none; }
.brand-name { white-space: nowrap; }

.nav { display: flex; flex-direction: column; flex: 1; overflow-y: auto; }
.nav a {
  position: relative; display: flex; align-items: center;
  text-decoration: none;
  transition: background var(--t), color var(--t);
}
.nav a svg { flex: none;  width: 16px; height: 16px; }

.nav a.active::before {
  content: ''; position: absolute;

 left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }

.nav .nav-badge {
  margin-left: auto;

}

.status-pill {
  display: flex; align-items: center;

}

@media (prefers-reduced-motion: reduce) { .dot.on { animation: none; } * { transition: none !important; } }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center;

}
.topbar h1 { margin: 0;  font: 600 var(--fs-20)/1.2 var(--font-head); letter-spacing: 0; }

.topbar .spacer { flex: 1; }
.view { width: 100%; }

/* ------------------------------------------------------------------ switch */
.switch { display: inline-flex; align-items: center; gap: var(--s-8); cursor: pointer; user-select: none; font-weight: 500; font-size: var(--fs-13); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-strong);
  position: relative; transition: background var(--t), border-color var(--t); flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-muted); transition: transform var(--t), background var(--t);
}
.switch:hover .track { border-color: var(--text-muted); }
.switch input:checked + .track { background: var(--ok-soft); border-color: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--ok); }
.switch input:focus-visible + .track { outline: var(--focus-ring); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }
.switch.radio { padding: var(--s-8) var(--s-12); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color var(--t), background var(--t); }
.switch.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.switch.radio:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.switch.radio .track { width: 16px; height: 16px; border-radius: 50%; }
.switch.radio .track::after { top: 3px; left: 3px; width: 8px; height: 8px; background: transparent; }
.switch.radio input:checked + .track { background: transparent; border-color: var(--accent); }
.switch.radio input:checked + .track::after { transform: none; background: var(--accent); }

/* ------------------------------------------------------------------ buttons
   primary  = the one main action on a screen (red, white text)
   default  = everything else (neutral)
   ghost    = low-weight actions inside rows / dialogs
   danger   = destructive (red outline, neutral text; fills red on hover)
   bill-due / bill-clear / pay = Accounting meanings, unchanged: due = red, clear = green tint, pay = green */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-8);
  height: var(--control-h); padding: 0 var(--s-16); border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-weight: 500; font-size: var(--fs-13); line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { border-color: var(--text-muted); background: var(--surface-2); }
.btn:active:not(:disabled) { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--text); }
.btn.danger svg { color: var(--danger); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn.danger:hover svg { color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn.sm { height: var(--control-h-sm); padding: 0 var(--s-12); font-size: var(--fs-12); }
.btn.lg { height: 44px; padding: 0 var(--s-24); font-size: var(--fs-15); font-weight: 600; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* Accounting — meaning unchanged: Bill red when they owe, faint green when nothing is due; Pay green */
.btn.bill-due { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn.bill-due:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.bill-clear { background: var(--ok-soft); border-color: var(--ok); color: var(--text); }
.btn.bill-clear:hover:not(:disabled) { background: color-mix(in srgb, var(--ok) 26%, transparent); }
.btn.bill-clear:disabled { opacity: .6; }
/* Bill already sent: same faded look as a disabled button, but still clickable (resend with warning). */
.btn.bill-sent { opacity: .45; }
.btn.bill-sent:hover, .btn.bill-sent:focus-visible { opacity: .8; }
.btn.pay { background: var(--ok); border-color: var(--ok); color: var(--on-ok); font-weight: 600; }
.btn.pay:hover { background: color-mix(in srgb, var(--ok) 86%, #fff); border-color: color-mix(in srgb, var(--ok) 86%, #fff); }
.icon-btn { width: var(--control-h); padding: 0; }
.btn.sm.icon-btn { width: var(--control-h-sm); }

/* ------------------------------------------------------------------ cards */
.grid-stats { display: grid; }
.stat {

  display: flex; flex-direction: column; justify-content: space-between;
}
.stat .k { display: flex; align-items: center; }
.stat .v { font-variant-numeric: tabular-nums; }
.stat .v small { font-weight: 500; }

.panel-head { display: flex; align-items: center; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }

.panel-head .spacer { flex: 1; }

.alert { display: flex; align-items: flex-start; border: 1px solid; }

.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }

/* ------------------------------------------------------------------ forms */
/* Labels sit above their input; hints are muted; inputs are darker than the panel
   so the editable area is obvious. Focus = the global 2px accent ring + accent border. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-16); align-items: end; }
.field { display: flex; flex-direction: column; gap: var(--s-4); font-size: var(--fs-12); color: var(--text-muted); font-weight: 500; }
.field.wide { grid-column: 1 / -1; }
.field .hint { font-weight: 400; font-size: var(--fs-12); color: var(--text-muted); }
.input, .field input:not([type=checkbox]), .field select, .field textarea, select.input {
  height: var(--control-h); padding: 0 var(--s-12); border-radius: var(--radius); border: 1px solid var(--border-input);
  background: var(--bg); color: var(--text); font-size: var(--fs-13); font-weight: 400; min-width: 0;
  transition: border-color var(--t), background var(--t);
}
.field textarea { height: auto; min-height: 76px; padding: var(--s-8) var(--s-12); resize: vertical; line-height: var(--lh-body); }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--text-muted); opacity: 1; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--text-muted); }.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.input:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.input:disabled, .field input:disabled, .field select:disabled, .field textarea:disabled { opacity: .55; cursor: not-allowed; }
.field select, select.input { cursor: pointer; }
.input.mono, .field input.mono { font-family: var(--font-mono); }
.search { position: relative; }
.search svg { position: absolute; left: var(--s-12); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search .input { padding-left: 36px; width: 240px; }

/* ------------------------------------------------------------------ chips & badges */
.chips { display: flex; flex-wrap: wrap; }
.chip {

  cursor: pointer; display: inline-flex; align-items: center;
  transition: background var(--t), color var(--t), border-color var(--t);
}

.chip .n { font-family: var(--font-mono); font-size: 11px; }

.badge {
  display: inline-flex; align-items: center;
  white-space: nowrap;

}

.b-operator_assigned { border-color: var(--primary); }
.b-waiting { border-color: var(--info); }

.role { display: inline-flex; align-items: center; }

.cat { display: inline-block; font-size: 12px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; position: relative; }
.t td.mono { white-space: nowrap; }
table.t { width: 100%; border-collapse: collapse; }
.t th {
  text-align: left;
  white-space: nowrap;
}
.t td { vertical-align: middle; }
.t tbody tr { transition: background var(--t); }

.t tbody tr:last-child td { border-bottom: 0; }
.t .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.t .code { font-family: var(--font-mono); font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.t .actions { text-align: right; white-space: nowrap; }
.t .actions > * + * { margin-left: 6px; }
/* ---- Orders page: one colour per situation ---- */
.ocards { display: grid; }
.ocard {
  display: flex; flex-direction: column; text-align: left; cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text); font: inherit; transition: border-color var(--t), background var(--t);
}

.obadge {
  display: inline-flex; align-items: center; white-space: nowrap;

}
/* kept (C1): border is 0 px wide, but this two-class selector still sets the computed colour */
.ov-sent.late { border-color: rgba(239, 68, 68, .5); }

.t tr.orow td:first-child { box-shadow: inset 4px 0 0 var(--row-c, transparent); }

.t tr.rv-cancelled { opacity: .8; }

.ostrip {

  border: 1px solid;
}
.ostrip-icon { font-size: 18px; }
.ostrip-text { flex: 1; }
.ostrip + .panel { margin-top: -4px; }

/* order list: one row per order, coloured bar on the left */
.olist { display: flex; flex-direction: column; }
.olist-head, .olist-row {
  display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(150px, 1.2fr) minmax(190px, 1.4fr) 110px minmax(150px, auto);
  gap: 14px; align-items: center; padding: 11px 16px 11px 18px;
}
.olist-head { text-transform: uppercase; }
.olist-row { box-shadow: inset 4px 0 0 var(--row-c, transparent); }
.olist-row:last-child { border-bottom: 0; }

.olist-row.rv-cancelled .code, .olist-row.rv-cancelled .olist-who { color: var(--muted); }
.olist-code, .olist-st, .olist-time { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.olist-act:empty { display: none; }
@media (max-width: 1350px) {
  .olist-head, .olist-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) 100px; }
  .olist-head span:last-child { display: none; }
  .olist-act { grid-column: 1 / -1; justify-content: flex-start; margin-top: -2px; }
}

.olist-code .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.olist-who { min-width: 0; }
.olist-arrow { color: var(--muted); margin: 0 2px; }

.olist-act { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.cell-sub { display: block; font-family: var(--font-mono); }
.assign { display: inline-flex; gap: 6px; align-items: center; }
.assign select { font-size: 12.5px; padding: 0 8px; max-width: 170px; }

.route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.route .arrow { color: var(--primary); width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------------ health (last 24h) */
.health { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.hcell { display: flex; flex-direction: column; text-decoration: none; color: inherit; transition: background var(--t); }

.hcell .hk { font-weight: 500; }
.hcell .hv { font-size: 20px; font-weight: 600; }

/* ------------------------------------------------------------------ timeline */
.timeline { list-style: none; margin: 0; padding: 4px 0; max-height: 460px; overflow-y: auto; }
.timeline li { display: grid; align-items: center; }
.timeline li:last-child { border-bottom: 0; }

.timeline .txt { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline .txt b { font-family: var(--font-mono); }
.ev { white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; }
.list li:last-child { border-bottom: 0; }

.list .who { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ empty / skeleton */
.empty { text-align: center; }
.empty svg { margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.skel { animation: shimmer 1.2s infinite linear; border: 1px solid var(--border); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-row { height: 96px; }
.skel-block { height: 280px; margin-top: 18px; }
.err-box { padding: 30px; text-align: center; }

/* ------------------------------------------------------------------ hero (settings) */
.hero {
  display: flex; align-items: center; gap: 20px;
  border: 1px solid var(--border); margin-bottom: 18px;
}

.hero .hero-icon { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.hero.on .hero-icon { background: var(--success-soft); color: var(--success); }
.hero .hero-icon svg { width: 26px; height: 26px; }
.hero h2 { margin: 0; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.hero .spacer { flex: 1; }

.savebar {
  position: sticky; bottom: 0; z-index: 4; margin: 18px -28px -48px; padding: 14px 28px;
  display: flex; align-items: center; gap: 12px; justify-content: flex-end;

}
.savebar .muted { margin-right: auto; font-size: var(--fs-12); }

/* ------------------------------------------------------------------ connection */
.conn { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.qr-tile { background: #fff; padding: 16px; width: 292px; height: 292px; display: grid; place-items: center; }
.qr-tile img { width: 260px; height: 260px; display: block; image-rendering: pixelated; }
.qr-tile.placeholder { color: var(--muted); text-align: center; padding: 24px; font-size: 13px; }

/* ------------------------------------------------------------------ overlay: drawer / modal */
.overlay { position: fixed; inset: 0; z-index: 40; opacity: 0; transition: opacity var(--t); }
.overlay.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(440px, 100vw);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 180ms ease;
}
.drawer.show { transform: none; }
.modal {
  position: fixed; left: 50%; top: 50%; z-index: 41; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  border: 1px solid var(--border); display: flex; flex-direction: column;
  transform: translate(-50%, -48%); opacity: 0; transition: transform var(--t), opacity var(--t);
}
.modal.show { transform: translate(-50%, -50%); opacity: 1; }
.dlg-head { display: flex; align-items: center; gap: 10px; }
.dlg-head h3 { margin: 0; flex: 1; }
.dlg-body { overflow-y: auto; flex: 1; display: flex; flex-direction: column; }
.dlg-body p { margin: 0; }
.dlg-foot { display: flex; justify-content: flex-end; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 240px; max-width: min(420px, calc(100vw - 40px));
  padding: 11px 14px; border: 1px solid var(--border);

  animation: toastIn 180ms ease;
}
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }

.toast.out { opacity: 0; transform: translateY(6px); transition: opacity var(--t), transform var(--t); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); border: 1px solid var(--border); padding: 32px 28px 26px; text-align: center; }
.login-card .logo { width: 68px; height: 68px; margin: 0 auto 16px; display: block; }
.login-card .brand-name { font-size: 20px; letter-spacing: .16em; }
.login-card .brand-sub { margin: 8px 0 26px; font-size: 10.5px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-card .err { min-height: 20px; font-size: 13px; text-align: center; }
.tagline { margin-top: 22px; color: var(--muted); font-size: var(--fs-13); text-align: center;  font-family: var(--font-body); }

/* ==================================================================
   PHASE 2 — DYNASTY LEDGER: shell + shared components
   Placed after the original component rules (same class names, so every
   selector app.js uses keeps working) and before the responsive section
   (so phone / touch rules still win). Old rules above are consolidated in Phase 7.
   ================================================================== */

/* ---- status dot: colour = meaning; no decorative pulse ---- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: none; animation: none; }
.dot.off { background: var(--danger); }
.dot.warn { background: var(--warn); }

/* ---- shell ---- */
.shell { grid-template-columns: 240px minmax(0, 1fr); background: var(--bg); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 0; }
.brand { gap: var(--s-12); padding: 24px 24px 20px; border-bottom: 0; }
.brand svg { width: 34px; height: 34px; }
.brand-name { font: 700 13px/1 var(--font-head); letter-spacing: .15em; }
.brand-name .red { color: var(--accent); }
.brand-sub { font: 500 10px/1 var(--font-head); letter-spacing: .3em; color: var(--text-muted); margin-top: 7px; }

.nav { gap: 2px; padding: 0 14px 16px; }
.nav-group {
  font-size: var(--fs-12); font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); padding: 16px 10px 6px;
}
.nav a {
  gap: var(--s-12); min-height: 38px; padding: 0 10px; border-radius: var(--radius);
  color: var(--text-muted); font-weight: 500;
}

.nav a:hover { background: var(--wash); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); }

.nav a.active svg { color: var(--accent); }
.nav .nav-badge {
  min-width: 22px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center;
  font: 600 var(--fs-12)/1 var(--font-mono); border-radius: 10px; background: var(--danger); color: var(--on-accent);
}

/* sidebar footer = system status card */
.side-foot { padding: 16px 14px; border-top: 0; }
.status-pill {
  border-radius: var(--radius-card); padding: var(--s-12) 14px; gap: var(--s-8);
  background: var(--bg); border: 1px solid var(--border); font-size: var(--fs-12); font-weight: 500; color: var(--text);
}

.topbar {
  gap: var(--s-16); min-height: 68px; padding: 12px 28px;
  background: var(--bg); backdrop-filter: none; border-bottom: 1px solid var(--border);
}

.topbar .sub { color: var(--text-muted); font-size: var(--fs-12); margin-top: 2px; }
/* Bot ON/OFF: same checkbox switch, sitting in a quiet pill */
.topbar .switch { height: 36px; padding: 0 12px 0 8px; border: 1px solid var(--line); border-radius: 18px; font-size: var(--fs-12); font-weight: 600; letter-spacing: .04em; }
.topbar .switch:has(input:checked) { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); background: var(--ok-soft); }
/* A1: SIGN switch + timer */
.sign-box { display: inline-flex; align-items: center; gap: 4px; }
.sign-box[hidden] { display: none; }
.sign-timer { height: 36px; border-radius: 18px; font-variant-numeric: tabular-nums; }
.sign-timer.on { color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line)); }
.sign-tf { display: flex; gap: 12px; }
.sign-tf label { display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: var(--fs-13); }
.view { padding: 24px 28px 48px; max-width: 1440px; }

/* ---- cards ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); margin-bottom: var(--s-16); }
.panel-head { gap: var(--s-12); padding: 16px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font: 600 var(--fs-15)/1.2 var(--font-head); }
.panel-head .muted { font-size: var(--fs-12); }
.panel-body { padding: 16px 18px; }

.grid-stats { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s-16); margin-bottom: var(--s-16); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 18px; min-height: 112px; gap: var(--s-8); transition: border-color var(--t);
}
a.stat:hover { border-color: var(--line); }
.stat .k { color: var(--text-muted); font-size: var(--fs-12); font-weight: 500; letter-spacing: 0; gap: var(--s-8); }
.stat .v { font: 600 var(--fs-28)/1.1 var(--font-mono); letter-spacing: -.02em; margin-top: 0; }
.stat .v small { font-size: var(--fs-13); color: var(--text-muted); letter-spacing: 0; }
.stat .s { color: var(--text-muted); font-size: var(--fs-12); margin-top: 0; font-family: var(--font-body); }
.stat.accent { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--surface); }
.stat.accent .v { color: var(--text); font-size: var(--fs-28); }
/* large numbers (≥ 20px, bold) may carry colour: AA large-text 3:1 */
.v.green { color: var(--ok); }
.v.red { color: var(--danger); }

.alert { gap: var(--s-12); padding: var(--s-12) var(--s-16); border-radius: var(--radius); font-size: var(--fs-13); margin-bottom: var(--s-16); color: var(--text); }
.alert.red { background: var(--bad-soft); border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--text); }
.alert.amber { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--text); }
.alert.red svg { color: var(--danger); }
.alert.amber svg { color: var(--warn); }

/* ---- chips (filters) ---- */
.chips { gap: 6px; }
.chip {
  height: 32px; padding: 0 12px; border-radius: var(--radius); border: 1px solid transparent; background: transparent;
  color: var(--text-muted); font-size: var(--fs-12); font-weight: 500; gap: var(--s-8);
}
.chip:hover { color: var(--text); background: var(--wash); }
.chip.active { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.chip .n { font: 600 var(--fs-12) var(--font-mono); color: var(--text); background: var(--bg); padding: 1px 6px; border-radius: 8px; }
.chip.oc-sent.active      { border-color: var(--warn); background: var(--warn-soft); }
.chip.oc-stuck.active     { border-color: var(--danger); background: var(--bad-soft); }
.chip.oc-hold.active      { border-color: var(--info); background: var(--info-soft); }
.chip.oc-duplicate.active { border-color: var(--warn); background: var(--warn-soft); }
.chip.oc-unmatched.active { border-color: var(--danger); background: var(--bad-soft); }
.chip.oc-delivered.active { border-color: var(--ok); background: var(--ok-soft); }
.chip.oc-cancelled.active { border-color: var(--line); background: var(--surface-2); }

/* ---- badges: colour lives in a dot + tint, text stays neutral (AA) ---- */
.badge {
  height: 22px; padding: 0 9px; gap: 6px; border-radius: 11px; border: 0;
  font: 600 var(--fs-12)/1 var(--font-body); text-transform: none; letter-spacing: 0;
  background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--b, var(--text-muted)); flex: none; }
.b-pending   { --b: var(--text-muted); }
.b-sent      { --b: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); color: var(--text); }
.b-delivered { --b: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 45%, transparent); color: var(--text); }
.b-cancelled { --b: var(--text-muted); background: var(--surface-2); color: var(--text-muted); text-decoration: line-through; }
.b-duplicate { --b: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); color: var(--text); }
.b-unmatched { --b: var(--danger); background: var(--bad-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 50%, transparent); color: var(--text); }
.b-operator_assigned { --b: var(--danger); background: transparent; box-shadow: inset 0 0 0 1px var(--danger); color: var(--text); }
.b-waiting   { --b: var(--info); background: transparent; box-shadow: inset 0 0 0 1px var(--info); color: var(--text); }
.b-listed    { --b: var(--info); background: var(--info-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 50%, transparent); color: var(--text); }
.role { height: 22px; padding: 0 9px; border-radius: 11px; font-size: var(--fs-12); font-weight: 600; letter-spacing: 0; gap: 6px; color: var(--text); }
.role::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.role.customer { background: var(--info-soft); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 50%, transparent); }
.role.customer::before { background: var(--info); }
.role.supplier { background: var(--warn-soft); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); }
.role.supplier::before { background: var(--warn); }
.cat { padding: 2px 8px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line); font: 600 var(--fs-12) var(--font-mono); }

/* order status pills (Orders page) — same language as badges */
.obadge { gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; font-weight: 600; font-size: var(--fs-12); border: 0; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); background: var(--surface-2); }
.obadge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--o, var(--text-muted)); flex: none; }
.ov-sent      { --o: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); color: var(--text); }
.ov-sent.late { --o: var(--danger); background: var(--bad-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 50%, transparent); color: var(--text); }
.ov-stuck     { --o: var(--on-accent); background: var(--danger); box-shadow: none; color: var(--on-accent); }
.ov-hold      { --o: var(--info); background: var(--info-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 50%, transparent); color: var(--text); }
.ov-duplicate { --o: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); color: var(--text); }
.ov-unmatched { --o: var(--danger); background: var(--bad-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 50%, transparent); color: var(--text); }
.ov-waiting   { --o: var(--text-muted); }
.ov-delivered { --o: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 45%, transparent); color: var(--text); }
.ov-cancelled { --o: var(--text-muted); background: transparent; color: var(--text-muted); }

/* ---- tables: hairline rows, quiet uppercase header, numbers right ---- */
.table-wrap { border-radius: 0 0 var(--radius-card) var(--radius-card); }
table.t { font-size: var(--fs-13); }
.t th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  font-size: var(--fs-12); font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.t td { padding: 12px 14px; border-bottom: 1px solid var(--hair); }
.t tbody tr:hover { background: var(--wash); }
.t th:first-child, .t td:first-child { padding-left: 18px; }
.t th:last-child, .t td:last-child { padding-right: 18px; }
.t .code { font: 600 var(--fs-13) var(--font-mono); }
.cell-sub { color: var(--text-muted); font-size: var(--fs-12); margin-top: 2px; }

.t tr.rv-sent      { --row-c: var(--warn); }
.t tr.rv-sent.late { --row-c: var(--danger); background: color-mix(in srgb, var(--danger) 5%, transparent); }
.t tr.rv-stuck     { --row-c: var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.t tr.rv-hold      { --row-c: var(--info); background: color-mix(in srgb, var(--info) 5%, transparent); }
.t tr.rv-duplicate { --row-c: var(--warn); background: color-mix(in srgb, var(--warn) 5%, transparent); }
.t tr.rv-unmatched { --row-c: var(--danger); }
.t tr.rv-waiting   { --row-c: var(--text-muted); }
.t tr.rv-delivered { --row-c: var(--ok); }
.t tr.rv-cancelled { --row-c: var(--border); }
.assign select { height: var(--control-h-sm); border-radius: var(--radius); border: 1px solid var(--border-input); background: var(--bg); }

/* Orders list (grid rows) — same table language */
.olist-head { font-size: var(--fs-12); font-weight: 600; letter-spacing: .07em; color: var(--text-muted); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 1; }
.olist-row { border-bottom: 1px solid var(--hair); transition: background var(--t); }
.olist-row:hover { background: var(--wash); }
.olist-row.rv-sent { --row-c: var(--warn); }
.olist-row.rv-sent.late { --row-c: var(--danger); background: color-mix(in srgb, var(--danger) 5%, transparent); }
.olist-row.rv-stuck { --row-c: var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.olist-row.rv-hold { --row-c: var(--info); background: color-mix(in srgb, var(--info) 5%, transparent); }
.olist-row.rv-duplicate { --row-c: var(--warn); background: color-mix(in srgb, var(--warn) 5%, transparent); }
.olist-row.rv-unmatched { --row-c: var(--danger); }
.olist-row.rv-waiting { --row-c: var(--text-muted); }
.olist-row.rv-delivered { --row-c: var(--ok); }
.olist-row.rv-cancelled { --row-c: var(--border); }
.olist-code .code { font: 600 var(--fs-13) var(--font-mono); }
.olist-who { font-size: var(--fs-13); }
.olist-time { font-size: var(--fs-12); }

/* queue cards (Orders) */

.ocard { border-radius: var(--radius-card); padding: 14px 16px; gap: 2px; background: var(--surface); border-color: var(--border); }
.ocard:hover { border-color: var(--line); background: var(--surface); }
.ocard.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ocard-n { font: 600 var(--fs-20)/1 var(--font-mono); }
.ocard-label { font-weight: 600; font-size: var(--fs-13); }
.ocard-sub { color: var(--text-muted); font-size: var(--fs-12); }
.ocard.warn, .ocard.bad, .ocard.info, .ocard.pro { background: var(--surface); }
.ocard.warn { box-shadow: inset 3px 0 0 var(--warn); }
.ocard.bad  { box-shadow: inset 3px 0 0 var(--danger); }
.ocard.info { box-shadow: inset 3px 0 0 var(--info); }
.ocard.pro  { box-shadow: inset 3px 0 0 var(--text-muted); }
.ocard.warn .ocard-n, .ocard.bad .ocard-n, .ocard.info .ocard-n, .ocard.pro .ocard-n { color: var(--text); }
.ocard.active.warn, .ocard.active.bad, .ocard.active.info, .ocard.active.pro { box-shadow: inset 0 0 0 1px var(--accent); }
.ostrip { border-radius: var(--radius-card); border-color: var(--border); background: var(--surface); color: var(--text); padding: var(--s-12) var(--s-16); gap: var(--s-12); }

/* health counters (Last 24 hours) */
.health { gap: 0; background: transparent; }
.hcell { padding: 14px 18px; background: var(--surface); border-right: 1px solid var(--hair); border-top: 1px solid var(--hair); gap: 4px; box-shadow: none; }
.hcell .hk { font-size: var(--fs-12); color: var(--text-muted); display: flex; align-items: center; gap: var(--s-8); }
.hcell .hk::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); flex: none; }
.hcell .hv { font: 600 var(--fs-20)/1.2 var(--font-mono); color: var(--text); }
.hcell.zero .hv { color: var(--text-muted); }
.hcell.red .hk::before { background: var(--danger); }
.hcell.amber .hk::before { background: var(--warn); }
.hcell.blue .hk::before { background: var(--info); }
.hcell.red, .hcell.amber, .hcell.blue { box-shadow: none; }
.hcell.red .hv, .hcell.amber .hv, .hcell.blue .hv { color: var(--text); }
a.hcell:hover { background: var(--wash); }

/* timeline (Live history) */
.timeline li { grid-template-columns: 56px auto 1fr; gap: var(--s-12); padding: 10px 18px; font-size: var(--fs-13); border-bottom: 1px solid var(--hair); }
.timeline time { font: var(--fs-12) var(--font-mono); color: var(--text-muted); }
.timeline .txt b { color: var(--text); font-weight: 600; }
.ev { display: inline-flex; align-items: center; gap: 6px; font: 600 var(--fs-12)/1 var(--font-body); text-transform: none; letter-spacing: 0; padding: 4px 8px; border-radius: 11px; background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.ev::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--e, var(--text-muted)); }
.ev.green { --e: var(--ok); background: var(--ok-soft); color: var(--text); }
.ev.red   { --e: var(--danger); background: var(--bad-soft); color: var(--text); }
.ev.amber { --e: var(--warn); background: var(--warn-soft); color: var(--text); }
.ev.blue  { --e: var(--info); background: var(--info-soft); color: var(--text); }

/* simple lists (running orders on Overview) */
.list li { gap: var(--s-12); padding: 12px 18px; border-bottom: 1px solid var(--hair); font-size: var(--fs-13); }
.list .code { font: 600 var(--fs-13) var(--font-mono); }

/* empty / loading / error */
.empty { padding: 48px 24px; color: var(--text-muted); }
.empty svg { width: 32px; height: 32px; color: var(--line); }
.empty b { font-size: var(--fs-15); }
.skel { border-radius: var(--radius-card); border-color: var(--border); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; }
.err-box { color: var(--text); }
.err-box svg { color: var(--danger); }

/* settings hero, section titles, save bar */
.hero { border-radius: var(--radius-card); padding: 20px 24px; background: var(--surface); }
.hero.on { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); background: var(--surface); box-shadow: inset 3px 0 0 var(--ok); }
.hero .hero-icon { border-radius: var(--radius-card); width: 48px; height: 48px; }
.hero h2 { font: 600 var(--fs-20)/1.2 var(--font-head); }
.hero p { font-size: var(--fs-13); }

.savebar { background: var(--surface); backdrop-filter: none; border-top: 1px solid var(--border); }

/* connection */
.qr-tile { border-radius: var(--radius-card); }
.qr-tile.placeholder { background: var(--surface-2); border: 1px dashed var(--line); }

/* ---- pop-ups: modal + side drawer ---- */
.overlay { background: rgba(0, 0, 0, .6); backdrop-filter: none; }
.modal, .drawer { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-pop); }
.modal { border-radius: var(--radius-card); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dlg-head h3 { font: 600 var(--fs-15)/1.2 var(--font-head); }
.dlg-body { padding: 18px 20px; gap: var(--s-16); }
.dlg-body p { color: var(--text-muted); }
.dlg-body p b { color: var(--text); }
.dlg-foot { padding: 12px 20px; gap: var(--s-8); background: var(--bg); border-top: 1px solid var(--border); }
.modal .dlg-foot { border-radius: 0 0 var(--radius-card) var(--radius-card); }

/* ---- toasts ---- */
.toast { border-radius: var(--radius-card); background: var(--surface-2); border-color: var(--line); box-shadow: var(--shadow-pop); font-size: var(--fs-13); color: var(--text); }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.ok svg { color: var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.err svg { color: var(--danger); }

/* ---- login ---- */
.login-wrap { background: var(--bg); }
.login-card { border-radius: var(--radius-card); background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-pop); }
.login-card .brand-name .red { color: var(--accent); }
.login-card .err { color: var(--text); }

/* ==================================================================
   PHASE 3 — OVERVIEW (Dynasty Ledger)
   ================================================================== */
.t-ok { --tc: var(--ok); } .t-warn { --tc: var(--warn); } .t-bad { --tc: var(--danger); }
.t-info { --tc: var(--info); } .t-n { --tc: var(--text-muted); }
.t-info-soft { --tc: color-mix(in srgb, var(--info) 45%, var(--surface-2)); }

/* executive summary line */
.ov-summary { display: flex; align-items: center; gap: var(--s-16); padding: 14px 18px; margin-bottom: var(--s-16);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.ov-summary p { margin: 0; color: var(--text-muted); font-size: var(--fs-13); }
.ov-summary p b { color: var(--text); font-weight: 600; }
.ov-chip { width: 32px; height: 32px; border-radius: var(--radius); display: inline-grid; place-items: center; flex: none;
  color: var(--tc); background: color-mix(in srgb, var(--tc) 15%, transparent); }
.ov-chip svg { width: 16px; height: 16px; }
.t-n.ov-chip { background: var(--surface-2); }

/* KPI cards */
.ov-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ov-kpis .stat .k { display: flex; align-items: center; gap: var(--s-12); }
.ov-kpis .stat .v { margin-top: var(--s-4); }
.ov-v-text { font: 600 var(--fs-20)/1.2 var(--font-body) !important; display: flex; align-items: center; gap: var(--s-8); }
.stat .s { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat .s b { color: var(--text); font-weight: 600; }
.ov-go { margin-left: auto; color: var(--text-muted); display: inline-flex; }
.ov-go svg { width: 16px; height: 16px; }
a.stat { text-decoration: none; color: inherit; }
.ov-money { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-16); margin-bottom: var(--s-16); }
.ov-flat { min-height: 0; }
.ov-flat .v { font-size: var(--fs-20); }

/* order pipeline */
.ov-pipe { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-12); }
.ov-stage { display: flex; flex-direction: column; gap: var(--s-4); padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); position: relative; }
.ov-stage + .ov-stage::before { content: ''; position: absolute; left: -13px; top: 50%; width: 12px; height: 1px; background: var(--line); }
.ov-stage.hot { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); background: color-mix(in srgb, var(--danger) 6%, var(--bg)); }
.ov-stage-n { font: 600 var(--fs-20)/1.1 var(--font-mono); }
.ov-stage-l { font-weight: 600; font-size: var(--fs-13); }
.ov-stage-s { font-size: var(--fs-12); color: var(--text-muted); }
.ov-meter { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: var(--s-8); }
.ov-meter i { display: block; height: 100%; border-radius: 2px; background: var(--tc); }

/* running orders table */
.ov-running td { vertical-align: middle; }
.ov-who { display: inline-flex; align-items: center; gap: var(--s-8); white-space: nowrap; }
.ov-av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font: 600 10.5px/1 var(--font-body); background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.ov-track { display: inline-flex; align-items: center; width: 140px; }
.ov-track i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); flex: none; }
.ov-track b { flex: 1; height: 2px; background: var(--line); }
.ov-track i.f { border-color: var(--tc); background: var(--tc); }
.ov-track b.f { background: var(--tc); }
.ov-track i.now { border-color: var(--tc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 28%, transparent); }
.ov-age { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 11px; font: 600 var(--fs-12) var(--font-mono);
  color: var(--text); background: color-mix(in srgb, var(--tc) 15%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc) 45%, transparent); }
.ov-note { padding: 10px 18px 14px; font-size: var(--fs-12); color: var(--text-muted); }

/* two-column rows */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: var(--s-16); }
.ov-grid > .panel { margin-bottom: var(--s-16); }

/* hourly chart */
.ov-chart { display: block; width: 100%; height: 170px; overflow: visible; }
.ov-chart .grid line { stroke: var(--border); stroke-width: 1; }
.ov-chart .grid text { fill: var(--text-muted); font: 11px var(--font-mono); }
.ov-chart .d { fill: var(--ok); }
.ov-chart .c { fill: var(--border-input); }
.ov-chart .hit { fill: transparent; }
.ov-chart .ov-bar:hover .hit, .ov-chart .ov-bar:focus .hit { fill: var(--wash); }
.ov-chart .ov-bar:focus { outline: none; }
.ov-chart .ov-bar:focus-visible .hit { stroke: var(--accent); stroke-width: 2; }
.ov-chart .now { stroke: var(--accent); stroke-dasharray: 3 3; }
.ov-axis { display: flex; justify-content: space-between; padding: 6px 0 0 28px; font-size: var(--fs-12); color: var(--text-muted); }
.ov-legend { display: flex; flex-wrap: wrap; gap: var(--s-16); margin-top: var(--s-12); font-size: var(--fs-12); color: var(--text-muted); }
.ov-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ov-legend .sw, .ov-net-rows .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--tc, var(--ok)); }
.ov-legend .sw.d { background: var(--ok); } .ov-legend .sw.c { background: var(--border-input); }

/* Last 24 hours as a list: dot · label · explanation · count */
.ov-health { display: flex; flex-direction: column; }
.ov-health .hcell { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: var(--s-12); row-gap: 2px;
  padding: 10px 18px; border-right: 0; border-top: 1px solid var(--hair); }
.ov-health .hcell:first-child { border-top: 0; }
.ov-health .hk { grid-column: 1; font-weight: 600; color: var(--text); font-size: var(--fs-13); }
.ov-health .ht { grid-column: 1; font-size: var(--fs-12); color: var(--text-muted); }
.ov-health .hv { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: var(--fs-15); }
.ov-health .hcell.zero { opacity: .6; }
.ov-health .hcell[title]::after { content: none; } /* explanation is already visible */

/* live history timeline */
.ov-live { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); font-size: var(--fs-12); color: var(--text-muted); }
.ov-timeline { max-height: 420px; padding: 8px 0; position: relative; }
.ov-timeline li { grid-template-columns: 52px auto 1fr; border-bottom: 0; padding: 8px 18px; }
.ov-timeline .txt { color: var(--text-muted); }

/* network */
a.ov-network { display: block; text-decoration: none; color: inherit; transition: border-color var(--t); }
a.ov-network:hover { border-color: var(--line); }
.ov-network .panel-head .muted { display: inline-flex; align-items: center; gap: 6px; }
.ov-network .panel-head svg { width: 14px; height: 14px; }
.ov-net-total { display: flex; align-items: baseline; gap: var(--s-8); }
.ov-net-total .mono { font: 600 var(--fs-28)/1 var(--font-mono); }
.ov-split { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); margin: var(--s-16) 0 var(--s-8); }
.ov-split i { display: block; height: 100%; background: var(--tc); min-width: 0; }
.ov-net-rows { margin: 0; }
.ov-net-rows div { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--hair); }
.ov-net-rows div.sub { padding-top: 0; border-top: 0; font-size: var(--fs-12); color: var(--text-muted); }
.ov-net-rows dt { display: inline-flex; align-items: center; gap: var(--s-8); }
.ov-net-rows dd { margin: 0; font-weight: 600; }

@media (max-width: 1100px) {
  .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-pipe { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .ov-summary { flex-wrap: wrap; }
  .ov-summary .btn { flex: 1 1 100%; }
  .ov-money { grid-template-columns: minmax(0, 1fr); gap: var(--s-8); }
  .ov-pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-8); }
  .ov-stage + .ov-stage::before { content: none; }
  .ov-track { width: 120px; }
  .ov-chart { height: 140px; }
}
@media (max-width: 480px) {
  .ov-kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ==================================================================
   PHASE 4 — ORDERS (Dynasty Ledger)
   Same ids / classes app.js uses (#orderCards .ocard[data-st], #orderChips .chip,
   #ordersTable .olist-row, #loosePdfs .ostrip); new classes are presentation only.
   ================================================================== */

/* queue cards: icon chip · label · big number */
.ocards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-12); margin-bottom: var(--s-16); }
.ocard.oq { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: var(--s-12); row-gap: 2px;
  align-items: center; padding: 14px 16px; min-height: 72px; }
.ocard.oq .ov-chip { grid-row: 1 / span 2; }
.ocard.oq .ocard-label { grid-column: 2; grid-row: 1; line-height: 1.3; }
.ocard.oq .ocard-sub { grid-column: 2; grid-row: 2; line-height: 1.35; }
.ocard.oq .ocard-n { grid-column: 3; grid-row: 1 / span 2; font: 600 22px/1 var(--font-mono); }
.ocard.oq.zero .ocard-n { color: var(--text-muted); }
/* tone = the 3px left bar + icon chip only; the old coloured borders (incl. a purple outside the tokens) go */
.ocard.oq.warn, .ocard.oq.bad, .ocard.oq.info, .ocard.oq.pro { border-color: var(--border); }
.ocard.oq.active { border-color: var(--accent); }
.ocard.oq:hover { border-color: var(--line); background: var(--surface); }
.ocard.oq:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* filter chips: colour dot + label + count */
.chip .cdot { width: 8px; height: 8px; border-radius: 50%; background: var(--tc); flex: none; }
.chip.zero .n { color: var(--text-muted); background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.od-head { flex-wrap: wrap; row-gap: var(--s-12); }
.od-head .chips { flex: 1 1 auto; min-width: 0; }
.od-head .search .input { width: 260px; }

/* order list: Code · Customer → Supplier · Status & progress · Time · Actions */
.od-panel .olist-head, .od-panel .olist-row {
  /* every row is its own grid, so every column has a fixed rule (an "auto" column would differ per row) */
  grid-template-columns: minmax(130px, 1fr) minmax(170px, 1.25fr) minmax(190px, 1.35fr) 110px 330px;
  gap: var(--s-16); padding: 12px 18px;
}
.od-panel .olist-head { padding-top: 10px; padding-bottom: 10px; text-transform: uppercase; }
.od-panel .olist-head .od-r { text-align: right; }
.od-panel .olist-row { box-shadow: inset 3px 0 0 var(--row-c, transparent); }
.od-panel .olist-row.rv-delivered, .od-panel .olist-row.rv-cancelled, .od-panel .olist-row.rv-waiting { --row-c: transparent; }
.od-panel .olist-row.rv-cancelled .code, .od-panel .olist-row.rv-cancelled .od-cust { color: var(--text-muted); }
.od-panel .olist-who { display: flex; align-items: center; gap: var(--s-12); min-width: 0; }
.od-pair { display: inline-flex; flex: none; gap: 3px; }
/* text sub-lines (notes, supplier name) in the body font; numbers/time stay mono */
.od-panel .olist-st .cell-sub, .od-names .cell-sub, .od-panel .olist-code .cell-sub { font-family: var(--font-body); }
.od-names { display: flex; flex-direction: column; min-width: 0; }
.od-cust { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.od-names .cell-sub { margin-top: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.od-panel .olist-st { gap: 6px; }
.od-panel .olist-st .ov-track { margin: 2px 0; }
.od-panel .olist-time { align-items: flex-end; text-align: right; gap: 2px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.od-panel .olist-act { justify-content: flex-end; gap: var(--s-8); }
@media (max-width: 1350px) {
  .od-panel .olist-head, .od-panel .olist-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.3fr) 110px; }
  .od-panel .olist-act { grid-column: 1 / -1; justify-content: flex-start; margin-top: 0; }
  .od-panel .olist-act:not(:empty) { padding-top: 2px; }
}

/* Bot switch before the first status answer: neither ON nor OFF (dashed pill, no knob, muted text) */
.topbar .switch.bot-unknown { border-style: dashed; background: transparent; cursor: progress; }
.switch.bot-unknown .track { background: var(--surface-2); border-color: var(--line); opacity: 1; }
.switch.bot-unknown .track::after { opacity: 0; }
.switch.bot-unknown #botToggleText { color: var(--text-muted); }

/* ✋ হাতে / অমিল strip + panel */
.ostrip { display: flex; align-items: center; margin-bottom: var(--s-16); }
.ostrip.due { box-shadow: inset 3px 0 0 var(--danger); }
.ostrip.open { margin-bottom: 0; border-radius: var(--radius-card) var(--radius-card) 0 0; border-bottom-color: var(--hair); }
.ostrip .ostrip-icon { font-size: inherit; }
.ostrip-text { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-13); color: var(--text-muted); }
.ostrip-text b { color: var(--text); font-weight: 600; }
.ostrip-k { color: var(--text); font-weight: 600; }
.ostrip.open + .panel { margin-top: 0; border-top: 0; border-radius: 0 0 var(--radius-card) var(--radius-card); }
.od-sub { display: flex; align-items: flex-start; gap: var(--s-12); padding: 16px 18px 12px; border-top: 1px solid var(--hair); }
.od-loose-panel > .od-sub:first-child { border-top: 0; }
.od-sub p { margin: 0; font-size: var(--fs-13); }
.od-sub-note { display: block; margin-top: 4px; font-size: var(--fs-12); color: var(--text-muted); }

@media (max-width: 767px) {

  .ocards .ocard.oq:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .ocard.oq { padding: 10px 12px; column-gap: 10px; min-height: 64px; }
  .ocard.oq .ov-chip { width: 28px; height: 28px; }
  .ocard.oq .ocard-n { font-size: 20px; }
  .od-head .search .input { width: 100%; }
}
/* very small phones: the icon chip is decoration (tone stays in the left bar) — give the text the room */
@media (max-width: 400px) {
  .ocard.oq { grid-template-columns: minmax(0, 1fr) auto; }
  .ocard.oq .ov-chip { display: none; }
  .ocard.oq .ocard-label, .ocard.oq .ocard-sub { grid-column: 1; }
  .ocard.oq .ocard-n { grid-column: 2; }
}

/* phones: the menu is one sideways strip — group labels would only take room */
@media (max-width: 767px) {
  .nav-group { display: none; }
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 767px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { min-width: 0; }
  .sidebar { min-width: 0; position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 10px 12px; border-bottom: 0; }
  .brand > div { display: none; }
  .brand svg { width: 32px; height: 32px; }
  .nav { flex-direction: row; padding: 8px 8px 8px 0; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 8px 11px; white-space: nowrap; font-size: 13px; }
  .nav a.active::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 2px; border-radius: 2px; }
  .side-foot { display: none; }
  .topbar { position: static; padding: 12px 16px; flex-wrap: wrap; }
  .topbar .sub { display: none; }
  .view { padding: 16px 16px 40px; }
  .savebar { margin: 18px -16px -40px; padding: 12px 16px; }
  .search .input { width: 100%; }
  .search { flex: 1; min-width: 160px; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .stat .v { font-size: 20px; }
  .stat.accent .v { font-size: 22px; }
  .conn { grid-template-columns: 1fr; justify-items: center; }

  .hero { flex-wrap: wrap; }

  /* tables -> stacked cards */
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.t.stack tbody tr:last-child { border-bottom: 0; }
  table.t.stack td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right;  min-width: 0; overflow-wrap: anywhere; flex-wrap: wrap; column-gap: 12px; row-gap: 2px; }
  table.t.stack td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-12); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  table.t.stack td.actions { justify-content: flex-end; padding-top: 8px; flex-wrap: wrap;  gap: 8px; }
  table.t.stack td.actions::before { content: none; }

  table.t.stack tr.orow { box-shadow: inset 4px 0 0 var(--row-c, transparent); }
  table.t.stack tr.orow td:first-child { box-shadow: none; }
  .ocards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .olist-head { display: none; }
  .olist-row { grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 14px 12px 16px; }
  .olist-code { grid-column: 1; }
  .olist-time { grid-column: 2; grid-row: 1; text-align: right; }
  .olist-who, .olist-st, .olist-act { grid-column: 1 / -1; }
  .olist-act { justify-content: flex-start; }
  .ocard { padding: 10px 12px; }
  .ocard-n { font-size: 22px; }
  .timeline li { grid-template-columns: 52px 1fr; }
  .timeline .txt { grid-column: 1 / -1; white-space: normal; }
}

/* ==================================================================
   Mobile / tablet additions. Everything below is inside a media query
   for small screens or touch input, so the desktop look is unchanged.
   ================================================================== */

/* ---- 1. Touch screens: every tap target at least 44px ---- */
@media (pointer: coarse) {
  .btn, .btn.sm { height: auto; min-height: 44px; }
  .btn.sm { padding: 0 12px; }
  .icon-btn, .btn.icon-btn { min-width: 44px; }
  .chip { height: auto; min-height: 44px; }
  .nav a { min-height: 44px; }
  .switch { min-height: 44px; }
  .switch .track { width: 46px; height: 28px; }
  .switch .track::after { width: 22px; height: 22px; }
  .switch input:checked + .track::after { transform: translateX(18px); }
  .switch.radio .track { width: 22px; height: 22px; }
  .switch.radio .track::after { top: 5px; left: 5px; width: 10px; height: 10px; }
  .switch.radio input:checked + .track::after { transform: none; }
  /* 16px text in inputs: iPhone does not zoom in when typing */
  .input, .field input:not([type=checkbox]), .field select, .field textarea, select.input, .assign select {
    min-height: 44px; font-size: 16px;
  }
  .assign select { height: auto; }
  /* A tapped item keeps its hover colour on phones — not for menu tabs and filter chips */
  .nav a:not(.active):hover { background: transparent; color: var(--muted); }
  .chip:not(.active):hover { background: transparent; color: var(--muted); }
  /* Explanations that were only a mouse-hover tooltip: shown under the item */
  .hcell[title]::after { content: attr(title); font-size: var(--fs-12); line-height: 1.35; color: var(--muted); }
}

/* ---- 2. Tables become cards on phones (label beside every value) ---- */
@media (max-width: 767px) {

  /* a value's small second line goes under it, not beside it */
  table.t.stack td > .cell-sub { flex-basis: 100%; text-align: right; }
  table.t.stack td > :not(.btn) { min-width: 0; }

  table.t.stack td.actions > * + * { margin-left: 0; }
  /* group heading rows (Contacts): full width, no label */
  table.t.stack tr.group-row { padding: 0; }
  table.t.stack tr.group-row td { justify-content: flex-start; text-align: left; padding: 8px 14px; }
  table.t.stack tr.group-row td::before { content: none; }
  /* a cell's hover explanation (e.g. Accounting "Stuck") written under its value */
  table.t.stack td[title] { flex-wrap: wrap; }
  table.t.stack td[title]::after { content: attr(title); flex-basis: 100%; text-align: left; font: 400 var(--fs-12)/1.35 var(--font-body); color: var(--muted); }
  /* long order text: wrap instead of "…" (the full text was only on hover) */
  .olist-code .cell-sub { white-space: normal; overflow-wrap: anywhere; }
}

/* ---- 3. Phones (≤767px): page by page, nothing wider than the screen ---- */
@media (max-width: 767px) {
  .topbar h1 { font-size: 17px; }
  /* Overview: running-orders list wraps instead of pushing the page wider */
  .list li { flex-wrap: wrap; gap: 4px 10px; padding: 10px 14px; }
  .list .who { flex: 1 1 100%; order: 3; white-space: normal; }
  .health { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .hcell { padding: 10px 12px; }
  .timeline { max-height: 360px; }
  .timeline li { padding: 8px 14px; }
  /* Orders: filter chips in one sideways strip (only the strip moves), search full width */
  .panel-head .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; padding-bottom: 2px; }
  .panel-head .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .ostrip { flex-wrap: wrap; }

  .ostrip .btn { flex: 1 1 100%; }
  .olist-act { flex-wrap: wrap; }
  /* Forms: one column, label above its input */
  .form-grid, .view .form-grid[style] { grid-template-columns: minmax(0, 1fr) !important; }

  .panel-body { padding: 14px; }
  .hero { padding: 16px; gap: 14px; }
  .savebar { flex-wrap: wrap; }
  .savebar .muted { flex: 1 1 100%; margin-right: 0; }
  .savebar .btn { flex: 1; }
  /* Pop-ups and side panel: fit the screen (dvh = space left by the browser's own bars) */
  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .drawer { width: 100vw; }
  .dlg-head { padding: 12px 14px; }
  .dlg-body { padding: 14px; }
  .dlg-foot { padding: 12px 14px; flex-wrap: wrap; }
  .dlg-foot .btn { flex: 1 1 auto; }
  /* Connection: QR shrinks to the screen */
  .qr-tile { width: min(292px, 100%); height: auto; aspect-ratio: 1; padding: 12px; }
  .qr-tile img { width: 100%; height: auto; max-width: 260px; }
  .conn > * { min-width: 0; max-width: 100%; }
  /* Toasts across the bottom */
  .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { min-width: 0; max-width: none; }
  /* Things given a fixed minimum width for desktop rows (bulk banner, Danger zone, filters) */
  .view [style*="min-width:2"] { min-width: min(100%, 220px) !important; }
  .view [style*="max-width:320px"] { max-width: 100% !important; }
}

/* ---- 4. Small phones (≤480px, e.g. iPhone SE / 360px Android) ---- */
@media (max-width: 480px) {
  .view { padding: 12px 12px 36px; }
  .savebar { margin: 18px -12px -36px; padding: 10px 12px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar > div:first-child { flex: 1 1 100%; }
  .topbar .spacer { display: none; }
  .topbar #logoutBtn { margin-left: auto; }
  .grid-stats { gap: 8px; }
  .stat { padding: 12px; min-height: 84px; }
  .stat .v { font-size: 18px; }
  .stat.accent .v { font-size: 20px; }
  .ocards { gap: 6px; }
  .ocard-label { font-size: 13px; }
  .panel-head { padding: 12px 14px; }
  .view [style*="min-width:2"] { min-width: 0 !important; flex-basis: 100% !important; }

  .hero .btn { flex: 1 1 100%; }
}

/* ---- 5. Touch tablets (768–1024px, e.g. iPad). Only touch screens: a desktop browser window
   of the same width (mouse) keeps the desktop look. ---- */
@media (pointer: coarse) and (min-width: 768px) and (max-width: 1024px) {
  .shell { grid-template-columns: 216px minmax(0, 1fr); }
  .brand { gap: 10px; padding: 18px 14px 16px; }
  .brand svg { width: 34px; height: 34px; }
  .brand-name { font-size: 13px; letter-spacing: .12em; }
  .topbar { padding: 14px 20px; }
  .view { padding: 20px 20px 44px; }
  .savebar { margin: 18px -20px -44px; padding: 14px 20px; }
  .grid-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
  .conn { grid-template-columns: 1fr; justify-items: center; }
  .conn > * { min-width: 0; max-width: 100%; }
  /* tables as cards here too (wide tables would otherwise scroll sideways) */
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.t.stack tbody tr:last-child { border-bottom: 0; }
  table.t.stack td { border: 0; padding: 4px 0; display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 12px; row-gap: 2px; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  table.t.stack td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-12); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  table.t.stack td > .cell-sub { flex-basis: 100%; text-align: right; }
  table.t.stack td.actions { justify-content: flex-end; padding-top: 8px; gap: 8px; }
  table.t.stack td.actions::before { content: none; }
  table.t.stack td.actions > * + * { margin-left: 0; }
  table.t.stack tr.group-row { padding: 0; }
  table.t.stack tr.group-row td { justify-content: flex-start; text-align: left; padding: 8px 14px; }
  table.t.stack tr.group-row td::before { content: none; }

  table.t.stack tr.orow td:first-child { box-shadow: none; }
  table.t.stack tr.orow { box-shadow: inset 4px 0 0 var(--row-c, transparent); }
}

/* ---- 7. Login on phones: fits and stays reachable when the keyboard opens ---- */
@media (max-width: 480px) {
  .login-wrap { min-height: 100vh; min-height: 100dvh; padding: 16px 12px; }
  .login-card { padding: 26px 18px 22px; }
  .login-card .logo { width: 58px; height: 58px; margin-bottom: 12px; }
  .login-card .brand-name { font-size: 17px; }
  .login-card .brand-sub { margin: 8px 0 20px; }
  .tagline { margin-top: 16px; }
}

/* ---- 8. Orders list on phones (Phase 4): each order is a small card ---- */
@media (max-width: 767px) {
  .od-panel .olist-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 12px 14px 12px 16px; }
  .od-panel .olist-code { grid-column: 1; grid-row: 1; }
  .od-panel .olist-time { grid-column: 2; grid-row: 1; }
  .od-panel .olist-who, .od-panel .olist-st, .od-panel .olist-act { grid-column: 1 / -1; }
  .od-panel .olist-act { justify-content: flex-start; }
  .od-panel .olist-act .btn { flex: 1 1 auto; }
  .od-cust, .od-names .cell-sub { white-space: normal; overflow-wrap: anywhere; }
  .ostrip.open + .panel { border-top: 1px solid var(--border); }
  .ostrip-text { flex: 1 1 calc(100% - 48px); }
  .od-head .spacer { display: none; }
  .od-head .search { flex: 1 1 100%; }
  .od-sub { padding: 14px; }
}
/* ---- 9. Orders list by its OWN width (container query): when the list is narrow — tablet in
   portrait, a small desktop window — each order becomes the same small card as on phones. ---- */
.od-panel { container: odlist / inline-size; }
@container odlist (max-width: 760px) {
  .od-panel .olist-head { display: none; }
  .od-panel .olist-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 12px 14px 12px 16px; }
  .od-panel .olist-code { grid-column: 1; grid-row: 1; }
  .od-panel .olist-time { grid-column: 2; grid-row: 1; }
  .od-panel .olist-who, .od-panel .olist-st, .od-panel .olist-act { grid-column: 1 / -1; }
  .od-panel .olist-act { justify-content: flex-start; }
  .od-cust, .od-names .cell-sub { white-space: normal; overflow-wrap: anywhere; }
  .od-panel .olist-code .code { overflow-wrap: anywhere; }
}

/* ==================================================================
   PHASE 5 — INBOX · CONTACTS · ROUTING (from the approved concept)
   ================================================================== */
/* shared: who-cell = avatar + name + sub-line */
.p5-who { display: flex; align-items: center; gap: var(--s-12); min-width: 0; }
.p5-who .ov-av { width: 28px; height: 28px; font-size: 11px; }
.p5-who-t { display: flex; flex-direction: column; min-width: 0; }
.p5-who-t b { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p5-who-t .cell-sub { margin-top: 0; font-family: var(--font-body); }
.p5-id { font: 500 var(--fs-12) var(--font-mono); color: var(--text-muted); }
.p5-count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 8px; border-radius: 11px;
  font: 600 var(--fs-12)/1 var(--font-mono); color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.p5-count.t-warn { background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); }
.p5-count.zero { color: var(--text-muted); background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.p5-note { display: flex; align-items: flex-start; gap: var(--s-12); padding: 14px 18px; margin-bottom: var(--s-16);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); font-size: var(--fs-13); color: var(--text-muted); }
.p5-note b { color: var(--text); font-weight: 600; }
.p5-note p { margin: 0; }
.p5-foot { display: flex; align-items: center; gap: var(--s-8); font-size: var(--fs-12); color: var(--text-muted); margin: 0 2px var(--s-16); }
.p5-foot svg { width: 14px; height: 14px; flex: none; }
.panel-head .p5-count { margin-left: -4px; }

/* Inbox */
.ib-msg { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ib-table td { vertical-align: middle; }
.ib-table td[data-label="Message"] .cell-sub { font-family: var(--font-body); }

/* Contacts */
.ct-tools { flex-wrap: wrap; row-gap: var(--s-12); column-gap: var(--s-8); }
.ct-tools .chips { flex: 0 1 auto; margin-right: var(--s-8); }
.ct-tools .search .input { width: 220px; }
.ct-table tr.group-row td { padding: 14px 18px 8px; background: var(--surface); border-bottom: 1px solid var(--line);
  font: 600 var(--fs-12)/1 var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.ct-table tr.group-row td .gdot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--tc); margin-right: 8px; vertical-align: 2px; }
.ct-table tr.group-row td .gn { font-family: var(--font-mono); color: var(--text); margin-left: 6px; letter-spacing: 0; }
.ct-table tbody tr.group-row:hover { background: transparent; }
.ct-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ct-rate { font: 600 var(--fs-13) var(--font-mono); }
.ct-state { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-12); color: var(--text); }
.ct-state.off { color: var(--text-muted); }
.t tr.inactive td { opacity: 1; }
.t tr.inactive td > * { opacity: .6; }
.t tr.inactive td.actions > * { opacity: 1; }

/* Routing */
.rt-form { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) 120px auto; gap: var(--s-12); align-items: end;
  padding: 14px 18px; background: var(--bg); border-bottom: 1px solid var(--border); }
.rt-form .btn { height: var(--control-h); }
.rt-form .field .hint { display: inline; margin-left: 6px; }
.rt-alerts { padding: 16px 18px 0; }
.rt-alerts .alert:last-child { margin-bottom: 16px; }
.rt-route { display: flex; align-items: center; gap: var(--s-12); flex-wrap: wrap; }
.rt-route .cat { font-size: var(--fs-12); }
.rt-arrow { width: 28px; height: 1px; background: var(--line); position: relative; flex: none; }
.rt-arrow::after { content: ''; position: absolute; right: 0; top: -3px; border: 3.5px solid transparent; border-left: 5px solid var(--line); border-right: 0; }
.rt-sup { display: inline-flex; align-items: center; gap: var(--s-8); font-weight: 600; }
.rt-sup .ov-av { width: 24px; height: 24px; font-size: 10px; }
.rt-flag { font-weight: 400; color: var(--text-muted); font-size: var(--fs-12); }
.rt-flag::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin-right: 6px; vertical-align: 1px; }
.rt-prio { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font: 600 var(--fs-12)/1 var(--font-mono);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--text); }
.rt-table tr.editing { background: var(--wash); box-shadow: inset 3px 0 0 var(--accent); }
.rt-table tr.editing select.input { min-width: 180px; height: var(--control-h-sm); }

/* Narrow panel (tablet portrait / small window with a mouse): same card rows as phones,
   decided by the panel's own width (like the approved Orders list), so tables never scroll sideways. */
.p5-panel { container: p5 / inline-size; }
@container p5 (max-width: 760px) {
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.t.stack tbody tr:last-child { border-bottom: 0; }
  table.t.stack td { border: 0; padding: 4px 0; display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 12px; row-gap: 2px; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  table.t.stack td::before { content: attr(data-label); color: var(--text-muted); font-size: var(--fs-12); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  table.t.stack td > .cell-sub { flex-basis: 100%; text-align: right; }
  table.t.stack td.actions { justify-content: flex-end; padding-top: 8px; gap: 8px; }
  table.t.stack td.actions::before { content: none; }
  table.t.stack td.actions > * + * { margin-left: 0; }
  table.t.stack.ct-table tr.group-row { padding: 0; }
  table.t.stack.ct-table tr.group-row td { display: block; text-align: left; padding: 12px 14px 8px; }
  table.t.stack.ct-table tr.group-row td::before { content: none; }
  table.t.stack td[data-label="Customer"], table.t.stack td[data-label="Name"], table.t.stack td[data-label="WhatsApp"], table.t.stack td[data-label="Route"] { flex-direction: column; align-items: flex-start; text-align: left; }
  .ib-msg { max-width: 100%; white-space: normal; }
  .rt-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .rt-form { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .rt-form .btn { width: 100%; }
  .rt-alerts { padding: 14px 14px 0; }
  .ib-msg { max-width: 100%; white-space: normal; }
  .ct-tools .btn { flex: 1 1 auto; }
  .ct-tools .search { flex: 1 1 100%; }
  .ct-tools .search .input { width: 100%; }
  .ct-tools .spacer { display: none; }
  table.t.stack.ct-table tr.group-row td { display: block; padding: 12px 14px 8px; }
  .p5-who-t b { white-space: normal; }
  table.t.stack td[data-label="Customer"], table.t.stack td[data-label="Name"], table.t.stack td[data-label="WhatsApp"], table.t.stack td[data-label="Route"] { flex-direction: column; align-items: flex-start; text-align: left; }
}

/* ==================================================================
   PHASE 6 — ACCOUNTING · SETTINGS · CONNECTION (from the approved concept)
   ================================================================== */
/* shared card header: icon chip + title + one quiet line */
.p6-head { display: flex; align-items: center; gap: var(--s-12); }
.p6-head-t { display: flex; flex-direction: column; min-width: 0; }
.p6-head-t h2 { margin: 0; }
.p6-head-t span { font-size: var(--fs-12); color: var(--text-muted); }

/* bulk banner (shared with Overview): tokens only */
.p6-bulk { display: flex; align-items: center; gap: var(--s-16); flex-wrap: wrap; padding: 14px 18px; margin-bottom: var(--s-16);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: inset 3px 0 0 var(--info); }
.p6-bulk-jobs { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-13); }
.p6-bulk-bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.p6-bulk-bar i { display: block; height: 100%; background: var(--info); }
.p6-bulk-note { font-size: var(--fs-12); color: var(--text-muted); }

/* Accounting — top row: balance position + lifetime */
.ac-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); gap: var(--s-16); margin-bottom: var(--s-16); }
.ac-top > .panel { margin-bottom: 0; }
/* A2: Accounting tabs */
.ac-top[hidden], .ac-send .row[hidden] { display: none; }
.ac-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--s-16); padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; width: fit-content; max-width: 100%; }
.ac-tab { border: 0; background: transparent; color: var(--text-muted); font: 600 var(--fs-13)/1 var(--font-body); padding: 9px 14px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.ac-tab:hover { color: var(--text); }
.ac-tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.ac-tab-n { font: 500 12px var(--font-mono); color: var(--text-muted); }
.ac-tab-n.t-bad { color: var(--danger); } .ac-tab-n.t-warn { color: var(--warn); }
.ac-one { display: flex; align-items: center; gap: var(--s-16); padding: 16px 18px; flex-wrap: wrap; }
.ac-one > div:not(.r) { flex: 1; min-width: 160px; }
.ac-one .k { font-size: 12px; color: var(--text-muted); }
.ac-one .v { font: 700 24px/1.2 var(--font-head); }
.ac-one .s { font-size: 12px; color: var(--text-muted); }
.ac-one .r { text-align: right; }
@media (max-width: 560px) { .ac-tabs { width: 100%; } .ac-tab { flex: 1; justify-content: center; padding: 9px 6px; flex-direction: column; } .ac-one .r { text-align: left; } }
.ac-pos { display: grid; grid-template-columns: minmax(0, 1fr) 168px minmax(0, 1fr); align-items: center; gap: var(--s-24); padding: 24px 20px; }
.ac-side h3 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font: 600 var(--fs-12)/1.2 var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.ac-side .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--tc); flex: none; }
.ac-amt { font: 600 var(--fs-28)/1.1 var(--font-mono); letter-spacing: -.02em; }
.ac-side .s { font-size: var(--fs-12); color: var(--text-muted); margin-top: 4px; }
.ac-side.pay { text-align: right; }
.ac-side.pay h3 { justify-content: flex-end; }
.ac-ring { position: relative; width: 168px; height: 168px; margin: 0 auto; }
.ac-ring svg { display: block; width: 100%; height: 100%; }
.ac-ring .mid { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ac-ring .k { font: 600 var(--fs-12)/1 var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.ac-ring .v { font: 600 var(--fs-20)/1.2 var(--font-mono); margin-top: 6px; }
.ac-ring .s { font-size: var(--fs-12); color: var(--text-muted); }
.ac-life { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-12); padding: 16px 18px; }
.ac-lf { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--bg); min-width: 0; }
.ac-lf .k { font-size: var(--fs-12); color: var(--text-muted); }
.ac-lf .v { font: 600 var(--fs-20)/1.2 var(--font-mono); margin-top: 4px; }
.ac-lf .s { font-size: var(--fs-12); color: var(--text-muted); }
.ac-lf.wide { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s-16); }
.ac-lf.wide .r { margin-left: auto; text-align: right; }

/* Accounting — bills & reminders panel */
.ac-send .row { display: flex; align-items: center; gap: var(--s-16); flex-wrap: wrap; padding: 16px 18px; }
.ac-send .row + .row { border-top: 1px solid var(--border); }
.ac-send .t { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 2px; }
.ac-send .t b { font: 600 var(--fs-15)/1.3 var(--font-head); }
.ac-send .t span { font-size: var(--fs-13); color: var(--text-muted); }
.ac-send .t .mono { color: var(--text); }

/* Accounting — ledgers */
.ac-table td { vertical-align: middle; }
.ac-table td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ac-due { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ac-d { display: inline-flex; align-items: center; gap: 8px; font: 600 var(--fs-13) var(--font-mono); color: var(--text); }
.ac-d::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--tc); flex: none; }
.ac-d.zero { color: var(--text-muted); font-weight: 400; }
.ac-d.zero::before { content: none; }
.ac-bar { width: 72px; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.ac-bar i { display: block; height: 100%; background: var(--tc); }
.ac-flag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.ac-flag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.ac-zero { color: var(--text-muted); }
.ac-table .p5-who-t .cell-sub { font-family: var(--font-mono); }

/* Settings */
.st-sec .panel-head { border-bottom: 1px solid var(--border); }
.st-sec .panel-body { padding: 18px; }
.st-switches { display: flex; flex-direction: column; margin-top: var(--s-16); border-top: 1px solid var(--hair); }
.st-switches .switch { padding: 12px 0; border-bottom: 1px solid var(--hair); width: 100%; }
.st-msgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s-16); }
.st-msgs .field { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--bg); }
.st-danger { box-shadow: inset 3px 0 0 var(--danger); }
.st-danger .row { display: flex; align-items: center; gap: var(--s-16); flex-wrap: wrap; padding: 18px; }
.st-danger .t { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
.st-danger .k { display: inline-flex; align-items: center; gap: 8px; font: 600 var(--fs-12)/1 var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.st-danger .k::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.st-danger .t b { font: 600 var(--fs-15)/1.3 var(--font-head); }
.st-danger .t span { font-size: var(--fs-13); color: var(--text-muted); }
.st-dirty { display: inline-flex; align-items: center; gap: 8px; }
.st-dirty.on::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.st-dirty.on { color: var(--text) !important; }

/* Connection */
.cn-grid { display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: var(--s-32); padding: 24px; align-items: start; }
.cn-tile-ok { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text); font-size: var(--fs-13); }
.cn-tile-ok .ov-chip { width: 56px; height: 56px; }
.cn-tile-ok .ov-chip svg { width: 28px; height: 28px; }
.cn-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font: 600 var(--fs-20)/1.2 var(--font-head); }
.cn-kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); margin: 0 0 20px; border-top: 1px solid var(--hair); font-size: var(--fs-13); }
.cn-kv dt, .cn-kv dd { padding: 10px 0; border-bottom: 1px solid var(--hair); margin: 0; }
.cn-kv dt { color: var(--text-muted); }
.cn-err { display: inline-flex; align-items: flex-start; gap: 8px; font: var(--fs-12)/1.5 var(--font-mono); color: var(--text); }
.cn-err::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-top: 6px; flex: none; }
.cn-steps { list-style: none; counter-reset: s; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: var(--fs-13); }
.cn-steps li { counter-increment: s; display: flex; align-items: center; gap: 12px; }
.cn-steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 600 var(--fs-12)/1 var(--font-mono); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.cn-link { display: flex; gap: var(--s-16); align-items: center; flex-wrap: wrap; padding: 14px; margin: 0 0 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.cn-link img { width: 96px; height: 96px; border-radius: var(--radius); background: #fff; padding: 4px; flex: none; }
.cn-link .t { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.cn-link .t b { font-weight: 600; }
.cn-link a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; font-family: var(--font-mono); font-size: var(--fs-13); overflow-wrap: anywhere; }
.cn-link a:hover { text-decoration-color: var(--text); }
.cn-link .t span { font-size: var(--fs-12); color: var(--text-muted); }
.cn-out { display: flex; align-items: center; gap: var(--s-16); flex-wrap: wrap; padding-top: 4px; }
.cn-out span { font-size: var(--fs-12); color: var(--text-muted); }

/* narrow panels: tables become cards by the panel's own width (as Phases 4–5) */
.p6-panel { container: p6 / inline-size; }
@container p6 (max-width: 860px) {
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.t.stack tbody tr:last-child { border-bottom: 0; }
  table.t.stack td { border: 0; padding: 4px 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; column-gap: 12px; row-gap: 2px; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  table.t.stack td::before { content: attr(data-label); color: var(--text-muted); font: 400 var(--fs-12) var(--font-body); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  table.t.stack td > .cell-sub { flex-basis: 100%; text-align: right; }
  table.t.stack td.actions { justify-content: flex-end; padding-top: 8px; gap: 8px; }
  table.t.stack td.actions::before { content: none; }
  table.t.stack td.actions > * + * { margin-left: 0; }
  table.t.stack td[data-label="Name"], table.t.stack td[data-label="Supplier"] { flex-direction: column; align-items: flex-start; text-align: left; }
}
/* phone rule writes a cell's hover explanation under it: let that text wrap inside the card */
.ac-table td[title]::after { min-width: 0; flex: 1 1 100%; overflow-wrap: anywhere; white-space: normal; }
/* Connection: QR tile above the details whenever the panel is narrow (any device) */
.cn-panel { container: cn / inline-size; }
@container cn (max-width: 720px) {
  .cn-grid { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: var(--s-24); }
  .cn-grid .qr-tile { margin: 0 auto; width: min(292px, 100%); height: auto; aspect-ratio: 1; }
  .cn-grid .qr-tile svg, .cn-grid .qr-tile img { width: 100%; height: auto; max-width: 260px; }
}
@media (max-width: 1100px) {
  .ac-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .ac-pos { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-16); padding: 18px 14px; }
  .ac-ring { grid-column: 1 / -1; grid-row: 1; width: 148px; height: 148px; }
  .ac-amt { font-size: var(--fs-20); }
  .ac-life { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 14px; gap: 8px; }
  .ac-send .row, .st-danger .row { padding: 14px; }
  .ac-send .btn, .st-danger .btn { flex: 1 1 100%; }
  .cn-grid { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: var(--s-24); justify-items: stretch; }
  .cn-grid .qr-tile { margin: 0 auto; }
  .cn-kv { grid-template-columns: 110px minmax(0, 1fr); }
  .cn-out .btn { flex: 1 1 100%; }
  .st-msgs { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .ac-life .ac-lf.wide { flex-wrap: wrap; }
}

/* ==================================================================
   PHASE 7 — Overview "Running orders": cards when its panel is narrow
   (tablet portrait / small window with a mouse), same card language as
   Orders (Phase 4) and the Phase 5–6 tables. Phones (≤767 px) keep their existing card rules,
   so the container is only set from 768 px up.
   ================================================================== */
@media (min-width: 768px) { .ov-card:has(.ov-running) { container: ovrun / inline-size; } }
@container ovrun (max-width: 760px) {
  table.t.stack.ov-running thead { display: none; }
  table.t.stack.ov-running, table.t.stack.ov-running tbody, table.t.stack.ov-running tr, table.t.stack.ov-running td { display: block; width: 100%; }
  table.t.stack.ov-running tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.t.stack.ov-running tbody tr:last-child { border-bottom: 0; }
  table.t.stack.ov-running td { border: 0; padding: 4px 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; column-gap: 12px; row-gap: 2px; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  table.t.stack.ov-running td::before { content: attr(data-label); color: var(--text-muted); font: 400 var(--fs-12) var(--font-body); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  table.t.stack.ov-running td > .cell-sub { flex-basis: 100%; text-align: right; }
  table.t.stack.ov-running .ov-who { white-space: normal; }
}

/* ==================================================================
   PHASE 8 · B1 — secondary text (.cell-sub) in the interface font;
   data sub-lines keep monospace: phone numbers (.mono), times on the
   Overview running list, #ids in the Orders time column, PDF codes.
   Size, colour and line-height unchanged.
   ================================================================== */
.cell-sub { font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.cell-sub.mono,
.ov-running td .cell-sub,
.od-panel .olist-time .cell-sub:last-child,
.t td[data-label="File"] .cell-sub { font-family: var(--font-mono); }

/* ==================================================================
   PHASE 8 · B3 — popup texts that app.js sizes inline (12.5 / 13.5 px)
   brought onto the type scale. Attribute selector + !important is the
   only CSS way to reach inline styles; only those elements carry them.
   ================================================================== */
[style*="font-size:12.5px"] { font-size: var(--fs-12) !important; }
[style*="font-size:13.5px"] { font-size: var(--fs-13) !important; }

/* =============================================================
   LONG-NAME FIX — long customer names wrap instead of widening the table
   (>=768: desktop tables + 768 cards). Phones (<=767) already wrap via the existing rule.
   ============================================================= */
@media (min-width: 768px) {
  .p5-who-t b {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* =============================================================
   DAILY LEDGER — today's columns (Asia/Dhaka day) tinted so they stand apart from lifetime figures.
   ============================================================= */
.ac-table th.ac-today { color: var(--accent); }
.ac-table th.ac-today, .ac-table td.ac-today { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.ac-table td.ac-today b { color: var(--text); font-weight: 600; }
.ac-table thead th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
.ac-table thead th.num { min-width: 52px; white-space: normal; }
.ac-table th, .ac-table td { padding-left: 8px; padding-right: 8px; }
.ac-table td.actions { gap: 6px; }
.ac-table th:first-child, .ac-table td:first-child { padding-left: 14px; }

/* ---------- T9: Wallet page redesign ---------- */
.w-kpis { display: grid; grid-template-columns: minmax(0, 1.8fr) repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1280px) { .w-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.w-kpi { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.w-kpi .lbl { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.w-kpi .ico { width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; flex: none; }
.w-kpi .ico svg { width: 15px; height: 15px; }
.w-kpi .val { font: 600 24px/1.1 var(--font-mono, ui-monospace, monospace); color: var(--text); letter-spacing: -.01em; }
.w-kpi .sub { font-size: 11.5px; color: var(--text-muted); overflow-wrap: anywhere; }
.w-kpi.hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.w-kpi.hero .val { font-size: 34px; }
.t-g { background: color-mix(in srgb, #3E9B6B 18%, transparent); color: #5fc08c; }
.t-r { background: color-mix(in srgb, #C7413C 18%, transparent); color: #e2726d; }
.t-a { background: color-mix(in srgb, #d79b2b 18%, transparent); color: #e6b24f; }
.t-b { background: color-mix(in srgb, #4b82c9 18%, transparent); color: #78a7e6; }
.w-kpi .up, .w-wl .up, .w-tl .up { color: #5fc08c; }
.w-kpi .down, .w-wl .down, .w-tl .down { color: #e2726d; }
.w-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .w-grid { grid-template-columns: minmax(0, 1fr); } }
.w-card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); min-width: 0; }
.w-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.w-head h2 { margin: 0; font-size: 15px; }
.w-count { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, #d79b2b 22%, transparent); color: #e6b24f; font-weight: 600; }
.w-head .seg { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--text-muted); padding: 6px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.seg button.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.w-search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 9px; padding: 4px 10px; color: var(--text-muted); min-width: 170px; flex: 1 1 170px; max-width: 260px; }
.w-search svg { width: 14px; height: 14px; flex: none; }
.w-search input { background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 12.5px; width: 100%; padding: 2px 0; }
.w-av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--text); flex: none; }
.w-rq, .w-wl { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.w-rq:last-child, .w-wl:last-child { border-bottom: 0; }
.w-wl.inactive { opacity: .6; }
.w-rq .who, .w-wl .who { min-width: 0; }
.w-rq .who b, .w-wl .who b { font-weight: 600; }
.w-rq .meta { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 8px 10px; flex-wrap: wrap; margin-top: 3px; }
.w-rq .trx { font-family: var(--font-mono, ui-monospace, monospace); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); }
.w-rq .side, .w-wl .side { text-align: right; }
.w-rq .amt { font: 600 17px var(--font-mono, ui-monospace, monospace); }
.w-wl .bal { font: 600 16px var(--font-mono, ui-monospace, monospace); }
.w-rq .act, .w-wl .act { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.w-rq .st, .w-wl .st { font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.w-wl .tag { font-size: 10.5px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-muted); }
.w-wl .bar { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; margin-top: 7px; }
.w-wl .bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #e2726d); }
.w-wl .bar i.low { background: #d79b2b; }
.w-card .empty { padding: 28px 16px; }
.w-hhead { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.w-hhead .seg { margin-left: auto; }
.w-hbal { font: 600 22px var(--font-mono, ui-monospace, monospace); color: var(--text); }
.w-tl { list-style: none; margin: 0; padding: 0; }
.w-tl li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.w-tl li:last-child { border-bottom: 0; }
.w-tl .dot { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.w-tl .dot svg { width: 14px; height: 14px; }
.w-tl .d { font-size: 11.5px; color: var(--text-muted); }
.w-tl .v { font: 600 14px var(--font-mono, ui-monospace, monospace); }
@media (max-width: 640px) {
  .w-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .w-kpi.hero { grid-column: 1 / -1; }
  .w-kpi .val { font-size: 19px; }
  .w-kpi.hero .val { font-size: 26px; }
  .w-rq, .w-wl { grid-template-columns: auto minmax(0, 1fr); }
  .w-rq .side, .w-wl .side { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .w-rq .act, .w-wl .act { margin-top: 0; }
  .w-search { max-width: none; }
}
/* ---------- W: supplier service tags + service profit table ---------- */
.ct-cats { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.cat.cat-svc { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.w-pl td.num, .w-pl th.num { min-width: 96px; }
.w-pl .w-pl-tot td { border-bottom: 0; }
.w-card .up { color: #5fc08c; }
.w-card .down { color: #e2726d; }
/* ---------- Y: Bulk Add ---------- */
.bk-drop { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 38px 20px; border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 14px; background: color-mix(in srgb, var(--accent) 5%, var(--surface)); cursor: pointer; }
.bk-drop.on { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.bk-drop > b { font-size: 16px; }
.bk-drop .bk-ico svg { width: 34px; height: 34px; color: var(--text-muted); }
.bk-drop .muted { font-size: 12.5px; }
.bk-file { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.bk-file .muted { font-size: 12px; }
.bk-x { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, #3E9B6B 20%, transparent); color: #5fc08c; font-weight: 700; font-size: 12px; flex: none; }
.bk-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.bk-sum > div { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-muted); }
.bk-sum .n { font: 600 22px var(--font-mono, ui-monospace, monospace); color: var(--text); }
.bk-sum .g, .bk-st.g { color: #5fc08c; } .bk-sum .b, .bk-st.b { color: #78a7e6; } .bk-sum .y, .bk-st.y { color: #e6b24f; } .bk-sum .r, .bk-st.r { color: #e2726d; }
.bk-st { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, currentColor 14%, transparent); }
.bk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-top: 1px solid var(--border); }
.bk-done { border: 1px solid color-mix(in srgb, #3E9B6B 45%, var(--border)); background: color-mix(in srgb, #3E9B6B 8%, var(--surface)); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bk-done > b { font-size: 16px; }
.bk-actions { display: flex; gap: 8px; flex-wrap: wrap; }