/* ============================================================================
 * style.css  ·  Theme + native-app polish on top of Bootstrap 5.3
 * ----------------------------------------------------------------------------
 * Strategy:
 *   • Define a single brand scale (blue -> light blue -> white) as tokens.
 *   • Re-point Bootstrap's CSS variables at those tokens where the cascade
 *     allows, and restyle the few components Bootstrap colours from compiled
 *     Sass (buttons, badges) explicitly.
 *   • Layer in the "native app" feel: glass nav, soft elevation, spring-y
 *     press states, smooth combobox, safe-area insets, custom scrollbars.
 *   • Honour the quality floor: visible keyboard focus, reduced-motion respect,
 *     responsive down to small phones.
 *
 * Sections
 *   1.  Design tokens
 *   2.  Bootstrap variable overrides
 *   3.  Base / native resets
 *   4.  Ticker bar  (the signature element)
 *   5.  State screens + login
 *   6.  Glass navbar
 *   7.  Buttons
 *   8.  Forms & focus
 *   9.  Searchable combobox
 *   10. Cards & stat (KPI) cards
 *   11. Tables
 *   12. Status pills & badges
 *   13. Modals
 *   14. Toasts
 *   15. Scrollbars
 *   16. Animations & utilities
 *   17. Responsive tweaks
 *   18. Accessibility (focus-visible, reduced motion)
 * ========================================================================== */


/* ============================================================================
 * 1. DESIGN TOKENS
 * ========================================================================== */
:root {
  /* Brand blue scale --------------------------------------------------- */
  --brand-900: #082e63;
  --brand-800: #0d47a1;   /* deep edge of the ticker */
  --brand-700: #114b9e;
  --brand-600: #1565c0;   /* PRIMARY */
  --brand-500: #1976d2;
  --brand-400: #2f8fe0;
  --brand-300: #64b5f6;   /* light blue */
  --brand-200: #9fd0fb;
  --brand-100: #d6eaff;
  --brand-50:  #eef6ff;   /* faint tint for hovers / panels */

  --brand-600-rgb: 21, 101, 192;

  /* Neutrals ----------------------------------------------------------- */
  --ink-900: #0f172a;   /* headings */
  --ink-700: #334155;   /* body */
  --ink-500: #64748b;   /* muted */
  --surface: #ffffff;
  --surface-2: #f2f3f7; /* iOS-style grouped background (light system grey) */
  --hairline: #e7ebf2;

  /* Semantic (invoice statuses) --------------------------------------- */
  --ok-600: #16a34a;  --ok-50: #e9f9ee;
  --warn-600: #d97706; --warn-50: #fdf3e6;
  --danger-600: #dc2626; --danger-50: #fdeaea;

  /* Shape & elevation — generous, soft, iOS-like ---------------------- */
  --radius-sm: .65rem;
  --radius: 1rem;
  --radius-lg: 1.25rem;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
  --shadow-md: 0 6px 22px rgba(16, 24, 40, .09);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .16);

  /* Layout ------------------------------------------------------------- */
  --ticker-h: 54px;
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Bold / branded helpers -------------------------------------------- */
  --brand-grad: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-700) 100%);
  --brand-grad-soft: linear-gradient(180deg, var(--surface), var(--brand-50));
  --surface-raised: #ffffff;   /* cards, menus, modals (dark mode overrides) */
  --thead-bg: #fbfdff;
  --glass-bg: rgba(255, 255, 255, .78);
  --glass-bg-strong: rgba(255, 255, 255, .92);
}

:root { color-scheme: light; }


/* ============================================================================
 * 2. BOOTSTRAP VARIABLE OVERRIDES
 * (covers utilities like .text-primary, .border-primary, focus rings, links)
 * ========================================================================== */
:root {
  --bs-primary: var(--brand-600);
  --bs-primary-rgb: var(--brand-600-rgb);
  --bs-link-color: var(--brand-600);
  --bs-link-color-rgb: var(--brand-600-rgb);
  --bs-link-hover-color: var(--brand-700);

  --bs-body-color: var(--ink-700);
  --bs-body-bg: var(--surface-2);
  --bs-emphasis-color: var(--ink-900);
  --bs-secondary-color: var(--ink-500);
  --bs-border-color: var(--hairline);

  --bs-body-font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --bs-body-font-size: 0.975rem;
  --bs-body-line-height: 1.55;

  --bs-border-radius: var(--radius);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg);
}


/* ============================================================================
 * 3. BASE / NATIVE RESETS
 * ========================================================================== */
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
  background:
    radial-gradient(1100px 460px at 100% -20%, var(--brand-50), transparent 55%),
    var(--surface-2);
  color: var(--ink-700);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;   /* kill mobile tap flash */
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: clip;                            /* no horizontal swipe into empty space (clip keeps sticky nav working) */
}

h1, h2, h3, h4, h5, h6, .navbar-brand { color: var(--ink-900); letter-spacing: -0.02em; }
h1, h2, h3, .navbar-brand { font-weight: 700; }

::selection { background: var(--brand-200); color: var(--brand-900); }


/* ============================================================================
 * 4. TICKER BAR  ·  signature element (dual-sided blue / light-blue gradient)
 * ========================================================================== */
.ticker-bar {
  display: none !important;   /* removed from desktop + mobile per design */
  height: var(--ticker-h);
  /* Dual-sided: deep blue at both edges, bright light-blue through the middle. */
  background: linear-gradient(
    90deg,
    var(--brand-800) 0%,
    var(--brand-600) 28%,
    var(--brand-300) 50%,
    var(--brand-600) 72%,
    var(--brand-800) 100%
  );
  background-size: 200% 100%;
  animation: ticker-sheen 9s linear infinite;   /* slow living shimmer */
  color: #fff;
  padding-top: env(safe-area-inset-top, 0);      /* notch-safe on phones */
  box-shadow: var(--shadow-xs);
}
.ticker-bar__inner {
  height: var(--ticker-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: clamp(.85rem, 3vw, 1.5rem);
  font-size: .85rem;
}
.ticker-bar__brand {
  font-weight: 600;
  letter-spacing: .01em;
  text-shadow: 0 1px 2px rgba(8, 46, 99, .35);
  white-space: nowrap;
  flex-shrink: 0;
}
.ticker-bar__status .badge { font-weight: 500; }
.ticker-bar__status { flex-shrink: 0; }

/* Live-stats marquee — full width, scrolls continuously, fades at both edges */
.ticker-bar__carousel {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14%, #000 86%, transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 14%, #000 86%, transparent 100%);
}
.ticker-track {
  display: inline-flex;
  align-items: center;
  gap: 2.75rem;
  white-space: nowrap;
  padding-left: 2.75rem;
  animation: ticker-scroll 40s linear infinite;
  will-change: transform;
  transform: translateZ(0);   /* promote to its own layer for smooth scroll */
}
.ticker-stat {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  white-space: nowrap;
  color: #fff;
  font-size: .92rem;
  text-shadow: 0 1px 2px rgba(8, 46, 99, .35);
}
.ticker-stat::before {
  content: "•";
  opacity: .4;
  font-size: .7em;
}
.ticker-stat .bi { font-size: 1.05em; opacity: .92; }
.ticker-stat__label { font-weight: 500; opacity: .9; }
.ticker-stat__label::after { content: ":"; margin-left: -.1em; }
.ticker-stat__value { font-weight: 700; letter-spacing: .01em; }

@keyframes ticker-scroll {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-33.3333%, 0, 0); }
}

