/* AuFluence Core: design system, in line with the CRM (Nüdge). Rules: uiux-rules.md.
   Every colour is a token below; components use var(--...) only. */

/* ── 0. Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Brand = gold/amber: identity only (logo, hero accents). Never on controls. */
  --color-brand:         #d97706;
  --color-brand-light:   #f59e0b;
  --color-brand-rgb:     217, 119, 6;
  /* Action = indigo: every interactive element. */
  --color-action:        #4f46e5;
  --color-action-dark:   #4338ca;
  --color-action-light:  #6366f1;
  --color-action-rgb:    79, 70, 229;
  /* Indigo tints for text on dark surfaces (WCAG AA on --surface-page dark). */
  --color-action-lighter:  #818cf8;
  --color-action-lighter-rgb: 129, 140, 248;
  --color-action-lightest: #a5b4fc;
  --color-action-lightest-rgb: 165, 180, 252;
  /* Semantic. Success and danger are dark enough for text on white and for white text on
     them (4.5:1, WCAG AA); the -light tints are their text colour in dark mode. */
  --color-success:       #047857;
  --color-success-rgb:   4, 120, 87;
  --color-success-light: #34d399;
  --color-warning:       #f59e0b;
  --color-warning-rgb:   245, 158, 11;
  --color-danger:        #dc2626;
  --color-danger-rgb:    220, 38, 38;
  --color-danger-light:  #f87171;
  /* Neutrals (Slate) */
  --color-n950: #0f172a;
  --color-n900: #111827;
  --color-n700: #334155;
  --color-n500: #64748b;
  --color-n400: #94a3b8;
  --color-n300: #cbd5e1;
  --color-n100: #f1f5f9;
  --color-n50:  #f8fafc;
  --color-white: #ffffff;
  --color-black-rgb: 0, 0, 0;
  --color-white-rgb: 255, 255, 255;
  --color-border: rgba(var(--color-black-rgb), .09);

  /* Bootstrap kept in step with the system */
  --bs-primary:          var(--color-action);
  --bs-primary-rgb:      var(--color-action-rgb);
  --bs-link-color:       var(--color-action);
  --bs-link-color-rgb:   var(--color-action-rgb);
  --bs-link-hover-color: var(--color-action-dark);
  --bs-success:          var(--color-success);
  --bs-success-rgb:      var(--color-success-rgb);
  --bs-warning:          var(--color-warning);
  --bs-warning-rgb:      var(--color-warning-rgb);
  --bs-danger:           var(--color-danger);
  --bs-danger-rgb:       var(--color-danger-rgb);
  --bs-body-font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading:        "Sora", "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:           "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing (multiples of 4px) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  /* Radius */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 20px; --radius-circle: 50%;
  /* Elevation */
  --shadow-elevation-1: 0 1px 3px rgba(var(--color-black-rgb), .08);
  --shadow-elevation-2: 0 4px 12px rgba(var(--color-black-rgb), .12);
  --shadow-elevation-3: 0 4px 20px rgba(var(--color-black-rgb), .20);
  --shadow-elevation-4: 0 8px 32px rgba(var(--color-black-rgb), .24);
  /* Timing */
  --t-micro: 100ms ease-out;
  /* Durations alone, for properties that take no easing (the page-change animation, AUFL-304). */
  --dur-standard: 200ms;
  --dur-slide: 250ms;
  --t-standard: var(--dur-standard) ease-in-out;
  --t-slide: var(--dur-slide) cubic-bezier(.4, 0, .2, 1);
  /* Micro-interactions (AUFL-452) */
  --press-scale: .98;       /* a card or tile pressed, a touch less than a button's .97 */
  --hover-lift: -2px;       /* a card lifting under the mouse */
  --rise-distance: 8px;     /* how far a list row rises as it fades in */
  --stagger-step: 35ms;     /* the gap between one row's entrance and the next */
  /* Z stack */
  --z-sticky: 100; --z-sidebar: 1020; --z-navbar: 1025; --z-bottom-nav: 1030; --z-fab: 1035;
  --z-action-bar: 1031; --z-dropdown: 1050; --z-overlay: 1055; --z-modal: 1060; --z-toast: 1070;
  --z-tooltip: 1080;
  /* Shell sizes */
  --sidebar-width: 232px;
  --sidebar-collapsed-width: 64px;
  --navbar-height: 57px;
  --bottom-nav-height: 64px;
  --fab-size: 52px;

  /* The four gradients (uiux-rules.md §7.4): use no others. */
  --gradient-hero:    linear-gradient(135deg, var(--color-action), #6f42c1);
  --gradient-danger:  linear-gradient(135deg, #dc3545, #fd7e14);
  --gradient-success: linear-gradient(135deg, #198754, #20c997);
  --gradient-gold:    linear-gradient(135deg, var(--color-brand-light), var(--color-brand));

  /* Status pill pairs (tinted: safe in light and dark) */
  --pill-open-bg:   rgba(var(--color-action-rgb), .12);  --pill-open-fg:   var(--color-action-dark);
  --pill-active-bg: rgba(var(--color-warning-rgb), .16); --pill-active-fg: #92400e;
  --pill-done-bg:   rgba(var(--color-success-rgb), .14); --pill-done-fg:   #065f46;
  --pill-lost-bg:   rgba(var(--color-danger-rgb), .12);  --pill-lost-fg:   #b91c1c;
  --pill-hold-bg:   rgba(100, 116, 139, .14);            --pill-hold-fg:   var(--color-n700);

  --surface-page: var(--color-n50);
  --surface-sidebar: var(--color-n950);
  --bottom-nav-bg: rgba(var(--color-white-rgb), .9);

  /* Modals: the CRM's glass panel (AUFL-60) */
  --modal-glass-bg: rgba(var(--color-white-rgb), .85);
  --modal-border: rgba(var(--color-white-rgb), .5);
  --modal-shadow: 0 25px 50px -12px rgba(var(--color-black-rgb), .25);
  --modal-backdrop-overlay: rgba(var(--color-white-rgb), .7);
  --modal-backdrop-blur: 12px;
  --modal-title-color: var(--color-action);
}

[data-bs-theme="dark"] {
  --color-border: rgba(var(--color-white-rgb), .09);
  --surface-page: #0b1120;
  --surface-sidebar: #060a14;
  --bottom-nav-bg: rgba(5, 9, 18, .9);
  --pill-open-fg: #a5b4fc; --pill-active-fg: #fcd34d; --pill-done-fg: #6ee7b7;
  --pill-lost-fg: #fca5a5; --pill-hold-fg: var(--color-n300);
  --bs-link-color: var(--color-action-lightest);
  --bs-link-color-rgb: var(--color-action-lightest-rgb);
  --bs-link-hover-color: var(--color-white);
  --bs-link-hover-color-rgb: var(--color-action-lighter-rgb);
  --modal-glass-bg: rgba(15, 23, 42, .92);
  --modal-border: rgba(var(--color-white-rgb), .08);
  --modal-shadow: 0 25px 50px -12px rgba(var(--color-black-rgb), .5);
  --modal-backdrop-overlay: rgba(var(--color-black-rgb), .5);
  --modal-title-color: var(--color-action-light);
}
/* Text in the action and state colours, lifted to tints that pass on dark surfaces. */
[data-bs-theme="dark"] .text-primary { color: var(--color-action-lighter) !important; }
[data-bs-theme="dark"] .text-success { color: var(--color-success-light) !important; }
[data-bs-theme="dark"] .text-danger { color: var(--color-danger-light) !important; }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: var(--color-action-lighter);
  --bs-btn-border-color: var(--color-action-lighter); --bs-btn-hover-color: var(--color-white); }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: var(--color-n300); --bs-btn-border-color: var(--color-n500);
  --bs-btn-hover-color: var(--color-n950); --bs-btn-hover-bg: var(--color-n300); --bs-btn-hover-border-color: var(--color-n300);
  --bs-btn-active-color: var(--color-n950); --bs-btn-active-bg: var(--color-n300); }
[data-bs-theme="dark"] .btn-outline-danger { --bs-btn-color: var(--color-danger-light); --bs-btn-border-color: var(--color-danger-light); }
[data-bs-theme="dark"] .btn-outline-success { --bs-btn-color: var(--color-success-light); --bs-btn-border-color: var(--color-success-light); }
[data-bs-theme="dark"] .stage-step.current, [data-bs-theme="dark"] .stage-caption, [data-bs-theme="dark"] .initials,
[data-bs-theme="dark"] .filter-pill, [data-bs-theme="dark"] .help-flow .hf-step,
[data-bs-theme="dark"] .help-nav a.active, [data-bs-theme="dark"] .help-nav a:hover,
[data-bs-theme="dark"] .nav-tile .nt-icon, [data-bs-theme="dark"] .help-head .help-icon,
[data-bs-theme="dark"] .help-hint > i { color: var(--color-action-lighter); }

/* ── 1. Base ───────────────────────────────────────────────────────────── */
body {
  background: var(--surface-page);
  font-family: var(--bs-body-font-family);
  font-size: .9375rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, .h1, .h2, .h3, .h4, .page-title { font-family: var(--font-heading); letter-spacing: -.01em; }
.num, .font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
a { text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--color-action); outline-offset: 2px; }
.btn:active { transform: scale(.97); transition: transform var(--t-micro); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { --bs-btn-bg: var(--color-action); --bs-btn-border-color: var(--color-action);
  --bs-btn-hover-bg: var(--color-action-dark); --bs-btn-hover-border-color: var(--color-action-dark);
  --bs-btn-active-bg: var(--color-action-dark); --bs-btn-disabled-bg: var(--color-action);
  --bs-btn-disabled-border-color: var(--color-action); font-weight: 600; }
.btn-outline-primary { --bs-btn-color: var(--color-action); --bs-btn-border-color: var(--color-action);
  --bs-btn-hover-bg: var(--color-action); --bs-btn-hover-border-color: var(--color-action);
  --bs-btn-active-bg: var(--color-action-dark); }
.btn { border-radius: var(--radius-sm); font-weight: 500; }
/* `hidden` always hides. Bootstrap's display utilities (.d-block, .d-flex) are !important and
   come later, so a hidden field wrapped in <label class="d-block"> (data-shown-when) still
   showed, greyed out and marked required. The doubled attribute outranks one class. */
[hidden][hidden] { display: none !important; }
/* Every action reads in Title Case (owner, AUFL-213): buttons, ⋯ menu items, and the button
   names Help quotes, so Help matches the screen. Labels stay sentence case in the source. */
.btn, .dropdown-item, .help-ui { text-transform: capitalize; }
/* Outline buttons in a state colour: Bootstrap's compiled colours (amber 1.6:1, red 4.3:1
   on white) fail contrast, so each takes its text colour from a token. */
.btn-outline-danger { --bs-btn-color: var(--color-danger); --bs-btn-border-color: var(--color-danger);
  --bs-btn-hover-bg: var(--color-danger); --bs-btn-hover-border-color: var(--color-danger);
  --bs-btn-active-bg: var(--color-danger); --bs-btn-active-border-color: var(--color-danger); }
.btn-outline-success { --bs-btn-color: var(--color-success); --bs-btn-border-color: var(--color-success);
  --bs-btn-hover-bg: var(--color-success); --bs-btn-hover-border-color: var(--color-success);
  --bs-btn-active-bg: var(--color-success); --bs-btn-active-border-color: var(--color-success); }
.btn-outline-warning { --bs-btn-color: var(--pill-active-fg); --bs-btn-border-color: var(--color-warning);
  --bs-btn-hover-color: var(--color-n950); --bs-btn-active-color: var(--color-n950); }
.btn-check:checked + .btn-outline-warning { color: var(--color-n950); }
/* Bootstrap's grey (#6c757d) is just under 4.5:1 on the page surface. */
.btn-outline-secondary { --bs-btn-color: var(--color-n700); }
.form-control, .form-select { border-radius: var(--radius-sm); }
/* A mandatory field's label ends in a red asterisk; app.js (markRequired) sets the class.
   Drawn here, not typed, so the label's text stays as written for screen readers and tests. */
.label-required::after { content: " *"; color: var(--color-danger); }
[data-bs-theme="dark"] .label-required::after { color: var(--color-danger-light); }
.card { border-radius: var(--radius-md); border-color: var(--color-border); box-shadow: var(--shadow-elevation-1); }
/* Small-caps group label. One look wherever it sits (card or page), 12px so it stays readable
   on a low-end phone in daylight (the floor for any text in the app). */
h2.h6.text-uppercase, h3.h6.text-uppercase, .section-label {
  font-family: var(--bs-body-font-family); font-size: .75rem; font-weight: 700; letter-spacing: .08em;
}
.alert { border-radius: var(--radius-md); }
.badge { font-weight: 600; }
.table { --bs-table-bg: transparent; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }

@media (max-width: 991.98px) {
  .btn, .form-control, .form-select { min-height: 44px; }
  .btn { min-width: 44px; }
  .back-link { min-height: 44px; margin-bottom: 0; }
  .btn-lg, .form-control-lg, .form-select-lg { min-height: 48px; }
  .form-control, .form-select { font-size: 1rem; } /* no iOS zoom on focus */
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ── 2. Shell ──────────────────────────────────────────────────────────── */
/* dvh (AUFL-294): the height left over by the browser's bars and the on-screen keyboard
   (base.html's viewport asks for interactive-widget=resizes-content); vh first for old browsers. */
#wrapper { display: flex; min-height: 100vh; min-height: 100dvh; }

#sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-sidebar); color: var(--color-white);
  z-index: var(--z-sidebar);
  transition: width var(--t-slide), transform var(--t-slide);
  display: flex; flex-direction: column;
}
#sidebar .sidebar-brand {
  display: flex; align-items: center; gap: var(--space-2); min-height: 60px;
  padding: var(--space-3) var(--space-4); color: var(--color-white); text-decoration: none;
  border-bottom: 1px solid rgba(var(--color-white-rgb), .08);
}
.brand-mark { width: 32px; height: 32px; flex-shrink: 0; object-fit: contain; }
.brand-name { font-family: var(--font-heading); font-weight: 700; font-size: 1rem; white-space: nowrap; }
.brand-name small { display: block; font-family: var(--bs-body-font-family); font-weight: 500;
  font-size: .68rem; color: rgba(var(--color-white-rgb), .5); letter-spacing: .04em; }
.sidebar-group {
  padding: var(--space-4) var(--space-5) var(--space-1); font-size: .65rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: rgba(var(--color-white-rgb), .6); white-space: nowrap;
}
#sidebar .nav-link {
  display: flex; align-items: center; gap: 10px; height: 40px; margin: 2px var(--space-2);
  padding: 0 var(--space-3); border-radius: var(--radius-sm);
  color: rgba(var(--color-white-rgb), .78); font-size: .875rem; white-space: nowrap; overflow: hidden;
  transition: background var(--t-micro), color var(--t-micro);
}
#sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
#sidebar .nav-link:hover { background: rgba(var(--color-white-rgb), .07); color: var(--color-white); }
#sidebar .nav-link.active { background: rgba(var(--color-white-rgb), .12); color: var(--color-white); font-weight: 600; }
#sidebar .nav-link.active i { color: var(--color-brand-light); }
.sidebar-user {
  margin-top: auto; padding: var(--space-3) var(--space-4); border-top: 1px solid rgba(var(--color-white-rgb), .08);
  display: flex; align-items: center; gap: var(--space-2); font-size: .8rem;
}
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-circle); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-action); color: var(--color-white); font-weight: 700; font-size: .8rem;
}
.sidebar-user .who { min-width: 0; }
.sidebar-user .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who .sub { color: rgba(var(--color-white-rgb), .5); font-size: .72rem; }
/* Opens SIMS's My Profile page (change password); a full 44px touch target. */
.sidebar-user .who .profile-link {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: 44px;
  color: rgba(var(--color-white-rgb), .78); font-size: .75rem; text-decoration: none;
}
.sidebar-user .who .profile-link:hover { color: var(--color-white); text-decoration: underline; }
.sidebar-collapse-btn {
  background: none; border: 0; color: rgba(var(--color-white-rgb), .6); width: 40px; height: 40px;
  border-radius: var(--radius-sm); margin: var(--space-2) auto;
}
.sidebar-collapse-btn:hover { background: rgba(var(--color-white-rgb), .07); color: var(--color-white); }

/* The collapsed rail is a desktop setting only: theme.js restores it on every screen size, and
   below lg it would shrink the drawer to icons and hide who is signed in. */
@media (min-width: 992px) {
  .sidebar-collapsed #sidebar { width: var(--sidebar-collapsed-width); }
  .sidebar-collapsed #sidebar .nav-label, .sidebar-collapsed #sidebar .brand-name,
  .sidebar-collapsed #sidebar .sidebar-group, .sidebar-collapsed #sidebar .who { display: none; }
  .sidebar-collapsed #sidebar .nav-link { justify-content: center; padding: 0; }
  .sidebar-collapsed #sidebar .sidebar-collapse-btn i { transform: rotate(180deg); }
}

#page-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }

#topNavbar {
  position: sticky; top: 0; z-index: var(--z-navbar); min-height: var(--navbar-height);
  background: var(--bs-body-bg); border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4);
}
#topNavbar .page-crumb { font-size: .85rem; color: var(--bs-secondary-color); }
#topNavbar .page-crumb a { color: inherit; text-decoration: none; }
#topNavbar .page-crumb .current { color: var(--bs-body-color); font-weight: 600; }
#topNavbar .mobile-title { font-family: var(--font-heading); font-weight: 600; font-size: 1rem;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: var(--bs-body-bg); color: var(--bs-body-color);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.icon-btn:hover { background: var(--bs-tertiary-bg); }
.icon-btn { flex-shrink: 0; }
/* A small "show more" toggle: one chevron that turns when open, the same on every screen
   (the browser's own triangle disappears once the summary is laid out as flex). */
details > summary.small { display: flex; align-items: center; gap: var(--space-1); list-style: none; cursor: pointer; }
details > summary.small::-webkit-details-marker { display: none; }
details > summary.small::before { font-family: "bootstrap-icons"; content: "\F285"; font-size: .75em;
  transition: transform var(--t-standard); }
details[open] > summary.small::before { transform: rotate(90deg); }
/* "Purchase so far" rows take the same chevron. Rows whose summary is itself the card
   (Estimate, KYC, Risk Review) lost the browser's triangle and looked like dead cards. */
.so-far-row > summary { display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
  text-align: start; list-style: none; cursor: pointer; min-height: 44px; }
.so-far-row > summary::-webkit-details-marker { display: none; }
.so-far-row > summary > span { margin-inline-start: .25em; }  /* "Items · 1": flex drops the space */
.so-far-row > summary::before { font-family: "bootstrap-icons"; content: "\F285"; font-size: .75em;
  margin-inline-end: var(--space-2); transition: transform var(--t-standard); }
.so-far-row[open] > summary::before { transform: rotate(90deg); }
/* A customer message keeps its line breaks (English, then the local language); Bootstrap has no pre-line utility. */
.message-body { white-space: pre-line; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .so-far-row > summary::before { transition: none; } }
@media (max-width: 991.98px) {
  .icon-btn { width: 44px; height: 44px; }
  /* Small text toggles and inline links that stand alone are still tap targets. */
  details > summary.small, .help-hint a { display: inline-flex; align-items: center; min-height: 44px; }
  .form-check-label { padding-block: 11px; min-width: 44px; display: inline-block; }
  .min-h-tap { min-height: 44px; }
}

main.page { flex: 1 1 auto; padding: var(--space-4); width: 100%; max-width: 1280px; margin: 0 auto; }
@media (min-width: 768px) { main.page { padding: var(--space-6); } }

#bottomNav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottom-nav-height);
  background: var(--bottom-nav-bg);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -8px 24px rgba(var(--color-black-rgb), .06);
  z-index: var(--z-bottom-nav); padding: 0 var(--space-1) env(safe-area-inset-bottom);
}
#bottomNav .bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--color-n400); font-size: .65rem; font-weight: 600; letter-spacing: .02em;
  transition: color var(--t-micro);
}
#bottomNav .bn-item i { font-size: 1.375rem; transition: transform var(--t-micro); }
#bottomNav .bn-item.active { color: var(--color-action); }
#bottomNav .bn-item.active i { transform: scale(1.08); }
#bottomNav .bn-item:active { opacity: .7; transform: scale(.93); }
[data-bs-theme="dark"] #bottomNav .bn-item { color: var(--color-n500); }
[data-bs-theme="dark"] #bottomNav .bn-item.active { color: var(--color-action-light); }