@keyframes ticker-sheen {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* Offline state for the connection pill (toggled by app.js) */
#connection-badge.is-offline {
  background: var(--danger-50) !important;
  color: var(--danger-600) !important;
}


/* ============================================================================
 * 5. STATE SCREENS + LOGIN
 * ========================================================================== */
.state-screen {
  min-height: calc(100dvh - var(--ticker-h));
}

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  /* Calm blue wash so the white card pops */
  background:
    radial-gradient(900px 480px at 15% 10%, var(--brand-100), transparent 55%),
    radial-gradient(900px 520px at 100% 100%, var(--brand-50), transparent 60%);
}
#login-screen.d-none { display: none !important; }   /* keep Bootstrap toggle working */

.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}


/* ============================================================================
 * 6. GLASS NAVBAR
 * ========================================================================== */
.app-navbar {
  background: var(--glass-bg);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--hairline);
  box-shadow: var(--shadow-xs);
  padding-block: .55rem;
  min-height: 60px;                 /* reserve height before hydration (CLS) */
}
.app-navbar .navbar-brand { font-size: 1.05rem; }

.app-navbar .nav-link {
  color: var(--ink-700);
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: .45rem .8rem !important;
  margin-inline: .1rem;
  transition: background-color .18s ease, color .18s ease;
}
.app-navbar .nav-link:hover { background: #f2f3f7; color: #1c1c1e; }
.app-navbar .nav-link.active {
  background: var(--brand-grad);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(var(--brand-600-rgb), .30);
}
.app-navbar .nav-link.active:hover { color: #fff; }
.app-navbar .btn-light {
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: 999px;
}


/* ============================================================================
 * 7. BUTTONS  ·  brand colours + spring press feedback
 * ========================================================================== */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: transform .12s var(--ease-spring), box-shadow .2s ease,
              background-color .18s ease, border-color .18s ease, color .18s ease;
}
.btn:active { transform: scale(.97); }   /* native tap squish */

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: #1c1c1e;
  --bs-btn-border-color: #1c1c1e;
  --bs-btn-hover-bg: #000;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-border-color: #000;
  --bs-btn-active-bg: #000;
  --bs-btn-active-color: #fff;
  --bs-btn-active-border-color: #000;
  --bs-btn-disabled-bg: #8e8e93;
  --bs-btn-disabled-border-color: #8e8e93;
  background-image: none;
  border: none;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.btn-primary:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .22); }
.btn-primary:active { background-image: none; }

.btn-outline-primary {
  --bs-btn-color: var(--brand-600);
  --bs-btn-border-color: var(--brand-300);
  --bs-btn-hover-bg: var(--brand-600);
  --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-700);
}

.btn-light {
  --bs-btn-bg: var(--surface-raised);
  --bs-btn-color: var(--ink-700);
  --bs-btn-border-color: var(--hairline);
  --bs-btn-hover-bg: var(--brand-50);
  --bs-btn-hover-border-color: var(--brand-200);
  --bs-btn-hover-color: var(--brand-700);
  --bs-btn-active-bg: var(--brand-100);
  --bs-btn-active-border-color: var(--brand-200);
  --bs-btn-active-color: var(--brand-800);
}

/* Dropdown menus follow the theme (fixes white menus in dark mode) */
.dropdown-menu {
  --bs-dropdown-bg: var(--surface-raised);
  --bs-dropdown-color: var(--ink-700);
  --bs-dropdown-border-color: var(--hairline);
  --bs-dropdown-link-color: var(--ink-700);
  --bs-dropdown-link-hover-bg: var(--brand-50);
  --bs-dropdown-link-hover-color: var(--brand-700);
  --bs-dropdown-link-active-bg: var(--brand-600);
  --bs-dropdown-link-active-color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: .35rem;
}
.dropdown-menu .dropdown-item { border-radius: var(--radius-sm); padding: .5rem .7rem; }


/* ============================================================================
 * 8. FORMS & FOCUS
 * ========================================================================== */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--hairline);
  padding: .6rem .8rem;
  background-color: var(--surface-raised);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: #9fb0c4; }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 .2rem rgba(var(--brand-600-rgb), .18);
}
.input-group-text {
  background: var(--brand-50);
  border-color: var(--hairline);
  color: var(--brand-700);
}
.form-label { font-weight: 500; color: var(--ink-700); margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(var(--brand-600-rgb), .18); }


/* ============================================================================
 * 9. SEARCHABLE COMBOBOX  (client selector)
 * ========================================================================== */
.combobox { position: relative; }

.combobox__menu {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 1065;                 /* above modal content & sibling fields */
  background: var(--surface-raised);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  padding: .35rem;
  display: none;                 /* shown via .combobox.open */
}
.combobox.open .combobox__menu {
  display: block;
  animation: combobox-in .15s var(--ease-out);
}
.combobox__option {
  padding: .55rem .65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  transition: background-color .12s ease;
}
.combobox__option .opt-sub { font-size: .8rem; color: var(--ink-500); }
.combobox__option:hover,
.combobox__option.is-active {           /* keyboard navigation highlight */
  background: var(--brand-50);
  color: var(--brand-700);
}
.combobox__empty { padding: .65rem; color: var(--ink-500); font-size: .875rem; }

@keyframes combobox-in {
  from { opacity: 0; transform: translateY(-4px) scale(.99); }
  to   { opacity: 1; transform: none; }
}


/* ============================================================================
 * 10. CARDS & STAT (KPI) CARDS
 * ========================================================================== */
.card {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

/* Quick-stats band on the dashboard (rendered by dashboard.js) */
.stat-card {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  padding: 1.25rem 1.3rem;
  box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease-out), box-shadow .2s ease, border-color .2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }
.stat-card__label { color: var(--ink-500); font-size: .74rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; }
.stat-card__value { color: var(--ink-900); font-size: 1.85rem; font-weight: 800;
  line-height: 1.05; margin-top: .35rem; letter-spacing: -.03em; }
.stat-card__sub { color: var(--ink-500); font-size: .8rem; margin-top: .15rem; }
.stat-card__icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: #1c1c1e; color: #fff; font-size: 1.25rem;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .18);
}