/* Waiting counts on the approval queues (pending_counts.js). Gold, the brand colour, on the
   dark sidebar in both themes; a ring of the page colour lifts a badge off an icon. */
.nav-count {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-xl);
  background: var(--color-brand-light); color: var(--color-n950);
  font-family: var(--font-mono); font-size: .7rem; font-weight: 500; line-height: 1;
  font-variant-numeric: tabular-nums; animation: nav-count-in var(--t-standard);
}
@keyframes nav-count-in { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .nav-count { animation: none; } }
#sidebar .nav-link { position: relative; }
#sidebar .nav-link .nav-count { margin-left: auto; }
/* A long label gives way to its count, never the other way round. */
#sidebar .nav-link.has-count .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 992px) {
  .sidebar-collapsed #sidebar .nav-link .nav-count {
    position: absolute; top: 4px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px; font-size: .6rem;
  }
}
#bottomNav .bn-item { position: relative; }
#bottomNav .nav-count {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  font-size: .62rem; box-shadow: 0 0 0 2px var(--bs-body-bg);
}
.nav-tile { position: relative; }
.nav-tile .nav-count {
  position: absolute; top: var(--space-3); right: var(--space-3); min-width: 26px; height: 26px; padding: 0 8px;
  font-size: .8rem; box-shadow: 0 2px 8px rgba(var(--color-brand-rgb), .35);
}
.nav-tile.has-count { border-color: rgba(var(--color-brand-rgb), .45); }
[data-menu-pending].has-pending::after {
  content: ""; position: absolute; top: 8px; right: 8px; width: 9px; height: 9px;
  border-radius: var(--radius-circle); background: var(--color-brand-light); box-shadow: 0 0 0 2px var(--bs-body-bg);
}

#fab {
  display: none; position: fixed; right: var(--space-4); bottom: calc(var(--bottom-nav-height) + 8px);
  width: var(--fab-size); height: var(--fab-size); border-radius: var(--radius-circle);
  background: var(--color-action); color: var(--color-white); font-size: 1.5rem;
  align-items: center; justify-content: center; text-decoration: none;
  box-shadow: 0 4px 16px rgba(var(--color-black-rgb), .25); z-index: var(--z-fab);
  border: 0; padding: 0; /* it is a <button> where it opens a dialog */
  transition: transform var(--t-micro), box-shadow var(--t-micro);
}
#fab:active { transform: scale(.92); box-shadow: var(--shadow-elevation-2); }

/* The drawer's backdrop blurs the page as a dialog's does (AUFL-452). */
#sidebarBackdrop { display: none; position: fixed; inset: 0; background: var(--modal-backdrop-overlay);
  -webkit-backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%);
  backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%);
  z-index: calc(var(--z-sidebar) - 1); }

@media (max-width: 991.98px) {
  #sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); width: var(--sidebar-width); }
  .sidebar-open #sidebar { transform: none; box-shadow: var(--shadow-elevation-4); }
  .sidebar-open #sidebarBackdrop { display: block; animation: backdrop-in var(--t-slide); }
  .sidebar-collapse-btn { display: none; }
  /* Who is signed in sits under the logo in the drawer, not below every menu group. */
  #sidebar .sidebar-brand { order: -2; }
  .sidebar-user { order: -1; margin-top: 0; border-top: 0; border-bottom: 1px solid rgba(var(--color-white-rgb), .08); }
  #bottomNav { display: flex; }
  #fab { display: inline-flex; }
  main.page { padding-bottom: calc(var(--bottom-nav-height) + var(--space-8) + 56px); }
  /* Sticky action bars sit on top of the bottom nav, never under it. */
  .fixed-bottom { bottom: var(--bottom-nav-height) !important; z-index: var(--z-action-bar); }
  .has-action-bar #fab { display: none; }
  /* Typing (AUFL-294, app.js marks .is-typing): the keyboard takes the bottom half, so the
     bottom nav steps aside and the action bar sits right on the keyboard, its primary button
     reachable without closing it. */
  .is-typing #bottomNav { display: none; }
  .is-typing .fixed-bottom { bottom: 0 !important; }
  .is-typing .action-bar { bottom: 0; }
}
/* No pull-to-refresh mid-step (AUFL-294): a screen with an action bar is a step or a form, and
   a reload there loses what was typed. Dialogs and the drawer keep their own scroll to themselves. */
html:has(> body.has-action-bar), body.has-action-bar { overscroll-behavior-y: contain; }
.modal, .modal-body { overscroll-behavior: contain; }
@media (min-width: 992px) {
  .fixed-bottom { left: var(--sidebar-width) !important; }
  .sidebar-collapsed .fixed-bottom { left: var(--sidebar-collapsed-width) !important; }
  main.page { padding-bottom: calc(var(--space-8) + 72px); }
}
.fixed-bottom { box-shadow: 0 -6px 18px rgba(var(--color-black-rgb), .06); }

/* Skip link: hidden until focused, then above the sticky shell (shares the toast layer). */
.skip-link:focus { z-index: var(--z-toast); }

/* Toasts (flash messages) */
#toastStack {
  position: fixed; top: calc(var(--navbar-height) + var(--space-3)); right: var(--space-4); left: auto;
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); width: min(420px, calc(100vw - 32px));
}
@media (max-width: 575.98px) { #toastStack { left: var(--space-4); right: var(--space-4); width: auto; } }
.app-toast {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); background: var(--bs-body-bg); box-shadow: var(--shadow-elevation-3);
  border: 1px solid var(--color-border); border-left: 4px solid var(--color-action); font-size: .875rem;
  animation: toast-in 200ms ease-out;
}
.app-toast.t-success { border-left-color: var(--color-success); }
.app-toast.t-danger { border-left-color: var(--color-danger); }
.app-toast.t-warning { border-left-color: var(--color-warning); }
.app-toast .t-icon { font-size: 1.1rem; line-height: 1.3; }
.app-toast.t-success .t-icon { color: var(--color-success); }
.app-toast.t-danger .t-icon { color: var(--color-danger); }
.app-toast.t-warning .t-icon { color: var(--color-warning); }
.app-toast .t-body { flex: 1; }
.app-toast.hiding { opacity: 0; transform: translateY(-6px); transition: opacity var(--t-standard), transform var(--t-standard); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Page changes (AUFL-304): cross-document View Transitions, so going from one page to the next
   cross-fades like an app instead of blanking. The identity hero, page header and phone action
   bar each carry a name, so they hold their place (and only their content cross-fades) while
   the data area changes. The rest of the page only fades, never slides: the fixed bottom nav
   and top bar are part of it and must not move. Browsers without support load the page as
   before; reduced motion turns it off. Each name may appear once per page, or the browser
   skips the animation (the page still loads). */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.identity-hero { view-transition-name: identity-hero; }
.page-header { view-transition-name: page-header; }
/* Only the phone's fixed bar: the desktop inline copy sits in the data, at the end of the content. */
@media (max-width: 991.98px) {
  .action-bar:not(.action-bar-desktop) { view-transition-name: action-bar; }
}
::view-transition-group(*) { animation-duration: var(--dur-slide); }
::view-transition-old(root) { animation: page-fade-out var(--t-standard) both; }
::view-transition-new(root) { animation: page-fade-in var(--t-slide) both; }
@keyframes page-fade-out { to { opacity: 0; } }
@keyframes page-fade-in { from { opacity: 0; } }

/* ── 3. Page header ───────────────────────────────────────────────────── */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-5); }
.page-header .page-title { font-size: 1.5rem; font-weight: 700; margin: 0; line-height: 1.3; }
.page-header .page-sub { color: var(--bs-secondary-color); font-size: .875rem; margin-top: 2px; }
@media (max-width: 767.98px) { .page-header .page-title { font-size: 1.25rem; } }
.back-link { display: inline-flex; align-items: center; gap: var(--space-1); font-size: .82rem;
  color: var(--bs-secondary-color); text-decoration: none; margin-bottom: var(--space-1); }
.back-link:hover { color: var(--color-action); }

/* ── 4. Components ────────────────────────────────────────────────────── */
/* Status pill */
.status-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--radius-xl);
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; line-height: 1.5;
  white-space: nowrap; }