/* Dashboard charts (hand-built SVG) */
.chart-card { padding: 1.15rem 1.25rem; display: flex; flex-direction: column; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.chart-legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--ink-500); }
.chart-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-axis { fill: var(--ink-500); font-size: 11px; font-weight: 500; }
.donut-wrap { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.donut-svg { width: 140px; height: 140px; flex: 0 0 auto; }
.donut-total { fill: var(--ink-900); font-size: 26px; font-weight: 800; }
.donut-sub { fill: var(--ink-500); font-size: 11px; letter-spacing: .05em; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 140px; min-width: 140px; }
.donut-legend li { display: flex; align-items: center; gap: .5rem; font-size: .85rem; padding: .22rem 0; color: var(--ink-700); }
.donut-legend .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
@media (max-width: 575.98px) {
  .donut-wrap { justify-content: center; text-align: left; }
  .donut-legend { flex-basis: 100%; }
}


/* ============================================================================
 * 11. TABLES
 * ========================================================================== */
.table-wrap {
  position: relative;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table { margin: 0; --bs-table-hover-bg: var(--brand-50); }
.table > thead th {
  background: var(--thead-bg);
  color: var(--ink-500);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.table > tbody td { vertical-align: middle; border-color: var(--hairline); }


/* ============================================================================
 * 12. STATUS PILLS & BADGES
 * ========================================================================== */
.text-bg-primary { background-color: var(--brand-600) !important; }
.badge.text-bg-primary { background-color: var(--brand-600) !important; }

.status-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill--draft   { background: #eef2f7; color: #5b6b7f; }
.status-pill--sent    { background: var(--brand-50); color: var(--brand-700); }
.status-pill--due     { background: var(--brand-50); color: var(--brand-700); }
.status-pill--partial { background: var(--warn-50);  color: var(--warn-600); }
.status-pill--paid    { background: var(--ok-50);    color: var(--ok-600); }
.status-pill--overdue { background: var(--danger-50);color: var(--danger-600); }

/* Optional line-item detail sub-row (make/model, serial, weight) */
.line-detail-row td { background: transparent; }
.line-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding-left: .7rem;
  border-left: 2px solid var(--brand-100, #dce9fb);
}
.line-detail__hint {
  font-size: .66rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #8a97a8;
  flex: 0 0 auto;
}
.line-detail .form-control-sm { flex: 1 1 150px; min-width: 130px; }
.line-detail__weight { flex: 0 0 92px !important; min-width: 0 !important; }
.line-detail__unit { flex: 0 0 76px; width: 76px; }


/* ============================================================================
 * 13. MODALS
 * ========================================================================== */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--ink-700);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  border-bottom: 1px solid var(--hairline);
  background: var(--brand-grad-soft);
}
.modal-footer { border-top: 1px solid var(--hairline); }
.modal.fade .modal-dialog {
  transform: translateY(12px) scale(.98);
  transition: transform .22s var(--ease-out);
}
.modal.show .modal-dialog { transform: none; }


/* ============================================================================
 * 14. TOASTS
 * ========================================================================== */
.toast-container { padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0)); z-index: 1090; }
.toast {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--brand-600);
}
.toast.toast--success { border-left-color: var(--ok-600); }
.toast.toast--error   { border-left-color: var(--danger-600); }
.toast.toast--warning { border-left-color: var(--warn-600); }


/* ============================================================================
 * 15. SCROLLBARS  (thin, on-brand — WebKit/Blink)
 * ========================================================================== */
* { scrollbar-width: thin; scrollbar-color: var(--brand-200) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--brand-200);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--brand-300); background-clip: content-box; }


/* ============================================================================
 * 16. ANIMATIONS & UTILITIES
 * ========================================================================== */
/* Gentle entrance used when views swap in (add .view-enter from JS). */
.view-enter { animation: view-in .26s var(--ease-out); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.elevate-hover { transition: transform .2s var(--ease-out), box-shadow .2s ease; }
.elevate-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.text-brand { color: var(--brand-600) !important; }
.bg-brand-soft { background: var(--brand-50) !important; }


/* ============================================================================
 * 17. RESPONSIVE TWEAKS
 * ========================================================================== */
@media (max-width: 575.98px) {
  :root { --bs-body-font-size: 0.94rem; }
  .ticker-bar__brand span { display: none; }       /* tighten on tiny screens */
  .stat-card__value { font-size: 1.4rem; }
  .modal-dialog { margin: .6rem; }
}

/* On phones, let the collapsed nav menu breathe and stack cleanly. */
@media (max-width: 991.98px) {
  .app-navbar .navbar-collapse {
    margin-top: .6rem;
    padding-top: .6rem;
    border-top: 1px solid var(--hairline);
  }
  .app-navbar .nav-link { padding: .6rem .8rem !important; }
}


/* ============================================================================
 * 18. ACCESSIBILITY  ·  focus-visible + reduced motion
 * ========================================================================== */
:focus-visible {
  outline: 3px solid rgba(var(--brand-600-rgb), .45);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Mouse users don't get the ring; keyboard users do (above). */
:focus:not(:focus-visible) { outline: none; }


/* ============================================================================
 * MICRO-INTERACTIONS  ·  modal entrance, hover lifts, smooth transitions
 * (All neutralised by the reduced-motion query below.)
 * ========================================================================== */

/* Modals: soft scale + fade entrance and a gently blurred backdrop. */
.modal.fade .modal-dialog {
  transform: scale(.96) translateY(12px);
  opacity: 0;
  transition: transform .28s var(--ease-spring), opacity .22s ease;
}
.modal.show .modal-dialog { transform: none; opacity: 1; }
.modal-backdrop.show { backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.modal-content { box-shadow: var(--shadow-lg); }

/* Cards & stat-cards lift slightly on hover. */
.card, .stat-card {
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* Table rows gently highlight + nudge on hover. */
.table tbody tr {
  transition: background-color .14s ease, box-shadow .14s ease;
}
.table tbody tr:hover { box-shadow: inset 3px 0 0 var(--brand-500); }

/* Buttons: a touch of lift on hover, crisp press. */
.btn { transition: transform .12s var(--ease-spring), box-shadow .18s ease, background-color .18s ease, border-color .18s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.98); }

/* Status pills + badges ease their colour changes. */
.status-pill, .badge { transition: background-color .18s ease, color .18s ease; }

/* Nav links slide their background in smoothly. */
.app-navbar .nav-link { transition: background-color .18s ease, color .18s ease, box-shadow .18s ease; }

/* Toasts drift up as they appear. */
.toast { animation: toast-rise .32s var(--ease-out); }
@keyframes toast-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .ticker-bar { animation: none; background-position: 0 0; }
}


/* ============================================================================
 * 19. THEME TOGGLE BUTTON
 * ========================================================================== */
.theme-toggle {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface-raised);
  color: var(--ink-700);
  cursor: pointer;
  font-size: 1.05rem;
  transition: transform .12s var(--ease-spring), background-color .18s ease,
              color .18s ease, border-color .18s ease;
}
.theme-toggle:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.theme-toggle:active { transform: scale(.92); }
/* Swap the icon glyphs depending on the active theme. */
.theme-toggle .bi-sun-fill { display: none; }
[data-theme="dark"] .theme-toggle .bi-sun-fill  { display: inline; }
[data-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }


/* ============================================================================
 * 20. DARK THEME  ·  flips the semantic tokens; brand identity stays blue
 * ========================================================================== */
[data-theme="dark"] {
  color-scheme: dark;

  /* Brand tints re-tuned for dark surfaces (used as panel/hover fills) */
  --brand-100: #2c2c2e;
  --brand-50:  #1c1c1e;

  /* Neutrals — true-black iOS palette */
  --ink-900: #ffffff;
  --ink-700: #e5e5ea;
  --ink-500: #98989f;
  --surface:   #1c1c1e;   /* grouped card surface (iOS dark) */
  --surface-2: #000000;   /* app background — true black */
  --hairline:  #2c2c2e;

  /* Surface helpers */
  --surface-raised: #2c2c2e;
  --thead-bg: #1c1c1e;
  --glass-bg: rgba(0, 0, 0, .72);
  --glass-bg-strong: rgba(10, 10, 10, .94);

  /* Status pill backgrounds toned down for dark; keep readable text */
  --ok-50: rgba(48, 209, 88, .18);
  --warn-50: rgba(255, 214, 10, .18);
  --danger-50: rgba(255, 69, 58, .18);
  --ok-600: #30d158;
  --warn-600: #ffd60a;
  --danger-600: #ff453a;

  /* Bootstrap re-points for dark */
  --bs-body-bg: var(--surface-2);
  --bs-body-color: var(--ink-700);
  --bs-emphasis-color: var(--ink-900);
  --bs-secondary-color: var(--ink-500);
  --bs-border-color: var(--hairline);
  --bs-link-color: #ffffff;
  --bs-link-hover-color: #d2d2d7;

  /* Component surfaces (modals, dropdowns, inputs) → dark */
  --bs-modal-bg: var(--surface);
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-link-color: var(--ink-700);
  --bs-dropdown-link-hover-bg: var(--surface-raised);
  --bs-dropdown-link-hover-color: var(--ink-900);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .55);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, .6);
  --shadow-lg: 0 20px 52px rgba(0, 0, 0, .7);
}

/* App background — flat true black (no blue wash) */
[data-theme="dark"] body { background: var(--surface-2); }

/* Login — subtle near-black, no blue glow */
[data-theme="dark"] #login-screen { background: var(--surface-2); }

/* Inputs / selects → dark fill with subtle border */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #1c1c1e;
  border-color: #38383a;
  color: var(--ink-900);
}
[data-theme="dark"] .form-control::placeholder { color: #6b6b70; }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #1c1c1e;
  border-color: #5a5a5e;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .08);
}
[data-theme="dark"] .input-group-text {
  background: #2c2c2e;
  border-color: #38383a;
  color: var(--ink-500);
}

/* Cards / modals / dropdowns → dark grouped surfaces */
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .line-item,
[data-theme="dark"] .inv-card,
[data-theme="dark"] .stat-card {
  background: var(--surface);
  border-color: var(--hairline);
  color: var(--ink-700);
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--hairline); }

/* Mac title bar follows the dark surface */
[data-theme="dark"] #mac-titlebar { background: var(--surface); border-bottom-color: var(--hairline); }

/* Primary buttons INVERT on black → white button, black text (iOS/Claude) */
[data-theme="dark"] .btn-primary {
  --bs-btn-color: #000;
  --bs-btn-bg: #ffffff;
  --bs-btn-border-color: #ffffff;
  --bs-btn-hover-color: #000;
  --bs-btn-hover-bg: #e5e5ea;
  --bs-btn-hover-border-color: #e5e5ea;
  --bs-btn-active-color: #000;
  --bs-btn-active-bg: #d2d2d7;
  --bs-btn-active-border-color: #d2d2d7;
  box-shadow: none;
}
[data-theme="dark"] .btn-outline-primary {
  --bs-btn-color: #fff;
  --bs-btn-border-color: #48484a;
  --bs-btn-hover-bg: #fff;
  --bs-btn-hover-color: #000;
  --bs-btn-hover-border-color: #fff;
}

/* Active nav item in dark → white pill with black text */
[data-theme="dark"] .app-navbar .nav-link.active,
[data-theme="dark"] .navbar .nav-link.active {
  background: #ffffff !important;
  color: #000 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5) !important;
}

/* The draft pill uses literal greys — give it a dark variant */
[data-theme="dark"] .status-pill--draft { background: #2c2c2e; color: #c7c7cc; }

/* Secondary "light" buttons → elevated dark, light text */
[data-theme="dark"] .btn-light {
  --bs-btn-color: var(--ink-900);
  --bs-btn-bg: #2c2c2e;
  --bs-btn-border-color: #2c2c2e;
  --bs-btn-hover-bg: #3a3a3c;
  --bs-btn-hover-color: var(--ink-900);
  --bs-btn-hover-border-color: #3a3a3c;
  --bs-btn-active-bg: #3a3a3c;
  --bs-btn-active-color: var(--ink-900);
}
[data-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: var(--ink-700);
  --bs-btn-border-color: var(--hairline);
  --bs-btn-hover-bg: var(--surface-raised);
  --bs-btn-hover-color: var(--ink-900);
  --bs-btn-hover-border-color: #5a5a5e;
}

/* Modal close button + various icons need to invert in dark */
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.8); }

/* Bootstrap text-muted utility should follow our muted ink */
[data-theme="dark"] .text-muted { color: var(--ink-500) !important; }

/* Toasts get a dark surface */
[data-theme="dark"] .toast {
  background: var(--surface-raised);
  color: var(--ink-700);
}

/* Tables: ensure cell text + striping read well on dark */
[data-theme="dark"] .table {
  --bs-table-color: var(--ink-700);
  --bs-table-bg: transparent;
  --bs-table-hover-color: var(--ink-900);
  --bs-table-hover-bg: rgba(255, 255, 255, .04);
  --bs-table-border-color: var(--hairline);
}

/* Soft selection tint for dark */
[data-theme="dark"] ::selection { background: #ffffff; color: #000; }

/* Ticker bar (desktop) + nav → black surfaces, no blue */
[data-theme="dark"] .ticker-bar {
  background: #000;
  border-bottom: 1px solid var(--hairline);
}
[data-theme="dark"] .ticker-bar__brand,
[data-theme="dark"] .ticker-bar__carousel { color: var(--ink-500); }
[data-theme="dark"] .app-navbar { background: var(--glass-bg-strong); border-bottom: 1px solid var(--hairline); }


/* ============================================================================
 * DEVICE SMOOTHNESS  ·  touch tuning + GPU compositing
 * ========================================================================== */
/* Kill the 300ms tap delay and remove sticky hover states on touch devices. */
.btn, .nav-link, .dropdown-item, [data-nav], .stat-card, a, summary {
  touch-action: manipulation;
}
@media (hover: none) {
  .card:hover, .stat-card:hover, .table tbody tr:hover,
  .btn:hover:not(:disabled) { transform: none; box-shadow: var(--shadow-sm); }
  .table tbody tr:hover { box-shadow: none; }
}
/* Smooth, momentum scrolling inside scroll regions. */
.table-responsive, .modal-body { -webkit-overflow-scrolling: touch; }


/* ============================================================================
 * iOS-STYLE REFRESH  ·  grouped cards, soft controls, generous spacing
 * ========================================================================== */
.card-body { padding: 1.3rem 1.4rem; }

/* Form controls: rounded, gently filled, calm focus ring */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--hairline);
  padding: .62rem .9rem;
  font-size: .98rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
  border-color: #1c1c1e;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .08);
}
.input-group-text {
  border-radius: var(--radius-sm);
  border-color: var(--hairline);
  background: var(--surface-2);
  color: var(--ink-500);
  font-weight: 600;
}
.form-label { font-weight: 600; font-size: .85rem; color: var(--ink-700); margin-bottom: .35rem; }

/* Switches a touch larger / more tactile (matches the Settings look) */
.form-switch .form-check-input { height: 1.5em; width: 2.8em; cursor: pointer; }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }

/* Buttons: confident, rounded, iOS/Claude black */
.btn { border-radius: .85rem; font-weight: 600; padding: .58rem 1.15rem; transition: transform .06s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease; }
.btn-sm { border-radius: .65rem; padding: .36rem .7rem; }
.btn-lg { border-radius: 1rem; }
.btn:active { transform: scale(.97); }          /* native tap feedback */

/* Primary → solid near-black (like Claude / iOS action buttons) */
.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: #1c1c1e;
  --bs-btn-border-color: #1c1c1e;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #000;
  --bs-btn-hover-border-color: #000;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #000;
  --bs-btn-active-border-color: #000;
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: #8e8e93;
  --bs-btn-disabled-border-color: #8e8e93;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