.sp-open { background: var(--pill-open-bg); color: var(--pill-open-fg); }
.sp-active { background: var(--pill-active-bg); color: var(--pill-active-fg); }
.sp-done { background: var(--pill-done-bg); color: var(--pill-done-fg); }
.sp-lost { background: var(--pill-lost-bg); color: var(--pill-lost-fg); }
.sp-hold { background: var(--pill-hold-bg); color: var(--pill-hold-fg); }
/* A Waived Day Close (ADR-0028): set apart from a Non-working Day's grey. */
.sp-waived { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
/* Scan Checkpoint camera (ADR-0022): a page number is a 44px touch target (Bootstrap's buttons
   are smaller), and the live view never grows taller than most of the screen. */
.page-tick { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.scan-view { max-height: 60vh; object-fit: cover; }
/* The camera stage (ADR-0022): a shutter blink when a photo is kept, the photos on their way,
   and each photo's outcome flashed over the view (checkpoint_scan.js builds these). */
.scan-stage { position: relative; overflow: hidden; border-radius: var(--radius-md); }
/* The photo view (ADR-0027): an empty frame until a page is photographed, then the last photo
   kept, whole, so the person sees what was sent. */
.scan-view { min-height: 14rem; }
.scan-view img { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
/* A Family Video Call's video: a portrait phone recording at full width is taller than the
   screen, so it is held to the same 60vh as a photographed page and kept whole (letterboxed). */
.evidence-video { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
.scan-shutter { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: rgba(var(--bs-white-rgb), .75); }
.scan-shutter.is-on { animation: scan-shutter 180ms ease-out; }
@keyframes scan-shutter { from { opacity: 1; } to { opacity: 0; } }
.scan-pending { position: absolute; top: var(--space-2); right: var(--space-2); padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-xl); font-size: .8125rem; font-weight: 600;
  background: rgba(var(--bs-body-bg-rgb), .88); color: var(--bs-body-color); box-shadow: var(--shadow-elevation-1); }
.scan-flash { position: absolute; left: var(--space-4); right: var(--space-4); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center;
  padding: var(--space-4); border-radius: var(--radius-lg); pointer-events: none;
  background: rgba(var(--bs-body-bg-rgb), .92); color: var(--bs-body-color); box-shadow: var(--shadow-elevation-3);
  border-top: 4px solid currentColor; }
.scan-flash.is-on { animation: scan-flash-in var(--t-slide); }
.scan-flash-icon { font-size: 2.5rem; line-height: 1; }
.scan-flash-title { font-size: 1.0625rem; }
.scan-flash-detail { font-size: .875rem; color: var(--bs-secondary-color); }
.scan-flash.is-success { border-top-color: var(--bs-success); } .scan-flash.is-success .scan-flash-icon { color: var(--bs-success); }
.scan-flash.is-warning { border-top-color: var(--bs-warning); } .scan-flash.is-warning .scan-flash-icon { color: var(--bs-warning); }
.scan-flash.is-danger { border-top-color: var(--bs-danger); } .scan-flash.is-danger .scan-flash-icon { color: var(--bs-danger); }
.scan-flash.is-danger.is-on .scan-flash-icon { animation: scan-flash-shake 360ms ease-in-out; }
.scan-result { display: flex; gap: var(--space-2); align-items: baseline; padding: var(--space-1) 0; }
.scan-result.is-success .bi { color: var(--bs-success); } .scan-result.is-warning .bi { color: var(--bs-warning); }
.scan-result.is-danger .bi { color: var(--bs-danger); }
@keyframes scan-flash-in { from { opacity: 0; transform: translateY(-50%) scale(.92); } to { opacity: 1; transform: translateY(-50%) scale(1); } }
@keyframes scan-flash-shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

/* List card (CRM lead card pattern) */
.list-card {
  display: block; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  border-left: 4px solid transparent; background: var(--bs-body-bg); box-shadow: var(--shadow-elevation-1);
  color: var(--bs-body-color); text-decoration: none; overflow: hidden;
  transition: box-shadow var(--t-micro), transform var(--t-micro);
}
a.list-card:hover { box-shadow: var(--shadow-elevation-2); color: var(--bs-body-color); }
a.list-card:active { transform: scale(var(--press-scale)); }
.list-card .lc-body { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.list-card .lc-main { flex: 1; min-width: 0; }
.list-card .lc-title { font-weight: 700; font-size: 1rem; line-height: 1.25; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.list-card .lc-meta { font-size: .8rem; color: var(--bs-secondary-color); display: flex; flex-wrap: wrap;
  gap: var(--space-1) var(--space-3); margin-top: 2px; }
.list-card .lc-meta i { font-size: .75rem; margin-right: 2px; }
.list-card .lc-meta > span { white-space: nowrap; }
.list-card .lc-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.list-card .lc-chevron { color: var(--color-n400); flex-shrink: 0; }
.urgency-danger  { border-left-color: var(--color-danger) !important; }
.urgency-warning { border-left-color: var(--color-warning) !important; }
.urgency-info    { border-left-color: var(--color-action-light) !important; }
.urgency-success { border-left-color: var(--color-success) !important; }
/* Urgency on an ordinary card needs the thicker left border list-cards already have. */
.card[class*="urgency-"] { border-left-width: 4px; }
.list-stack { display: flex; flex-direction: column; gap: var(--space-3); }

/* Initials avatar for customers */
.initials { width: 40px; height: 40px; border-radius: var(--radius-circle); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
  background: rgba(var(--color-action-rgb), .12); color: var(--color-action); }

/* Identity hero (Purchase detail) */
.identity-hero {
  background: var(--gradient-hero); color: var(--color-white); border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5); box-shadow: 0 4px 20px rgba(var(--color-action-rgb), .28);
  margin-bottom: var(--space-4);
}
.identity-hero .ih-row { display: flex; align-items: center; gap: var(--space-3); }
.identity-hero .initials { width: 52px; height: 52px; background: rgba(var(--color-white-rgb), .18);
  color: var(--color-white); border: 2px solid rgba(var(--color-white-rgb), .4); font-size: 1rem; }
.identity-hero .ih-name { font-family: var(--font-heading); font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.identity-hero .ih-meta { font-size: .82rem; opacity: .88; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.identity-hero .ih-pill { display: inline-flex; align-items: center; gap: 4px; background: rgba(var(--color-white-rgb), .2);
  border: 1px solid rgba(var(--color-white-rgb), .4); border-radius: var(--radius-xl); padding: 3px 10px;
  font-size: .75rem; font-weight: 600; }
.identity-hero.ended { background: var(--gradient-success); box-shadow: 0 4px 20px rgba(var(--color-success-rgb), .28); }
.identity-hero.stopped { background: linear-gradient(135deg, var(--color-n700), var(--color-n950));
  box-shadow: var(--shadow-elevation-2); }

/* Stage stepper */
.stage-stepper { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-bottom: var(--space-4);
  padding-bottom: 2px; }
.stage-stepper::-webkit-scrollbar { display: none; }
.stage-step { flex: 1 0 auto; min-width: 72px; text-align: center; font-size: .75rem; font-weight: 600;
  color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .03em; }
.stage-step .bar { height: 4px; border-radius: 2px; background: var(--bs-border-color); margin-bottom: 6px; }
.stage-step.done .bar { background: var(--color-success); }
.stage-step.current .bar { background: var(--color-action); }
.stage-step.current { color: var(--color-action); }
/* The Purchase's stepper on a phone: every bar, no labels, the current Stage named underneath. */
.stage-caption { margin: calc(-1 * var(--space-2)) 0 var(--space-4); font-size: .75rem; font-weight: 600;
  color: var(--color-action); text-transform: uppercase; letter-spacing: .03em; }
@media (max-width: 767.98px) {
  .stage-compact { overflow: visible; margin-bottom: var(--space-3); }
  .stage-compact .stage-step { flex: 1 1 0; min-width: 0; }
  .stage-compact .stage-label { display: none; }
  .stage-compact .stage-step .bar { margin-bottom: 0; }
}
.stage-step.done { color: var(--bs-body-color); }
/* Itemisation Wizard: phase links and Item chips are tap targets. */
a.stage-step { display: block; min-height: 44px; padding-top: var(--space-2); }
.wizard-chips { scrollbar-width: none; }
.wizard-chips::-webkit-scrollbar { display: none; }
.wizard-chip { min-height: 44px; white-space: nowrap; }
/* The chip being worked on is a selected tab, tinted, not a filled button that reads as a
   second primary beside the action bar's. Scan beside a packet code is a field's own button. */
.wizard-chip-current, .wizard-chip-current:hover { background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis); font-weight: 600; }

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-tile { background: var(--bs-body-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevation-1); padding: var(--space-3) var(--space-4); border-left: 4px solid transparent;
  color: var(--bs-body-color); text-decoration: none; display: block; }
a.stat-tile:hover { box-shadow: var(--shadow-elevation-2); color: var(--bs-body-color); }
.stat-tile .st-value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 500; line-height: 1.15; }
.stat-tile .st-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--bs-secondary-color); margin-top: 2px; }
.stat-tile.accent-primary { border-left-color: var(--color-action); }
.stat-tile.accent-success { border-left-color: var(--color-success); }
.stat-tile.accent-warning { border-left-color: var(--color-warning); }
.stat-tile.accent-danger { border-left-color: var(--color-danger); }
.stat-tile.accent-gold { border-left-color: var(--color-brand); }

/* Home tiles */
.nav-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
@media (min-width: 768px) { .nav-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .nav-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.nav-tile { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4);
  border-radius: var(--radius-lg); background: var(--bs-body-bg); border: 1px solid var(--color-border);
  box-shadow: var(--shadow-elevation-1); color: var(--bs-body-color); text-decoration: none; min-height: 112px;
  transition: box-shadow var(--t-micro), transform var(--t-micro); }
.nav-tile:hover { box-shadow: var(--shadow-elevation-2); color: var(--bs-body-color); }
.nav-tile:active { transform: scale(var(--press-scale)); }
.nav-tile .nt-icon { width: 40px; height: 40px; border-radius: var(--radius-md); display: inline-flex;
  align-items: center; justify-content: center; font-size: 1.2rem;
  background: rgba(var(--color-action-rgb), .1); color: var(--color-action); }
.nav-tile .nt-label { font-weight: 700; font-size: .95rem; }
.nav-tile .nt-hint { font-size: .75rem; color: var(--bs-secondary-color); line-height: 1.3; }

/* Gold hero (home greeting) */
.welcome-hero { background: var(--gradient-gold); color: var(--color-white); border-radius: var(--radius-lg);
  padding: var(--space-5); margin-bottom: var(--space-5); box-shadow: 0 4px 20px rgba(var(--color-brand-rgb), .28); }
.welcome-hero .wh-title { font-family: var(--font-heading); font-size: 1.35rem; font-weight: 700; margin: 0; }
.welcome-hero .wh-sub { opacity: .9; font-size: .875rem; }
/* Today's Customer Rate under the Branch name: what staff quote a customer. */
.welcome-hero .wh-rate { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--space-2); margin-top: var(--space-3); }
.welcome-hero .wh-rate-label { font-size: .875rem; font-weight: 600; }
.welcome-hero .wh-rate-value { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; }
/* The two rates (Market Price Inclusive of GST, Net to the Customer): label left, rate right. */
.welcome-hero .wh-rates dd { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 700; }
/* The whole rate is one tap into the Rate Calculator, so it keeps the touch-target height. */
.welcome-hero .wh-rate-link { min-height: 44px; }
/* Rate Calculator: the karat and its % in a fixed column, so the gram boxes line up. */
.calc-karat { width: calc(var(--space-5) * 3); }
/* Working Branch on one line: the Branch list gives way first (min-width 0 lets it shrink),
   and the icon-only Change button keeps the 44px touch target. */
.welcome-hero .wh-branch .form-select { min-width: 0; }
.welcome-hero .wh-switch { min-width: 44px; min-height: 44px; }
/* Its ⋯ menu (Customer Checklist prints) sits on the gold, so the button takes the hero's white. */
.welcome-hero .more-menu-btn { color: inherit; border-color: rgba(var(--color-white-rgb), .6); }

/* Alert banner (next action) */
.action-banner { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); background: var(--gradient-danger); color: var(--color-white);
  margin-bottom: var(--space-3); }
.action-banner a { color: var(--color-white); font-weight: 600; }
.action-banner .btn-close { filter: invert(1) grayscale(1) brightness(2); }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-8) var(--space-4); color: var(--bs-secondary-color); }
/* The icon sits on a soft tinted disc with two fading rings (AUFL-452). Only the disc's icon:
   a plain `i` rule also blew up the Clear filters button's icon to 3rem. */
.empty-state .es-icon { width: 88px; height: 88px; margin: 0 auto var(--space-4); border-radius: var(--radius-circle);
  display: flex; align-items: center; justify-content: center; color: var(--color-action);
  background: rgba(var(--color-action-rgb), .08);
  box-shadow: 0 0 0 10px rgba(var(--color-action-rgb), .04), 0 0 0 20px rgba(var(--color-action-rgb), .02);
  animation: icon-pop var(--t-slide) backwards; }
.empty-state .es-icon i { font-size: 2.25rem; line-height: 1; }
.empty-state.es-danger .es-icon { color: var(--color-danger); background: rgba(var(--color-danger-rgb), .08);
  box-shadow: 0 0 0 10px rgba(var(--color-danger-rgb), .04), 0 0 0 20px rgba(var(--color-danger-rgb), .02); }
[data-bs-theme="dark"] .empty-state .es-icon { color: var(--color-action-lighter); background: rgba(var(--color-action-lighter-rgb), .1);
  box-shadow: 0 0 0 10px rgba(var(--color-action-lighter-rgb), .05), 0 0 0 20px rgba(var(--color-action-lighter-rgb), .025); }
[data-bs-theme="dark"] .empty-state.es-danger .es-icon { color: var(--color-danger-light); }
.empty-state .es-title { font-weight: 700; font-size: 1rem; color: var(--bs-body-color); }
.empty-state .es-sub { font-size: .875rem; margin-top: 2px; }

/* Section heading inside a page */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin: var(--space-6) 0 var(--space-3); }
.section-head h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }

/* Definition rows */
.kv { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-2) var(--space-3);
  font-size: .875rem; margin: 0; }
.kv dt { color: var(--bs-secondary-color); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* Choice cards */
.choice-card { display: flex; align-items: center; gap: var(--space-3); min-height: 64px; width: 100%;
  border: 1.5px solid var(--bs-border-color); border-radius: var(--radius-md); background: var(--bs-body-bg);
  padding: var(--space-3) var(--space-4); text-align: left; color: var(--bs-body-color); }
.choice-card:active { transform: scale(.98); background: var(--bs-secondary-bg); }
.btn-check:checked + .choice-card { border-color: var(--color-action); background: rgba(var(--color-action-rgb), .06); }

/* Collapsible settings rows (Settings): a plain summary with a turning chevron. */
.setting-item > summary { list-style: none; cursor: pointer; min-height: 56px; }
.setting-item > summary::-webkit-details-marker { display: none; }
.setting-item > summary .bi-chevron-down { transition: transform var(--t-standard); }
.setting-item[open] > summary .bi-chevron-down { transform: rotate(180deg); }
/* Settings tabs: they wrap rather than scroll, so no tab is out of sight on a phone. Unpicked
   tabs are bordered like a card so they read as tappable; each is a full 44px touch target. */
.settings-tabs .nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.settings-tabs .nav-link { min-height: 44px; border: 1px solid var(--color-border); }
.settings-tabs .nav-link:not(.active) { background: var(--bs-body-bg); color: var(--bs-body-color); }

/* Login */
.bare-wrap { width: 100%; max-width: 520px; }
.login-shell { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }

/* User Manual (/help) and contextual help hints. Modelled on the CRM's /docs page. */
.help-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.help-nav, .help-content { min-width: 0; }
@media (min-width: 992px) { .help-wrap { grid-template-columns: 248px minmax(0, 1fr); } }
.help-nav { position: static; }
@media (min-width: 992px) {
  .help-nav { position: sticky; top: calc(var(--navbar-height) + var(--space-4));
    max-height: calc(100vh - var(--navbar-height) - var(--space-8));
    max-height: calc(100dvh - var(--navbar-height) - var(--space-8)); overflow-y: auto; scrollbar-width: thin; }
}
.help-nav-group { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--bs-secondary-color); padding: var(--space-3) var(--space-2) var(--space-1); }
.help-nav a { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-2);
  border-radius: var(--radius-sm); font-size: .88rem; color: var(--bs-body-color); text-decoration: none; }
@media (min-width: 992px) { .help-nav a { min-height: 34px; } }
.help-nav a:hover { background: var(--bs-tertiary-bg); color: var(--color-action); }
.help-nav a.active { background: rgba(var(--color-action-rgb), .1); color: var(--color-action); font-weight: 600; }
.help-nav a i { opacity: .7; width: 16px; text-align: center; flex-shrink: 0; }
.help-progress { height: 3px; background: var(--color-border); border-radius: var(--radius-sm); overflow: hidden;
  margin-bottom: var(--space-3); }
.help-progress-bar { height: 100%; width: 0; background: var(--color-action); transition: width var(--t-standard); }
.help-toc summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }

.help-section { scroll-margin-top: calc(var(--navbar-height) + var(--space-4)); margin-bottom: var(--space-8);
  padding-bottom: var(--space-6); border-bottom: 1px solid var(--color-border); }
.help-section[hidden] { display: none; }
.help-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.help-head .help-icon { width: 44px; height: 44px; border-radius: var(--radius-md); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
  background: rgba(var(--color-action-rgb), .1); color: var(--color-action); }
.help-head h2 { font-family: var(--font-heading); font-size: 1.25rem; font-weight: 700; margin: 0; }
.help-head .help-sum { font-size: .85rem; color: var(--bs-secondary-color); }
.help-body { line-height: 1.65; font-size: .93rem; }
.help-body h3 { font-size: 1rem; font-weight: 700; margin: var(--space-5) 0 var(--space-2); }
.help-body ul, .help-body ol { padding-left: var(--space-5); }

/* Numbered steps */
.help-body .help-steps { list-style: none; padding: 0; counter-reset: step; margin-bottom: var(--space-4); }
.help-steps > li { counter-increment: step; position: relative; margin-bottom: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-3) 52px; background: var(--bs-tertiary-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.help-steps > li::before { content: counter(step); position: absolute; left: var(--space-4); top: var(--space-3);
  width: 24px; height: 24px; border-radius: var(--radius-circle); background: var(--color-action);
  color: var(--color-white); display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800; }

/* Callouts */
.help-callout { border-left: 3px solid; border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  margin: var(--space-4) 0; font-size: .9rem; }
.help-callout .hc-title { font-weight: 700; margin-bottom: var(--space-1); }
.help-tip { background: rgba(var(--color-success-rgb), .08); border-color: var(--color-success); }
.help-info { background: rgba(var(--color-action-rgb), .07); border-color: var(--color-action); }
.help-warn { background: rgba(var(--color-warning-rgb), .12); border-color: var(--color-warning); }
.help-danger { background: rgba(var(--color-danger-rgb), .08); border-color: var(--color-danger); }

/* An on-screen label, written the way it appears on the button or field */
.help-ui { display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--bs-body-bg); font-weight: 600; font-size: .86em;
  white-space: nowrap; }
.help-table { font-size: .88rem; }
.help-table td { overflow-wrap: anywhere; }
.help-table .help-ui { white-space: normal; }
.help-table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }
.help-flow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2);
  margin: var(--space-3) 0 var(--space-4); }
.help-flow .hf-step { padding: var(--space-1) var(--space-3); border-radius: var(--radius-xl);
  background: rgba(var(--color-action-rgb), .1); color: var(--color-action); font-weight: 600; font-size: .82rem; }
.help-flow .hf-step.hf-approval { background: rgba(var(--color-warning-rgb), .15); color: var(--bs-body-color); }
.help-flow .hf-arrow { color: var(--bs-secondary-color); }
.help-dl dt { font-weight: 700; margin-top: var(--space-3); }
.help-dl dd { margin-bottom: 0; color: var(--bs-body-color); }
.help-dl dd .help-avoid { display: block; font-size: .8rem; color: var(--bs-secondary-color); }

/* The action bar (ui.action_bar, ADR-0016): below lg the fixed bar above the bottom nav,
   at lg and up the same buttons inline at the end of the content. Secondary left, primary
   right; on a phone side by side with the primary about two-thirds of the width. */
.action-bar { margin-top: var(--space-4); }
.action-bar-inner { display: flex; gap: var(--space-2); justify-content: flex-end; }
.action-bar .btn { min-height: 48px; }
/* A list's FAB action, in the page header at lg and up (ui.page_header). */
.page-header .action-bar { margin-top: 0; }
@media (max-width: 991.98px) {
  .action-bar { position: fixed; left: 0; right: 0; bottom: var(--bottom-nav-height); margin: 0;
    z-index: var(--z-action-bar); padding: var(--space-2); background: var(--bs-body-bg);
    border-top: 1px solid var(--color-border); box-shadow: 0 -6px 18px rgba(var(--color-black-rgb), .06); }
  .action-bar .ab-secondary { flex: 1 1 0; min-width: 0; }
  .action-bar .ab-primary { flex: 2 1 0; min-width: 0; }
  .action-bar .btn { width: 100%; }
}

/* The ⋯ menu in the page header: a 44px target; its rows are full-height tap rows. */
.more-menu-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.more-menu .dropdown-menu { min-width: 240px; z-index: var(--z-dropdown); }
.more-menu .dropdown-item { min-height: 44px; white-space: normal; }
.more-menu .dropdown-item.text-danger:active { color: var(--color-white) !important; background: var(--color-danger); }

/* Waiting card: the screen's state while the person can't act (no action bar). */
.waiting-card { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4);
  border-radius: var(--radius-lg); border: 1px solid rgba(var(--color-warning-rgb), .45);
  background: rgba(var(--color-warning-rgb), .1); margin-bottom: var(--space-4); }
.waiting-card > i { color: var(--color-warning); font-size: 1.4rem; line-height: 1.2; }