/* Outline-primary → minimalist ink outline that fills black on hover */
.btn-outline-primary {
  --bs-btn-color: #1c1c1e;
  --bs-btn-border-color: #d2d2d7;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #1c1c1e;
  --bs-btn-hover-border-color: #1c1c1e;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #000;
  --bs-btn-active-border-color: #000;
}

/* Secondary "light" buttons → clean iOS grey, not blue-ish */
.btn-light {
  --bs-btn-color: #1c1c1e;
  --bs-btn-bg: #f2f3f7;
  --bs-btn-border-color: #f2f3f7;
  --bs-btn-hover-bg: #e7e8ee;
  --bs-btn-hover-border-color: #e7e8ee;
  --bs-btn-active-bg: #e1e2e9;
}

/* Active nav item → ink, matching the black button language */
.app-navbar .nav-link.active,
.navbar .nav-link.active {
  background: #1c1c1e !important;
  color: #fff !important;
  border-radius: .85rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .22) !important;
}

/* Line items as clean stacked cards (works on desktop + mobile) */
.line-items { display: flex; flex-direction: column; gap: .75rem; }
.line-item {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  padding: .9rem;
}
.line-item__row1 { display: flex; gap: .5rem; align-items: center; }
.line-item__row1 > .form-control { flex: 1 1 auto; }
.line-item__remove { flex: 0 0 auto; }
.line-item__row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .65rem; }
.line-item__row2 label { display: flex; flex-direction: column; gap: .25rem; margin: 0; font-size: .76rem; font-weight: 600; color: var(--ink-500); }
.line-item__totalline { display: flex; justify-content: space-between; align-items: center; margin-top: .65rem; padding-top: .55rem; border-top: 1px dashed var(--hairline); font-weight: 700; }
.line-item__detailshd { margin-top: .85rem; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-400, var(--ink-500)); }
.line-item__details { display: grid; gap: .65rem; margin-top: .45rem; grid-template-columns: 1fr; }
.line-item__details > label { display: flex; flex-direction: column; gap: .25rem; margin: 0; font-size: .76rem; font-weight: 600; color: var(--ink-500); }
.line-item__weightrow { display: grid; grid-template-columns: 1fr 96px; gap: .4rem; }
@media (min-width: 576px) {
  .line-item__details { grid-template-columns: 1fr 1fr; }   /* two-up once there's room */
}

/* Modals as clean iOS sheets */
.modal-content { border-radius: var(--radius-lg); }
.modal-header, .modal-footer { border-color: var(--hairline); }

/* Tighter, more confident headings */
h1, h2, h3, .h1, .h2, .h3, .h4, .h5 { letter-spacing: -.02em; }

/* Tables breathe a little more */
.table > :not(caption) > * > * { padding-top: .8rem; padding-bottom: .8rem; }

/* Account menu: email wraps fully, menu stays on-screen */
.account-menu { min-width: 220px; max-width: min(86vw, 320px); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.account-menu #current-user-email { display: block; white-space: normal; overflow-wrap: anywhere; word-break: break-all; }
/* On mobile the account menu lives inside the collapsed navbar — render it
   inline (full width) so the email never overflows or overlaps the page. */
@media (max-width: 991.98px) {
  .account-menu {
    position: static !important; float: none; transform: none !important;
    width: 100%; max-width: 100%; margin-top: .35rem;
    box-shadow: none; border: 1px solid var(--hairline);
  }
}

/* ============================================================================
 * DASHBOARD  ·  iOS activity list + bold financial highlights
 * ========================================================================== */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
  display: flex; align-items: center; gap: .85rem;
  padding: .85rem 1.4rem;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
  transition: background-color .12s ease;
}
.activity-item:first-child { border-top: 0; }
.activity-item:hover { background: var(--surface-2); }
.activity-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; padding: 0; background: #8e8e93; }
.activity-dot.status-pill--paid    { background: #30d158; }
.activity-dot.status-pill--overdue { background: #ff453a; }
.activity-dot.status-pill--partial { background: #ff9f0a; }
.activity-dot.status-pill--due     { background: var(--ink-900); }
.activity-dot.status-pill--sent    { background: #8e8e93; }
.activity-dot.status-pill--draft   { background: #c7c7cc; }
.activity-main { flex: 1 1 auto; min-width: 0; }
.activity-title { font-weight: 700; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-sub { font-size: .8rem; color: var(--ink-500); }
.activity-end { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex: 0 0 auto; }
.activity-amount { font-weight: 800; letter-spacing: -.01em; color: var(--ink-900); }

/* Financial highlights — bold, prominent ledger figures */
.inv-amount { font-weight: 800; font-size: 1.02rem; letter-spacing: -.01em; color: var(--ink-900); }
.outstanding-total { font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; color: var(--ink-900); line-height: 1.1; }

/* Stat-card values read bolder + tighter (Apple numerals) */
.stat-card__value { font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ============================================================================
 * macOS-STYLE TITLE BAR  ·  desktop PWA with Window Controls Overlay only
 * ========================================================================== */
#mac-titlebar { display: none; }
body.wco-active #mac-titlebar {
  display: flex;
  align-items: center;
  gap: .65rem;
  position: fixed;
  top: env(titlebar-area-y, 0);
  left: env(titlebar-area-x, 0);
  width: env(titlebar-area-width, 100%);
  height: env(titlebar-area-height, 34px);
  padding: 0 .9rem;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  z-index: 3000;
  -webkit-app-region: drag;
  app-region: drag;
}
.mac-traffic { display: flex; gap: 8px; -webkit-app-region: no-drag; app-region: no-drag; }
.mac-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer;
  transition: filter .12s ease, transform .06s ease;
}
.mac-dot--close { background: #ff5f57; }
.mac-dot--min   { background: #febc2e; }
.mac-dot--max   { background: #28c840; }
.mac-dot:hover  { filter: brightness(.9); }
.mac-dot:active { transform: scale(.9); }
.mac-title { font-size: .8rem; font-weight: 600; color: var(--ink-500); }

/* Keep app content clear of the overlay bar */
body.wco-active { padding-top: env(titlebar-area-height, 34px); }
body.wco-active .app-navbar.sticky-top { top: env(titlebar-area-height, 34px); }


/* ============================================================================
 * MOBILE NATIVE EXPERIENCE  (phones, ≤ 767.98px)
 * ========================================================================== */
@media (max-width: 767.98px) {

  /* Stats ticker is hidden entirely on phones */
  .ticker-bar { display: none !important; }

  /* Comfortable, consistent edge padding — content never touches the edge */
  #view-container { padding-left: 1rem !important; padding-right: 1rem !important; }

  /* Long strings (emails, IBANs) wrap; normal words are NOT split mid-word */
  #view-container, .card, .list-group-item, td, th, dd, dt, p {
    overflow-wrap: break-word;
  }
  .inv-card__client, .text-break-anywhere, [data-label="Client"] { overflow-wrap: anywhere; }

  /* Roomier, properly sized touch targets */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }

  /* Dashboard stat cards: full width, comfortable numbers */
  .stat-card { padding: 1rem 1.1rem; }
  .stat-card__value { font-size: 1.55rem; }

  /* Charts never overflow their card */
  .chart-svg, .donut-svg { max-width: 100%; height: auto; }
  .donut-wrap { justify-content: flex-start; }

  /* Modal feels like a native sheet, with breathing room */
  .modal-dialog { margin: .5rem; }

  /* Data tables: swipe horizontally instead of crushing columns into "Du e" */
  .table-responsive { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .table-responsive > .table { min-width: 580px; }
  .table-responsive > .table th,
  .table-responsive > .table td { white-space: nowrap; }
  .table-responsive > .table .status-pill,
  .table-responsive > .table .badge { white-space: nowrap; }

  /* ---- Invoices: dedicated readable card list (built in invoices.js) ---- */
  .invoices-cards { display: flex; flex-direction: column; gap: .85rem; }

  .inv-card {
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.1rem;
  }
  .inv-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
  }
  .inv-card__client {
    font-weight: 700;
    font-size: 1.08rem;
    line-height: 1.25;
    color: var(--ink-900);
    overflow-wrap: anywhere;
  }
  .inv-card__num { font-size: .8rem; color: var(--ink-500); margin-top: .12rem; }
  .inv-card__head .dropdown { flex: 0 0 auto; }

  .inv-card__figures {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-top: .75rem;
  }
  .inv-card__amt { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink-900); }
  .inv-card__due { font-size: .85rem; color: var(--ink-500); text-align: right; }
  .inv-card__due.is-overdue { color: var(--danger-600); font-weight: 600; }

  .inv-card__remind { margin-top: .55rem; font-size: .78rem; color: var(--ink-500); }

  .inv-card__actions {
    display: flex;
    gap: .35rem;
    margin-top: .9rem;
    padding-top: .85rem;
    border-top: 1px solid var(--hairline);
  }
  .inv-card__actions .btn {
    flex: 1 1 0;
    min-width: 0;                 /* shrink to fit — never force horizontal overflow */
    height: 44px;                 /* HIG: keep a 44px touch target */
    padding: 0;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}


/* ============================================================================
 * PAYMENT LEDGER  (Phase 1)
 * ========================================================================== */
.payment-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
  background: var(--surface-2); border-radius: var(--radius); padding: .85rem 1rem;
}
.payment-summary > div { display: flex; flex-direction: column; gap: .15rem; }
.payment-summary__k { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); font-weight: 600; }
.payment-summary__v { font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.payment-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--hairline); }
.payment-row:first-child { border-top: 0; }
.payment-row__amt { font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.payment-row__meta { font-size: .8rem; color: var(--ink-500); }


/* ============================================================================
 * iOS-STYLE ACTIVITY SPINNER  (restyles Bootstrap's .spinner-border)
 * ========================================================================== */
.spinner-border,
.spinner-border-sm {
  display: inline-block;
  width: 2rem; height: 2rem;
  border: none !important;
  border-radius: 0;
  color: rgba(60, 60, 67, .55);                 /* iOS systemGray (light) */
  background: none;
  background-color: currentColor;               /* shows through the spoke mask */
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%221.0%22%20transform%3D%22rotate%280%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.923%22%20transform%3D%22rotate%2830%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.845%22%20transform%3D%22rotate%2860%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.768%22%20transform%3D%22rotate%2890%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.691%22%20transform%3D%22rotate%28120%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.614%22%20transform%3D%22rotate%28150%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.536%22%20transform%3D%22rotate%28180%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.459%22%20transform%3D%22rotate%28210%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.382%22%20transform%3D%22rotate%28240%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.305%22%20transform%3D%22rotate%28270%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.227%22%20transform%3D%22rotate%28300%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.15%22%20transform%3D%22rotate%28330%2012%2012%29%22%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%221.0%22%20transform%3D%22rotate%280%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.923%22%20transform%3D%22rotate%2830%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.845%22%20transform%3D%22rotate%2860%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.768%22%20transform%3D%22rotate%2890%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.691%22%20transform%3D%22rotate%28120%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.614%22%20transform%3D%22rotate%28150%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.536%22%20transform%3D%22rotate%28180%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.459%22%20transform%3D%22rotate%28210%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.382%22%20transform%3D%22rotate%28240%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.305%22%20transform%3D%22rotate%28270%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.227%22%20transform%3D%22rotate%28300%2012%2012%29%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%222%22%20width%3D%222%22%20height%3D%225.5%22%20rx%3D%221%22%20fill%3D%22%23000%22%20opacity%3D%220.15%22%20transform%3D%22rotate%28330%2012%2012%29%22%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
  animation: ios-spin 1s steps(12, end) infinite;
}
.spinner-border-sm { width: 1.15rem; height: 1.15rem; }
.btn .spinner-border,
.btn .spinner-border-sm { color: currentColor; }   /* match the button's text colour */
[data-theme="dark"] .spinner-border,
[data-theme="dark"] .spinner-border-sm { color: rgba(235, 235, 245, .6); }
@keyframes ios-spin { to { transform: rotate(360deg); } }


/* ============================================================================
 * PAYMENTS VIEW
 * ========================================================================== */
.stat-card__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); font-weight: 600; margin-bottom: .25rem; }
.pay-card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: .85rem 1rem; margin-bottom: .7rem;
}
.pay-card__top { display: flex; align-items: center; justify-content: space-between; }
.pay-card__amt { font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.pay-card__meta { font-size: .82rem; color: var(--ink-500); margin-top: .15rem; }
.pay-card__inv { font-weight: 600; color: var(--ink-700); margin-top: .25rem; overflow-wrap: anywhere; }


/* ============================================================================
 * iOS SEGMENTED CONTROL + TEMPLATE CHIPS  (Email templates)
 * ========================================================================== */
.seg {
  display: flex; width: max-content; max-width: 100%;
  background: var(--surface-2); border-radius: .7rem; padding: 3px; gap: 2px;
  overflow-x: auto;                       /* scroll the strip instead of clipping tabs */
  scrollbar-width: none;                  /* hide scrollbar (native feel) */
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  flex: 0 0 auto; border: 0; background: transparent; border-radius: .55rem;
  padding: .45rem .8rem; font-weight: 600; font-size: .9rem; color: var(--ink-700);
  white-space: nowrap; scroll-snap-align: center;
  cursor: pointer; transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg-btn:hover { color: var(--ink-900); }
.seg-btn.is-active { background: var(--surface); color: var(--ink-900); box-shadow: var(--shadow-sm); }
.tpl-vars { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.tpl-chip {
  border: 1px solid var(--hairline); background: var(--surface-2); color: var(--ink-700);
  border-radius: .5rem; padding: .15rem .5rem; font-size: .76rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tpl-chip:hover { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }


/* ============================================================================
 * iOS / macOS INTERACTION POLISH  ·  unified, app-wide (LAST = wins)
 *
 * Hover effects apply ONLY where a precise pointer exists (Mac/PC). Touch
 * devices (iPhone/iPad) get clean :active tap feedback instead — no "stuck
 * hover". All hovers are calm and neutral: a soft grey wash, no blue tints,
 * no exaggerated lifts. This is the native Apple feel.
 * ========================================================================== */

/* ---- Pointer devices (Mac / PC): subtle, neutral hover -------------------- */
@media (hover: hover) and (pointer: fine) {
  a:hover { opacity: .82; }
  .app-navbar .nav-link:hover { background: var(--surface-2); color: var(--ink-900); }
  .app-navbar .nav-link.active:hover { color: #fff; }
  .table tbody tr:hover { background: var(--surface-2); box-shadow: none; }
  .list-group-item-action:hover { background: var(--surface-2); }
  .dropdown-item:hover,
  .combobox__option:hover { background: var(--surface-2); color: var(--ink-900); }
  .activity-item:hover { background: var(--surface-2); }
  .inv-card:hover, .pay-card:hover { box-shadow: var(--shadow-md); }

  /* Cards settle with a soft shadow instead of jumping up. */
  .card:hover { transform: none; box-shadow: var(--shadow-md); }
  .stat-card:hover { transform: none; box-shadow: var(--shadow-md); border-color: var(--hairline); }
  .elevate-hover:hover { transform: none; box-shadow: var(--shadow-md); }

  /* Buttons: no lift on hover; the squish happens on press (below). */
  .btn:hover:not(:disabled) { transform: none; }
  .btn-primary:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
  .btn-light:hover { background: var(--surface-2); }
  .btn-outline-primary:hover { background: var(--surface-2); }
  .theme-toggle:hover { background: var(--surface-2); color: var(--ink-900); border-color: var(--hairline); }
  .seg-btn:hover { color: var(--ink-900); }
  .mac-dot:hover { filter: brightness(.92); }

  /* Neutral, translucent scrollbars (Apple style) — no blue. */
  *::-webkit-scrollbar-thumb:hover { background: rgba(120, 120, 128, .55); }
}

/* ---- Touch devices: kill sticky hover, keep it flat ----------------------- */
@media (hover: none) {
  .card:hover, .stat-card:hover, .elevate-hover:hover,
  .inv-card:hover, .pay-card:hover { transform: none; box-shadow: var(--shadow-sm); }
  .table tbody tr:hover { background: transparent; box-shadow: none; }
  .btn:hover:not(:disabled) { transform: none; }
}

/* ---- Universal press feedback (touch + pointer): the iOS "squish/wash" ----- */
.btn:active:not(:disabled) { transform: scale(.97); }
.list-group-item-action:active,
.activity-item:active,
.dropdown-item:active,
.combobox__option:active,
.seg-btn:active,
.tpl-chip:active,
.inv-card:active,
.pay-card:active,
.stat-card:active,
.table tbody tr:active { background: var(--surface-2); }
.app-navbar .nav-link:active { opacity: .7; }

/* Base scrollbar tint (neutral, not blue). */
*::-webkit-scrollbar-thumb { background: rgba(120, 120, 128, .38); }


/* ============================================================================
 * AMENDMENT MODE  (paid-invoice editing)
 * ========================================================================== */
.amend-banner {
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem;
}
.amend-banner__row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.badge-amended {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  color: #8a6d00; background: #fff4d6; border: 1px solid #f3e2a8;
  border-radius: 999px; padding: .1rem .5rem; margin-left: .4rem; vertical-align: middle;
}


/* Inline new-client panel inside the invoice modal */
.newc-panel {
  margin-top: .6rem; padding: .9rem 1rem;
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius);
}


/* ============================================================================
 * BATCH ACTION BAR  (Phase 3 — date filter + multi-select)
 * ========================================================================== */
.batch-bar {
  position: sticky; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin: 1rem 0 .5rem; padding: .7rem .9rem .7rem 1.1rem;
  background: var(--ink-900); color: #fff;
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  animation: batch-rise .18s var(--ease-out, ease);
}
@keyframes batch-rise { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.batch-bar__count { font-weight: 700; letter-spacing: -.01em; }
.batch-bar__actions { display: flex; gap: .5rem; }
.batch-bar .btn-primary { background: #fff; color: var(--ink-900); border: 0; }
.batch-bar .btn-primary:hover { background: #f1f1f3; box-shadow: none; }
.batch-bar .btn-light { background: rgba(255, 255, 255, .16); color: #fff; border: 0; }
.batch-bar .btn-light:hover { background: rgba(255, 255, 255, .26); }
.row-check { cursor: pointer; }


/* ============================================================================
 * DATE RANGE FILTER  (clean, readable, responsive)
 * ========================================================================== */
.date-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.date-filter__group { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 160px; min-width: 150px; }
.date-filter__group label { font-size: .78rem; font-weight: 600; color: var(--ink-500); margin: 0; }
.date-filter__group .form-control { width: 100%; }
.date-filter__buttons { display: flex; gap: .5rem; flex: 0 0 auto; align-items: flex-end; }
@media (max-width: 575.98px) {
  .date-filter__group { flex: 1 1 100%; }
  .date-filter__buttons { width: 100%; }
  .date-filter__buttons .btn:first-child { flex: 1 1 auto; }
}


/* Editable payment rows (ledger) */
.payment-row__actions { display: flex; gap: .35rem; flex: 0 0 auto; }
.payment-row--edit { align-items: flex-start; }
.payment-edit { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; flex: 1 1 auto; }
.payment-edit .form-select { grid-column: 1 / -1; }
@media (min-width: 576px) { .payment-edit { grid-template-columns: 1fr 1fr 1fr; } .payment-edit .form-select { grid-column: auto; } }


/* iOS-style settings detail row (e.g. Version) */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem; }
.settings-row__label { font-weight: 500; color: var(--ink-900); }
.settings-row__value { color: var(--ink-500); font-variant-numeric: tabular-nums; }


/* ============================================================================
 * SEARCHABLE INVOICE COMBOBOX (Payments)
 * ========================================================================== */
.pay-combobox { position: relative; }
.pay-combobox__menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  margin: 0; padding: .3rem; list-style: none;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow-md); max-height: 280px; overflow-y: auto; display: none;
}
.pay-combobox.is-open .pay-combobox__menu { display: block; }
.pay-combobox__option { padding: .5rem .6rem; border-radius: .55rem; cursor: pointer; display: flex; flex-direction: column; gap: .1rem; }
.pay-combobox__option:hover { background: var(--surface-2); }
.pay-combobox__num { font-weight: 600; color: var(--ink-900); }
.pay-combobox__sub { font-size: .8rem; color: var(--ink-500); }
.pay-combobox__empty { padding: .6rem; color: var(--ink-500); font-size: .85rem; }


/* ============================================================================
 * DASHBOARD · OUTSTANDING INVOICES (native mobile layout)
 * ========================================================================== */
.out-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; padding: 1rem 1rem 0;
}
.out-head__total { text-align: right; }
.out-head__label { color: var(--ink-500); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; }
.out-row {
  display: flex; align-items: center; justify-content: space-between; gap: .85rem;
  padding: .75rem 1rem; border-top: 1px solid var(--hairline); cursor: pointer;
}
.out-row__main { min-width: 0; flex: 1 1 auto; }
.out-row__client { font-weight: 600; color: var(--ink-900); overflow-wrap: anywhere; }
.out-row__sub { font-size: .8rem; color: var(--ink-500); margin-top: .12rem; overflow-wrap: anywhere; }
.out-row__right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; text-align: right; }
.out-row__right .inv-amount { font-size: 1.05rem; white-space: nowrap; }


/* ============================================================================
 * NATIVE-APP FEEL · lock down interface text selection + mobile tap highlight
 * ----------------------------------------------------------------------------
 * Native iOS/macOS/Android/Windows apps don't let you highlight UI labels by
 * tapping, long-pressing or dragging. Browsers make everything selectable by
 * default, which is the #1 "this is a website" tell. We disable selection app-
 * wide, then RE-ENABLE it for form fields (so typing/editing still works) and
 * for anything explicitly marked `.selectable` (for data you want to copy).
 * ========================================================================== */
html {
  -webkit-tap-highlight-color: transparent;   /* no grey/blue flash on tap (mobile) */
}
body {
  -webkit-touch-callout: none;                /* no iOS long-press copy/lookup popover */
  -webkit-user-select: none;                  /* Safari / iOS / Chrome */
  -ms-user-select: none;                      /* legacy Edge */
  user-select: none;
}

/* Form controls must stay selectable & editable, or typing feels broken. */
input, textarea, select,
[contenteditable="true"], [contenteditable="true"] *,
.selectable, .selectable * {
  -webkit-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* Stop images from being draggable/long-press-saveable like a web page. */
img {
  -webkit-user-drag: none;
  user-select: none;
}


/* Rounded "VAT" badge shown beside Tax labels (UK clients call it VAT) */
.vat-badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.2;
  color: var(--ink-500);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: .1rem .42rem;
  margin-left: .35rem;
  vertical-align: middle;
  -webkit-user-select: none;
  user-select: none;
}


/* ============================================================================
 * MOBILE SELECTION + BATCH BAR (native long-press & touch targets)
 * ========================================================================== */
/* Long-press visual feedback + selected card highlight */
.inv-card { transition: transform .12s var(--ease-out, ease), box-shadow .12s ease, background .12s ease; }
.inv-card.is-pressing { transform: scale(.975); }
.inv-card.is-selected { box-shadow: 0 0 0 2px var(--brand, #1565c0) inset; background: color-mix(in srgb, var(--brand, #1565c0) 6%, transparent); }
.selection-mode .inv-card { cursor: pointer; }

/* Batch-bar buttons keep a 44px target; icon + label by default. */
.batch-bar .btn {
  min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  white-space: nowrap;
}

/* On phones, collapse the batch-bar buttons to icons only so nothing crams. */
@media (max-width: 575.98px) {
  .batch-bar { gap: .6rem; padding: .6rem .7rem; }
  .batch-bar__count { font-size: .9rem; }
  .batch-bar__actions { gap: .45rem; }
  .batch-bar .btn .btn-label { display: none; }      /* swap text → icon only */
  .batch-bar .btn { padding-left: 0; padding-right: 0; width: 44px; flex: 0 0 44px; }
}


/* ============================================================================
 * PAYMENTS · SPOTLIGHT-STYLE INVOICE SEARCH
 * ========================================================================== */
.pay-spotlight { position: relative; }
.pay-spotlight__menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.18);
  max-height: 340px; overflow-y: auto;
  display: none; -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.pay-spotlight.is-open .pay-spotlight__menu { display: block; animation: spot-in .14s var(--ease-out, ease); }
@keyframes spot-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pay-spotlight__head { padding: 6px 10px 4px; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-400, var(--ink-500)); }
.pay-spotlight__opt {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem;
  border-radius: 9px; cursor: pointer;
}
.pay-spotlight__opt:hover { background: var(--brand, #1565c0); }
.pay-spotlight__opt:hover * { color: #fff !important; }
.pay-spotlight__icon {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--ink-500); font-size: .95rem;
}
.pay-spotlight__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pay-spotlight__num { font-weight: 600; color: var(--ink-900); }
.pay-spotlight__sub { font-size: .8rem; color: var(--ink-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-spotlight__tag { flex: 0 0 auto; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pay-spotlight__tag.is-due { color: var(--brand, #1565c0); }
.pay-spotlight__tag.is-paid { color: var(--ink-400, var(--ink-500)); }
.pay-spotlight__empty { padding: .7rem; color: var(--ink-500); font-size: .85rem; }


/* Mobile "Select all" bar above the invoice cards */
.cards-selectall {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .9rem; margin-bottom: .65rem;
  font-weight: 600; color: var(--ink-900);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; cursor: pointer;
}
.cards-selectall .form-check-input { margin: 0; width: 1.25em; height: 1.25em; cursor: pointer; }


/* ============================================================================
 * SCROLL AFFORDANCES — native iOS / macOS scroll cues
 *   1) thin, always-visible rounded scrollbars
 *   2) soft edge fades that hint at off-screen content
 *   3) overscroll containment so an overlay's bounce never scrolls the page
 * ========================================================================== */

/* 1 — Thin native scrollbars everywhere (light theme) */
* { scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .3) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .3);
  border-radius: 9999px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .45); }
*::-webkit-scrollbar-thumb:active { background: rgba(0, 0, 0, .55); }
*::-webkit-scrollbar-corner { background: transparent; }

[data-theme="dark"] * { scrollbar-color: rgba(255, 255, 255, .3) transparent; }
[data-theme="dark"] *::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .28); }
[data-theme="dark"] *::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .42); }
[data-theme="dark"] *::-webkit-scrollbar-thumb:active { background: rgba(255, 255, 255, .55); }

/* Small floating strips/menus stay clean (no bar) — they cue via snap + fade */
.seg, .pay-spotlight__menu { scrollbar-width: none; }
.seg::-webkit-scrollbar,
.pay-spotlight__menu::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* 2 — Soft top/bottom fades on the major vertical scroll regions */
.modal-dialog-scrollable .modal-body,
.pay-spotlight__menu {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}

/* 3 — Contain overscroll so the phone bounce never leaks to the page behind */
.modal-body,
.pay-spotlight__menu,
.dropdown-menu,
.table-responsive,
.seg { overscroll-behavior: contain; }


/* ============================================================================
 * LAYOUT STABILITY (CLS) — reserved space + native skeleton loaders
 * ========================================================================== */
#view-container { min-height: 78vh; }      /* stable content area so the page never grows from empty */

.skel {
  background: var(--surface-2);
  border-radius: 10px;
  animation: skel-pulse 1.5s ease-in-out infinite;
}
[data-theme="dark"] .skel { background: rgba(255, 255, 255, .07); }
@keyframes skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; opacity: .8; } }

.skel-line    { height: 14px; border-radius: 7px; }
.skel-row     { height: 88px; border-radius: var(--radius, 16px); margin-bottom: .8rem; }
.skel-stat    { height: 116px; border-radius: var(--radius, 16px); }
.skel-chart   { height: 280px; border-radius: var(--radius, 16px); }
.skel-toolbar { height: 46px; border-radius: 12px; margin-bottom: 1.1rem; }
.skel-grid    { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1.25rem; }
@media (min-width: 768px) { .skel-grid { grid-template-columns: repeat(4, 1fr); } }
.skel-wrap    { animation: skel-fade .3s ease both; }
@keyframes skel-fade { from { opacity: 0; } to { opacity: 1; } }


/* ============================================================================
 * HORIZONTAL-SCROLL CUE — native iOS scroll indicator
 *   A thin rounded pill at the bottom that shows the scroll position while
 *   scrolling and fades out when idle. JS positions/sizes the thumb.
 * ========================================================================== */
.scroll-x-host { position: relative; }
.ios-scroll-ind {
  position: absolute; left: 6px; right: 6px; bottom: 4px; height: 3px;
  pointer-events: none; opacity: 0; transition: opacity .4s ease; z-index: 5;
}
.ios-scroll-ind.is-active { opacity: 1; }
.ios-scroll-ind__thumb {
  position: absolute; top: 0; left: 0; height: 100%; min-width: 24px;
  background: rgba(0, 0, 0, .32); border-radius: 9999px;
  will-change: transform, width;
}
[data-theme="dark"] .ios-scroll-ind__thumb { background: rgba(255, 255, 255, .4); }
/* Hide the default bar on these tables — the iOS pill is the indicator */
.table-wrap .table-responsive,
.scroll-x-host .table-responsive { scrollbar-width: none; }
.table-wrap .table-responsive::-webkit-scrollbar,
.scroll-x-host .table-responsive::-webkit-scrollbar { width: 0; height: 0; display: none; }