/* Task list rows (ui.task_list): done, to do, locked, waiting on someone. */
.task-row { min-height: 48px; }
.task-row .task-icon { font-size: 1.1rem; flex-shrink: 0; }
.task-done .task-icon { color: var(--color-success); }
.task-todo .task-icon { color: var(--color-action); }
.task-waiting .task-icon { color: var(--color-warning); }
.task-add { color: var(--color-action); }
[data-bs-theme="dark"] .task-add { color: var(--color-action-lighter); }
.task-locked { color: var(--bs-secondary-color); }
.task-locked > summary { list-style: none; cursor: pointer; min-height: 44px; }
.task-locked > summary::-webkit-details-marker { display: none; }
.task-locked .task-reason { padding: var(--space-1) 0 var(--space-1) calc(1.1rem + var(--space-2)); }
.task-group { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--bs-secondary-color); background: var(--bs-tertiary-bg); }
[data-bs-theme="dark"] .task-todo .task-icon { color: var(--color-action-lighter); }
[data-bs-theme="dark"] .task-done .task-icon { color: var(--color-success-light); }

/* First-visit hint on a screen */
.help-hint { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); border: 1px solid rgba(var(--color-action-rgb), .3);
  background: rgba(var(--color-action-rgb), .06); margin-bottom: var(--space-3); font-size: .9rem; }
.help-hint > i { color: var(--color-action); font-size: 1.2rem; }
.help-hint[hidden] { display: none; }
.help-hint .btn-close { width: 44px; height: 44px; margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1) 0 0; flex-shrink: 0; }

/* How to photograph a cheque (_cheque_guide.html, AUFL-259): an inline SVG sample, themed by tokens. */
.cheque-guide { padding: var(--space-3); border-radius: var(--radius-lg); border: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg); }
.cheque-guide li > i { color: var(--color-action); }
.cheque-guide-sample { display: block; width: 100%; max-width: 360px; height: auto; }
.cheque-guide-sample .cg-paper { fill: var(--bs-body-bg); stroke: var(--bs-border-color); stroke-width: 1.5; }
.cheque-guide-sample .cg-line { fill: none; stroke: var(--bs-border-color); stroke-width: 1; }
.cheque-guide-sample .cg-ink-fill { fill: var(--bs-secondary-color); }
.cheque-guide-sample .cg-faint { opacity: .5; }
.cheque-guide-sample .cg-ink { fill: none; stroke: var(--bs-body-color); stroke-width: 1.5; }
.cheque-guide-sample .cg-ink-text { fill: var(--bs-body-color); font-size: 9px; font-weight: 600; }
.cheque-guide-sample .cg-mark { fill: rgba(var(--color-action-rgb), .08); stroke: var(--color-action);
  stroke-width: 1.5; stroke-dasharray: 4 3; }
.cheque-guide-sample .cg-label { fill: var(--color-action); font-size: 8px; font-weight: 600; }
.cheque-guide-sample .cg-micr { fill: var(--bs-body-color); font-family: var(--bs-font-monospace); font-size: 10px; }
.cheque-guide-sample .cg-stamp { fill: var(--bs-danger); font-size: 17px; font-weight: 700; letter-spacing: 2px; }
.cheque-guide-sample .cg-stamp-line { stroke: var(--bs-danger); stroke-width: 1.5; }
[data-bs-theme="dark"] .cheque-guide li > i,
[data-bs-theme="dark"] .cheque-guide-sample .cg-label { color: var(--color-action-lighter); fill: var(--color-action-lighter); }
[data-bs-theme="dark"] .cheque-guide-sample .cg-mark { stroke: var(--color-action-lighter); }

/* ── 5. List screens (AUFL-59; CRM uiux-rules §6.5–6.5.2, §8.1) ─────────── */
/* Filter bar pills and the dirty-Apply marker, as in the CRM's custom.css. */
.filter-pill {
  display: inline-flex; align-items: center; gap: var(--space-1); padding: 3px 0 3px 10px;
  border-radius: var(--radius-xl); background: var(--bs-primary-bg-subtle); color: var(--bs-primary);
  border: 1px solid var(--bs-primary-border-subtle); font-size: .78rem; font-weight: 600;
  white-space: nowrap; text-decoration: none;
}
.filter-pill:hover { color: var(--color-action-dark); }
.filter-pill .pill-remove {
  min-width: 44px; min-height: 44px; margin: -12px 0; display: inline-flex; align-items: center;
  justify-content: center; font-size: .9rem; opacity: .7;
}
.filter-pill:hover .pill-remove { opacity: 1; }
[data-bs-theme="dark"] .filter-pill { color: var(--color-action-lighter); }
.filter-apply-btn { min-height: 48px; min-width: 120px; }
/* Uncommitted edits in the panel: a ring, plus a dot for anyone who can't tell the rings
   apart by contrast. Apply stays enabled. */
.filter-apply-btn.filter-apply-dirty { box-shadow: 0 0 0 3px var(--bs-primary-border-subtle); position: relative; }
.filter-apply-btn.filter-apply-dirty::after {
  content: ''; position: absolute; top: var(--space-1); right: var(--space-1);
  width: var(--space-2); height: var(--space-2); border-radius: var(--radius-circle); background: var(--color-warning);
}

/* List views: the table never shows below md, whatever was stored (list_view.js). */
.lv-table { display: none; }
@media (min-width: 768px) {
  [data-list-view]:not([data-view="card"]) .lv-table { display: block; }
  [data-list-view]:not([data-view="card"]) .lv-cards { display: none; }
}
.lv-cards { padding: var(--space-2); }

/* Table view (CRM §6.5): at most 9 columns, hover row, header sticks under the top bar.
   No horizontal scroll container, so the sticky header works; cells wrap instead. */
.list-table { margin-bottom: 0; --bs-table-hover-bg: var(--bs-tertiary-bg); }
.list-table thead th {
  position: sticky; top: var(--navbar-height); z-index: var(--z-sticky); background: var(--bs-tertiary-bg);
  white-space: nowrap; padding-top: var(--space-2); padding-bottom: var(--space-2);
}
.list-table td { vertical-align: middle; overflow-wrap: anywhere; font-size: .875rem; }
.list-table td.num, .list-table th.num { text-align: right; }
.list-table a.row-link { font-weight: 600; text-decoration: none; color: var(--bs-link-color); }
.list-table a.row-link:hover { text-decoration: underline; }

/* Pager under a list. */
.list-pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-top: 1px solid var(--color-border);
}
@media (max-width: 991.98px) {
  .list-pager .page-link { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
}

/* Skeleton loading (CRM §8.1). */
.skeleton {
  background: linear-gradient(90deg, var(--bs-secondary-bg) 25%, rgba(var(--color-white-rgb), .7) 50%,
    var(--bs-secondary-bg) 75%);
  background-size: 200% 100%; animation: skeleton-wave 1.4s linear infinite;
  border-radius: var(--radius-sm); color: transparent; pointer-events: none;
}
@keyframes skeleton-wave { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.sk-line   { height: 12px; margin-bottom: 6px; }
.sk-title  { height: 18px; margin-bottom: var(--space-2); }
.sk-avatar { width: 40px; height: 40px; border-radius: var(--radius-circle); }
.sk-badge  { height: 20px; width: 60px; border-radius: var(--radius-xl); }
[data-bs-theme="dark"] .skeleton {
  background: linear-gradient(90deg, rgba(var(--color-white-rgb), .08) 25%, rgba(var(--color-white-rgb), .15) 50%,
    rgba(var(--color-white-rgb), .08) 75%);
  background-size: 200% 100%;
}

/* ── 6. Modals (AUFL-60; CRM custom.css "Premium modal", uiux-rules.md §4) ─ */
/* Bootstrap's own layers (dialog 1055, backdrop 1050) tie with --z-overlay; pin the dialog
   to --z-modal so it is never behind its backdrop. */
.modal          { z-index: var(--z-modal); }
.modal-backdrop { z-index: calc(var(--z-modal) - 1); }
.modal-backdrop.show {
  opacity: 1; background: var(--modal-backdrop-overlay);
  -webkit-backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%);
  backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%);
}
.modal-content {
  background: var(--modal-glass-bg); border: 1px solid var(--modal-border); border-radius: var(--radius-xl);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--modal-shadow), 0 8px 32px rgba(var(--color-action-rgb), .12);
  animation: modal-in var(--t-slide) both;
}
.modal-header { padding: var(--space-6) var(--space-6) var(--space-4); border-bottom: 1px solid var(--bs-border-color);
  animation: modal-part-in var(--t-slide) 50ms both; }
/* The CRM's gradient title, using the hero gradient; dark mode uses a plain light indigo
   rather than adding a fifth gradient. */
.modal-header .modal-title {
  font-family: var(--font-heading); font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em;
  display: flex; align-items: center; gap: var(--space-2); color: var(--modal-title-color);
}
.modal-header .modal-title .mt-text { background: var(--gradient-hero); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; }
[data-bs-theme="dark"] .modal-header .modal-title .mt-text { background: none; -webkit-text-fill-color: currentColor; }
.modal-header .btn-close {
  width: 44px; height: 44px; border-radius: var(--radius-md); background-color: rgba(var(--color-black-rgb), .05);
  opacity: .6; margin: calc(var(--space-1) * -1) calc(var(--space-1) * -1) calc(var(--space-1) * -1) auto;
  transition: transform var(--t-standard), opacity var(--t-standard), background-color var(--t-standard);
}
.modal-header .btn-close:hover { background-color: rgba(var(--color-danger-rgb), .1); opacity: 1; transform: rotate(90deg); }
[data-bs-theme="dark"] .modal-header .btn-close { background-color: rgba(var(--color-white-rgb), .06); }
.modal-body { padding: var(--space-5) var(--space-6); animation: modal-part-in var(--t-slide) 80ms both; }
.modal-footer { padding: var(--space-4) var(--space-6) var(--space-5); gap: var(--space-2);
  border-top: 1px solid var(--bs-border-color); animation: modal-part-in var(--t-slide) 110ms both; }
.modal-footer > * { margin: 0; }
.modal .form-control, .modal .form-select { border-width: 1.5px; border-radius: var(--radius-md); }
.modal .form-control:focus, .modal .form-select:focus {
  border-color: var(--color-action); box-shadow: 0 0 0 3px rgba(var(--color-action-rgb), .15);
}
.modal .form-label { font-weight: 600; font-size: .85rem; }
.modal .modal-footer .btn { border-radius: var(--radius-md); min-height: 44px; padding-left: var(--space-5);
  padding-right: var(--space-5); font-weight: 600; }
.modal .modal-footer .btn-primary { background: var(--gradient-hero); border: 0;
  box-shadow: 0 4px 14px rgba(var(--color-action-rgb), .3); }
.modal .modal-footer .btn-primary:hover { box-shadow: 0 8px 24px rgba(var(--color-action-rgb), .4); }
/* Full screen below sm (a form needs the room); the panel loses its rounding there. */
@media (max-width: 575.98px) {
  .modal-fullscreen-sm-down .modal-content { border-radius: 0; border: 0; }
  .modal-fullscreen-sm-down .modal-footer .btn { flex: 1 1 0; min-height: 48px; }
}
@keyframes modal-in { from { opacity: 0; transform: scale(.96) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes modal-part-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── 7. Page loader and busy buttons (AUFL-60; CRM partials/_page_loader.html) ─ */
/* A bar along the top for real page navigations only, never for in-page fetches. */
.page-loader {
  position: fixed; top: 0; left: 0; height: 4px; width: 0; opacity: 0; pointer-events: none;
  background: var(--color-action); box-shadow: 0 0 8px 1px var(--color-action); z-index: var(--z-tooltip);
  transition: width .4s ease, opacity var(--t-slide);
}
.page-loader.pl-loading { opacity: 1; width: 40%; }
.page-loader.pl-leaving { opacity: 1; width: 80%; }
.page-loader.pl-done    { opacity: 1; width: 100%; }
.page-loader.pl-reset   { transition: none; }
/* The spinner a sending submit button shows left of its text (CRM uiux-rules §4.2). */
.btn .btn-spinner { margin-right: var(--space-2); vertical-align: -.125em; }
/* Inline progress of a photo sent in the background (async_upload.js): a slim track under the
   form, the file name and MB sent above it, Cancel / Try again at the end of the line. */
.upload-progress { margin-top: var(--space-2); animation: toast-in var(--t-standard); }
.upload-progress .progress { --bs-progress-height: 6px; --bs-progress-bar-bg: var(--color-action);
  --bs-progress-border-radius: var(--radius-sm); --bs-progress-bar-transition: width var(--t-standard); }
.upload-progress .up-action { min-height: 44px; padding-inline: var(--space-2); }
.upload-progress[data-state="done"] .progress { --bs-progress-bar-bg: var(--color-success); }
/* Scrolled into view clear of a sticky action bar: the same room main.page keeps for it. */
.upload-progress { scroll-margin-bottom: calc(var(--space-8) + 56px); }
@media (max-width: 991.98px) { .upload-progress { scroll-margin-bottom: calc(var(--bottom-nav-height) + var(--space-8) + 56px); } }
/* An uploaded photo's thumbnail (_evidence.html): fixed, whatever the photo's shape. */
/* A printed form in the Purchase page's Forms list: a full-height tap row. */
.doc-row { min-height: 48px; }
.evidence-thumb { width: 64px; height: 64px; }
.item-thumb { width: 72px; height: 72px; }
.evidence-thumb, .item-thumb { display: block; flex-shrink: 0; overflow: hidden; font-size: .75rem;
  background: var(--bs-secondary-bg); }

/* ── 8. Installed app: offline (AUFL-65; CRM uiux-rules §9.4) ─────────── */
/* Sticky under the top bar while the device is offline; pwa.js shows and hides it. */
.offline-banner {
  position: sticky; top: var(--navbar-height); z-index: var(--z-navbar);
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4);
  background: var(--color-warning); color: var(--color-n950); font-size: .85rem; font-weight: 600;
}
.offline-banner[hidden] { display: none; }
/* A button held back offline says why (its title); the dimmed look comes from :disabled. */
.is-offline [data-offline-held] { cursor: not-allowed; }
/* Where a saved page leaves out personal data (KYC, bank details): sw.js writes this note. */
.offline-private-note {
  display: flex; align-items: center; gap: var(--space-2); margin: var(--space-3) 0; padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--color-border); border-radius: var(--radius-md); background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color); font-size: .875rem;
}

/* The in-app camera for every photo staff take (AUFL-216/217, photo_camera.js). The frame marks
   what the photo keeps: a card (85.6 x 54 mm), a face (portrait), a cheque (CTS-2010, 203 x 92 mm),
   a page (A4, 210 x 297 mm) or a thing (square); the rest of the view is dimmed. */
.photo-camera { position: relative; overflow: hidden; border-radius: var(--radius-md); background: var(--bs-body-color);
  aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto; }
.photo-camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-camera.is-mirrored video { transform: scaleX(-1); }
.photo-camera-frame { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border: 3px solid var(--bs-white); border-radius: var(--radius-md); box-shadow: 0 0 0 100vmax rgba(var(--bs-black-rgb), .45); }
.photo-camera[data-shape="landscape"] .photo-camera-frame { width: 92%; aspect-ratio: 85.6 / 54; }
.photo-camera[data-shape="portrait"] .photo-camera-frame { height: 86%; aspect-ratio: 3 / 4; border-radius: var(--radius-xl); }
.photo-camera[data-shape="cheque"] .photo-camera-frame { width: 94%; aspect-ratio: 203 / 92; }
.photo-camera[data-shape="document"] .photo-camera-frame { height: 90%; aspect-ratio: 210 / 297; border-radius: var(--radius-sm); }
.photo-camera[data-shape="square"] .photo-camera-frame { width: 88%; aspect-ratio: 1; }
/* The packet scanner's aim (packet_scan.js): wide enough for a barcode, tall enough for a QR code. */
.packet-scanner { position: relative; overflow: hidden; border-radius: var(--radius-md); }
.packet-scanner-frame { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 72%;
  aspect-ratio: 4 / 3; border: 3px solid var(--bs-white); border-radius: var(--radius-md);
  box-shadow: 0 0 0 100vmax rgba(var(--bs-black-rgb), .45); pointer-events: none; }

/* The Live Photo (AUFL-245, ADR-0021): its field on the page, and the app's own camera for it.
   The camera shows the customer mirrored, as a selfie view does, inside an oval; the ring round
   the oval empties as the attempt's time runs out (live_photo.js draws it). */
.live-photo { display: flex; align-items: center; gap: var(--space-4); }
.live-photo-preview { flex-shrink: 0; display: grid; place-items: center; width: 72px; aspect-ratio: 3 / 4;
  overflow: hidden; border-radius: var(--radius-lg); background: var(--bs-secondary-bg);
  color: var(--bs-secondary-color); font-size: 1.75rem; }
.live-photo-preview img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.live-camera { position: relative; overflow: hidden; aspect-ratio: 3 / 4; max-height: 64vh; margin: 0 auto;
  border-radius: var(--radius-lg); background: rgb(var(--color-black-rgb)); }
.live-camera video, .live-camera-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1); }
.live-camera-frame, .live-camera-ring { position: absolute; left: 50%; top: 46%; height: 78%; aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%); }
.live-camera-frame { border-radius: var(--radius-circle); box-shadow: 0 0 0 100vmax rgba(var(--color-black-rgb), .55); }
.live-camera-ring { overflow: visible; }
.live-camera-ring ellipse { fill: none; stroke-width: 4px; vector-effect: non-scaling-stroke; }
.live-camera-ring .ring-track { stroke: rgba(var(--bs-white-rgb), .3); }
.live-camera-ring .ring-time { stroke: var(--bs-success); stroke-linecap: round; transition: stroke var(--t-standard); }
.live-camera.is-hurry .ring-time { stroke: var(--bs-warning); }
.live-camera-timer { position: absolute; top: var(--space-3); right: var(--space-3); min-width: 44px;
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-xl); text-align: center;
  background: rgba(var(--color-black-rgb), .55); color: var(--bs-white); font-weight: 600;
  font-variant-numeric: tabular-nums; }
.live-camera-try { position: absolute; top: var(--space-3); left: var(--space-3); padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-xl); background: rgba(var(--color-black-rgb), .55); color: var(--bs-white);
  font-size: .875rem; font-weight: 600; }
.live-camera.is-still .live-camera-frame, .live-camera.is-still .live-camera-ring,
.live-camera.is-still .live-camera-timer, .live-camera:not(.is-timed) .live-camera-timer,
.live-camera.is-still .live-camera-try, .live-camera:not(.is-timed) .live-camera-try { display: none; }
.live-camera-prompt { min-height: 3.25rem; margin-top: var(--space-3); text-align: center; }
/* The Liveness Challenge (AUFL-246): the action asked for, big on the camera, and the steps. */
.live-camera-cue { position: absolute; left: 50%; bottom: var(--space-4); transform: translateX(-50%);
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: var(--radius-circle);
  background: rgba(var(--color-black-rgb), .55); color: var(--bs-white); font-size: 2rem;
  transition: background var(--t-standard); }
.live-camera-cue.is-passed { background: var(--bs-success); }
.live-camera.is-still .live-camera-cue { display: none; }
.liveness-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin: var(--space-3) 0 0;
  padding: 0; list-style: none; }
.liveness-steps li { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 32px;
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-xl); font-size: .875rem;
  background: var(--bs-secondary-bg); color: var(--bs-secondary-color);
  transition: background var(--t-standard), color var(--t-standard); }
.liveness-steps li.is-current { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); font-weight: 600; }
.liveness-steps li.is-done { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
/* Liveness not checked (AUFL-248): the badge on the camera, and the reasons to choose from. */
.live-camera-try.is-unchecked { background: var(--bs-warning); color: var(--bs-dark); }
.live-camera-reasons { margin-top: var(--space-3); }
.live-camera-reason, .live-camera-doorstep { min-height: 44px; margin: 0; }
.live-camera-reason[hidden], .live-camera-doorstep[hidden] { display: none !important; }
.live-camera-note { display: block; }
.live-camera-note[hidden] { display: none; }
.liveness-frames { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.liveness-frames li { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); max-width: 88px;
  text-align: center; line-height: 1.2; }
/* The Day Close calendar (ADR-0028): a month of every Branch's status, like the CRM campaign
   calendar. A day is one tap (44px min); on a phone each Branch is a dot, from md its named pill. */
.cal-grid { overflow: hidden; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-row + .cal-row { border-top: 1px solid var(--bs-border-color); }
.cal-cell { min-width: 0; min-height: 64px; padding: var(--space-1); border: 0; border-right: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg); color: var(--bs-body-color); }
.cal-cell:last-child { border-right: 0; }
.cal-day-header { min-height: 0; padding: var(--space-2) 0; background: var(--bs-tertiary-bg); }
.cal-cell-empty { background: var(--bs-tertiary-bg); }
.cal-cell-button { display: block; width: 100%; }
.cal-cell-button:hover, .cal-cell-button:focus-visible { background: var(--bs-secondary-bg); }
.cal-today { background: var(--bs-primary-bg-subtle); }
.cal-day-num { margin-bottom: var(--space-1); font-size: .75rem; line-height: 1; text-align: right; }
.cal-events { display: flex; flex-wrap: wrap; gap: var(--space-1); }
/* The dot takes the pill's strong text colour: its pale background is too faint at dot size. */
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: var(--radius-circle); background: currentColor; }
.cal-pill { width: 100%; overflow: hidden; padding: 1px var(--space-2); font-size: .65rem; text-overflow: ellipsis; }
.cal-tap { min-height: 44px; }
.cal-offcanvas { --bs-offcanvas-width: 360px; }
@media (min-width: 768px) { .cal-cell { min-height: 110px; padding: var(--space-2); } }
.cal-header .cal-day-header { min-height: 0; padding: var(--space-2) 0; }

/* ── 9. Micro-interactions, icons and backdrops (AUFL-452) ───────────────── */
/* Page header icon (ui.page_header): the screen's menu icon in a tinted square by the title. */
.page-title-row { display: flex; align-items: center; gap: var(--space-3); }
.page-icon { width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem;
  background: rgba(var(--color-action-rgb), .1); color: var(--color-action);
  box-shadow: inset 0 0 0 1px rgba(var(--color-action-rgb), .12); animation: icon-pop var(--t-slide) backwards; }
@media (max-width: 767.98px) { .page-icon { width: 36px; height: 36px; font-size: 1.05rem; } }
[data-bs-theme="dark"] .page-icon { color: var(--color-action-lighter); background: rgba(var(--color-action-lighter-rgb), .12);
  box-shadow: inset 0 0 0 1px rgba(var(--color-action-lighter-rgb), .16); }

/* Section labels with an icon: the icon in the action colour, so a long card is easy to scan.
   A label in a state colour (a decision, the final amount) keeps its icon in that colour. */
h2.h6.text-uppercase > .bi:first-child { font-size: 1.1em; vertical-align: -.1em; margin-inline-end: 2px; }
h2.h6.text-uppercase.text-body-secondary > .bi:first-child { color: var(--color-action); }
[data-bs-theme="dark"] h2.h6.text-uppercase.text-body-secondary > .bi:first-child { color: var(--color-action-lighter); }

/* Tap and hover: cards and tiles press like buttons; with a mouse they lift and their
   chevron or icon leans toward where the tap goes. */
a.stat-tile, .choice-card { transition: box-shadow var(--t-micro), transform var(--t-micro); }
a.stat-tile:active, .list-group-item-action:active { transform: scale(var(--press-scale)); }
.choice-card:active { transform: scale(var(--press-scale)); }
.list-card .lc-chevron, .nav-tile .nt-icon { transition: transform var(--t-standard); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  a.list-card:hover, .nav-tile:hover, a.stat-tile:hover { transform: translateY(var(--hover-lift)); }
  a.list-card:active, .nav-tile:active, a.stat-tile:active { transform: translateY(0) scale(var(--press-scale)); }
  a.list-card:hover .lc-chevron { transform: translateX(3px); }
  .nav-tile:hover .nt-icon { transform: scale(1.08) rotate(-4deg); }
}

/* Entrance: list rows, tiles and the page's cards fade and rise in, one after another. Only
   the first eight are staggered so a long list isn't kept waiting. `backwards` holds the start
   frame through the delay and lets go at the end, so no row keeps a transform (a transform
   would trap a ⋯ menu under the next card). Rows are clickable throughout. */
@keyframes rise-in { from { opacity: 0; transform: translateY(var(--rise-distance)); } }
@media (prefers-reduced-motion: no-preference) {
  .list-stack > *, .stat-grid > *, .nav-tiles > *, .task-list .list-group > *, .list-table tbody > tr,
  main.page > .card {
    animation: rise-in var(--t-slide) backwards; animation-delay: calc(var(--stagger-index, 0) * var(--stagger-step));
  }
  :is(.list-stack, .stat-grid, .nav-tiles, .list-group, tbody) > :nth-child(2) { --stagger-index: 1; }
  :is(.list-stack, .stat-grid, .nav-tiles, .list-group, tbody) > :nth-child(3) { --stagger-index: 2; }
  :is(.list-stack, .stat-grid, .nav-tiles, .list-group, tbody) > :nth-child(4) { --stagger-index: 3; }
  :is(.list-stack, .stat-grid, .nav-tiles, .list-group, tbody) > :nth-child(5) { --stagger-index: 4; }
  :is(.list-stack, .stat-grid, .nav-tiles, .list-group, tbody) > :nth-child(6) { --stagger-index: 5; }
  :is(.list-stack, .stat-grid, .nav-tiles, .list-group, tbody) > :nth-child(7) { --stagger-index: 6; }
  :is(.list-stack, .stat-grid, .nav-tiles, .list-group, tbody) > :nth-child(n+8) { --stagger-index: 7; }
}
@keyframes icon-pop { from { opacity: 0; transform: scale(.6); } 70% { transform: scale(1.06); } }
@keyframes backdrop-in { from { opacity: 0; } }

/* Form feedback: a refused field shakes once (app.js adds .field-shake) and its message drops
   in; a field with a shape or check digit shows Bootstrap's green tick once it passes. */
@keyframes field-shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.field-shake { animation: field-shake 360ms ease-in-out; }
.invalid-feedback.d-block { animation: feedback-in var(--t-standard); }
@keyframes feedback-in { from { opacity: 0; transform: translateY(-4px); } }

/* A success toast draws its tick: the ring, then the check. The dash lengths are each
   stroke's own length (ring: 2π × 10; check: its two strokes). */
.t-check { width: 1.25rem; height: 1.25rem; flex-shrink: 0; margin-top: 1px; fill: none; stroke: currentColor;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.t-check circle { stroke-dasharray: 63; stroke-dashoffset: 63; animation: draw-stroke 420ms ease-out forwards; }
.t-check path { stroke-dasharray: 14; stroke-dashoffset: 14; animation: draw-stroke 240ms 340ms ease-out forwards; }
@keyframes draw-stroke { to { stroke-dashoffset: 0; } }
[data-bs-theme="dark"] .app-toast.t-success .t-icon { color: var(--color-success-light); }
@media (prefers-reduced-motion: reduce) { .t-check circle, .t-check path { animation: none; stroke-dashoffset: 0; } }

/* Gradient heroes (Home, Purchase): two soft glows drifting and a large faint icon behind the
   content (ui.hero_backdrop). Clipped by its own layer, never the hero, so the ⋯ menu in the
   hero can still drop below it. */
.welcome-hero, .identity-hero { position: relative; }
.welcome-hero > :not(.hero-backdrop), .identity-hero > :not(.hero-backdrop) { position: relative; }
.hero-backdrop { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.hb-glow { position: absolute; top: -60px; right: -40px; width: 180px; height: 180px; border-radius: var(--radius-circle);
  background: rgba(var(--color-white-rgb), .22); filter: blur(32px); }
.hb-glow-2 { top: auto; right: auto; bottom: -70px; left: 20%; width: 140px; height: 140px;
  background: rgba(var(--color-white-rgb), .14); }
.hb-mark { position: absolute; right: -12px; bottom: -28px; font-size: 7.5rem; line-height: 1;
  color: rgba(var(--color-white-rgb), .14); transform: rotate(-12deg); }
@keyframes glow-drift { to { transform: translate(-24px, 16px) scale(1.1); } }
@media (prefers-reduced-motion: no-preference) {
  .hb-glow { animation: glow-drift 12s ease-in-out infinite alternate; }
  .hb-glow-2 { animation-delay: -6s; }
}

/* Pages outside the shell (signed out, offline, an error before sign-in): the hero and gold
   gradients as two large faint glows behind the card. */
.login-shell { position: relative; }
.login-shell::before, .login-shell::after { content: ""; position: fixed; z-index: -1; pointer-events: none;
  width: 60vmax; height: 60vmax; border-radius: var(--radius-circle); opacity: .12; filter: blur(80px); }
.login-shell::before { top: -20vmax; right: -20vmax; background: var(--gradient-hero); }
.login-shell::after { bottom: -25vmax; left: -20vmax; background: var(--gradient-gold); }

/* The ⋯ menu on a phone (app.js): the page behind blurs as behind a dialog, the menu's own
   header or card is lifted above that, and the menu eases in. `scale`/`translate` rather than
   `transform`, which Bootstrap's positioning sets on the menu. */
.menu-backdrop { position: fixed; inset: 0; z-index: calc(var(--z-dropdown) - 1); background: var(--modal-backdrop-overlay);
  -webkit-backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%);
  backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%); animation: backdrop-in var(--t-standard); }
.menu-lifted { position: relative; z-index: var(--z-dropdown); }
.dropdown-menu.show { animation: menu-in var(--t-standard); }
@keyframes menu-in { from { opacity: 0; scale: .97; translate: 0 -4px; } }
/* Offcanvas panels (the Day Close calendar's day) share the dialog backdrop. */
.offcanvas-backdrop.show { opacity: 1; background: var(--modal-backdrop-overlay);
  -webkit-backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%);
  backdrop-filter: blur(var(--modal-backdrop-blur)) saturate(180%); }

/* The Control Room map (ADR-0033, AUFL-497): Leaflet needs a fixed height to lay out its tiles. */
.trip-map { height: 320px; overflow: hidden; z-index: 0; }
@media (min-width: 992px) { .trip-map { height: 420px; } }
