/* ============================================
   BridgeConn - Unified Design System
   ============================================

   LAYOUT STRUCTURE:
   =================
   The application uses a clean, consistent layout structure:

   <html>
     <body>                          (flex column container)
       <header class="app-topnav">   (fixed height, full width — primary sections)
       <div class="app-body">        (flex row, grows to fill)
         <aside class="app-sidebar"> (only rendered for sections with sub-pages
                                       today: Admin, Sync Manager — see
                                       views/partials/sidebar.ejs)
         <div class="main">          (flex column, grows to fill)
           <div class="content">     (main scrollable content area)
           <footer>                  (footer at bottom)
         </div>
       </div>
     </body>
   </html>

   SCROLLING STRATEGY:
   ===================
   - Only the browser window scrollbar is used for vertical scrolling
   - No nested scroll containers in the main layout
   - Content expands naturally, browser handles scrolling
   - Top nav and sidebar are fixed-height/width, content area is flexible

   RESPONSIVE BEHAVIOR:
   ====================
   - Desktop: sidebar (if present) + main content side by side (flex row)
   - Mobile: sidebar becomes a slide-in panel behind the hamburger button;
     pages with no sidebar for the current section never show the hamburger
   - All scrolling handled by browser window scrollbar
*/

/* ===== DESIGN TOKENS ===== */
:root {
  /* Color Palette — aligned with the app-shell tokens below (--nav-*), which
     already matched the approved redesign mockup; the rest of the app is now
     brought up to the same restrained, single-accent palette instead of the
     older navy-heavy one. */
  --primary: #24408F;
  --secondary: #334EAC;
  --accent: #7096D1;
  --light: #DDE4F6;
  --lighter: #EEF1FA;
  --background: #F6F7FB;
  --white: #ffffff;

  /* Surfaces beyond plain white, for subtly recessed panels (table headers,
     toolbars, code/data blocks) — from the mockup's --surface-sunken. */
  --surface-sunken: #FBFBFE;
  --border-strong: #D3D7E2;

  /* Soft-accent backgrounds for selected/active states (nav active links,
     info banners) — from the mockup's --accent-soft(-strong). Same values
     as --lighter/--light above, named to match the mockup for new code. */
  --accent-soft: #EEF1FA;
  --accent-soft-strong: #DDE4F6;

  /* Semantic Colors */
  --success: #157A45;
  --success-light: #E8F6EE;
  --error: #B3261E;
  --error-light: #FBEBEA;
  --warning: #96540A;
  --warning-light: #FDF3E4;
  --info: #334EAC;
  --info-light: #EEF1FA;

  /* Text Colors */
  --text-primary: #171B2E;
  /* IMPLEMENTATION_UI_004A: neutral, not brand indigo (design §28.3). Light
     values stay literal here (not aliased to --theme-*) so unconverted
     consumers never flip in the gated Dark preview. */
  --text-secondary: #3E4C58;
  --text-muted: #63697D;
  /* IMPLEMENTATION_UI_004A: #9599AB was 2.83:1 (fails AA); now 5.80:1. */
  --text-light: #5A6772;
  --text-faint: #5A6772;

  /* Data/numeric columns (amounts, dates, codes) get a monospaced face so
     digits line up — from the mockup's --font-data. */
  --font-data: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

  /* Border Colors */
  --border-color: #E4E7EE;
  --border-light: #EEF0F4;

  /* Background Colors */
  --bg-primary: #F6F7FB;
  --bg-secondary: #ffffff;
  --bg-hover: #F3F4F8;
  --bg-active: #EEF1FA;

  /* Content column max-width — BridgeConn's content area no longer stretches
     edge-to-edge on wide screens; only the reading/scanning column is capped,
     the top nav and sidebar (chrome, not content) still reach the edges. */
  --content-max: 78rem;

  /* App shell — top bar (light, minimal). Kept as its own token set since
     it was built first and already matches the palette above — the rest of
     the app's tokens were brought in line with these, not the other way
     around. */
  --nav-bg: var(--white);
  --nav-border: var(--border-color);
  --nav-text: #171B2E;
  --nav-text-muted: #63697D;
  --nav-accent: var(--secondary);
  --nav-accent-strong: #24408F;
  --nav-accent-soft: #EEF1FA;

  /* IMPLEMENTATION_UI_003C: header ("top bar") tokens, Light theme. A
     separate family on purpose: the --nav-* set above is also consumed by
     page content (.context-bar on Admin Client Config), so repointing it —
     let alone giving it Dark values — would recolour unconverted pages.
     Measured: text 16.38:1, muted 5.80:1, control borders 3.12:1, accent and
     focus ring 6.53:1, selected option (white on #12648A) 6.53:1, avatar
     10.26:1, closing-date badge 7.84:1. */
  --topbar-bg: #FFFFFF;
  --topbar-border: #DCE3E8;
  --topbar-text: #14212B;
  --topbar-text-muted: #5A6772;
  --topbar-control-border: #8494A0;
  --topbar-hover-bg: #EDF2F5;
  --topbar-accent: #12648A;
  --topbar-focus-ring: #12648A;
  --topbar-selected-bg: #12648A;
  --topbar-on-selected: #FFFFFF;
  --topbar-avatar-bg: #E1EFF5;
  --topbar-avatar-text: #0B3A52;
  --topbar-badge-bg: #EEF2F5;
  --topbar-badge-text: #3E4C58;

  /* KD-65 (UI-004A1): page canvas, page-title area and footer. Light values
     alias the legacy tokens they replace, so Light renders exactly as before;
     only the gated Dark block below gives them theme values. */
  --page-bg: var(--background);
  --page-title: var(--text-primary);
  --page-subtitle: var(--text-muted);
  --page-footer-text: var(--text-muted);
  --page-footer-border: var(--secondary);

  /* KD-68 (UI-005A): list surfaces — tables, toolbars, pagination, list
     states, spinners. Light values alias today's exact values (Light renders
     as before); only the gated Dark block below gives them theme values. */
  --list-surface: var(--white);
  --list-header-bg: var(--white);
  --list-row-alt: var(--bg-hover);
  --list-row-hover: var(--bg-active);
  --list-border: var(--border-color);
  --list-text: #333;
  --list-text-strong: var(--text-primary);
  --list-text-secondary: var(--text-secondary);
  --list-text-muted: var(--text-muted);
  --list-sorted: var(--secondary);
  --list-page-active-bg: var(--primary);
  --list-state-info: var(--info);
  --spinner-track: #f3f3f3;
  --spinner-head: var(--secondary);
  --skeleton-base: #f0f0f0;
  --skeleton-highlight: #e0e0e0;
  /* KD-69 (UI-005B): page-specific list surfaces (Sync Issues, Run History,
     Company Sync). Light aliases the legacy value each rule used before. */
  --list-info-bg: var(--info-light);
  --list-info-border: var(--light);
  --list-sunken: var(--surface-sunken);
  --list-border-strong: var(--border-strong);
  --list-border-light: var(--border-light);
  /* KD-93: recessed name panels inside dialogs (Customer/Vendor Matching
     confirm and Reconfirm). Light aliases the value they used before. */
  --modal-panel-bg: var(--lighter);

  /* KD-60 (UI-006A): Dashboard cards and KPIs. Light values alias today's
     exact values (Light/gate-off renders as before); only the gated Dark
     block below gives them theme values. Used only by .card/.cards/.card-icon,
     which only the Dashboard partials render. */
  --card-bg: var(--white);
  --card-title: var(--text-primary);
  /* Card body text (KPI values, last-sync lines). Light is Bootstrap's own .h4
     /body colour (#212529), so Light/gate-off is byte-identical; only Dark
     themes it. Literal, like --list-text #333, because no token holds this. */
  --card-text: #212529;
  --card-icon-bg: var(--lighter);
  --card-icon-text: var(--secondary);
  --card-icon-success-bg: var(--success-light);
  --card-icon-success-text: var(--success);
  --card-icon-error-bg: var(--error-light);
  --card-icon-error-text: var(--error);

  /* App shell — persistent left sidebar (IMPLEMENTATION_023). Dark navy,
     per the approved bridgeconn_gl_sync_approved.png reference — a
     deliberately separate token set from --nav-* above, since the top bar
     stays light while only the sidebar goes dark. */
  /* IMPLEMENTATION_UI_003B: approved KuyKuy Bridge sidebar, Light theme
     (dark in both themes; Dark values in the :root[data-theme="dark"]
     block below). Measured on the rendered sidebar: link/label text 6.55:1,
     hover text 8.36:1, active text 6.53:1, Light Cyan indicator and focus
     ring 6.17:1 vs the sidebar and 3.34:1 vs the active fill. Replaces the
     old indigo set (#10162B…), whose group label failed AA at 3.75:1 and
     whose #5B7FFF accent was a third, unrelated blue. */
  --shell-sidebar-bg: #0B3A52;
  --shell-sidebar-border: #114A66;
  --shell-sidebar-text: #E8F1F6;
  --shell-sidebar-text-muted: #A9C3D1;
  --shell-sidebar-group-label: #A9C3D1;
  --shell-sidebar-active-bg: #12648A;
  --shell-sidebar-active-text: #FFFFFF;
  --shell-sidebar-accent: #6BC6DC;
  --shell-sidebar-hover-bg: #114A66;
  --shell-sidebar-focus-ring: #6BC6DC;

  /* Spacing Scale (4px base unit) */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */
  --space-3xl: 4rem;     /* 64px */
  
  /* Typography Scale */
  --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 2rem;      /* 32px */
  --font-size-4xl: 2.5rem;    /* 40px */
  
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(23, 27, 46, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(23, 27, 46, 0.1), 0 2px 4px -1px rgba(23, 27, 46, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(23, 27, 46, 0.1), 0 4px 6px -2px rgba(23, 27, 46, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(23, 27, 46, 0.1), 0 10px 10px -5px rgba(23, 27, 46, 0.04);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  
  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* ===== THEME FOUNDATION — Light (IMPLEMENTATION_UI_002) =====
     Semantic tokens from docs/design/BRIDGECONN_PRODUCT_VISUAL_SYSTEM.md
     §28, approved at UI-001 closure as the initial palette (subject to
     visual review). Prefixed --theme-* and NOT yet consumed by any existing
     component: UI-002 is foundation only, so no page is recoloured. Later
     increments alias the legacy tokens above to these as they restyle each
     area. The Dark values live in the :root[data-theme="dark"] block below,
     and Dark is only ever activated by gated code (lib/themePreference.js),
     never by the OS alone — there is deliberately no prefers-color-scheme
     block. Brand colours (#12648A, #6BC6DC, #FFFFFF) are official; the rest
     are derived/proposed values measured for WCAG 2.2 AA. */
  --theme-color-scheme: light;
  --theme-brand-primary: #12648A;
  --theme-brand-secondary: #6BC6DC;
  --theme-bg: #F4F7F9;                 /* application background */
  --theme-surface: #FFFFFF;            /* cards, tables, forms */
  --theme-surface-elevated: #FFFFFF;   /* menus, dialogs (plus shadow) */
  --theme-surface-sunken: #EEF2F5;     /* table headers, toolbars */
  --theme-text: #14212B;               /* 16.38:1 on surface */
  --theme-text-secondary: #3E4C58;     /*  8.83:1 */
  --theme-text-muted: #5A6772;         /*  5.80:1 */
  --theme-border: #DCE3E8;             /* decorative only */
  --theme-border-strong: #8494A0;      /*  3.12:1, inputs/state borders */
  --theme-link: #12648A;               /*  6.53:1 */
  --theme-primary-bg: #12648A;         /* white text 6.53:1 */
  --theme-primary-hover-bg: #0E5474;   /* white text 8.27:1 */
  --theme-on-primary: #FFFFFF;
  --theme-secondary-bg: #FFFFFF;
  --theme-secondary-border: #8494A0;
  --theme-secondary-text: #14212B;
  --theme-secondary-hover-bg: #EDF2F5;
  --theme-disabled-bg: #EDF1F4;        /* label stays >= 4.5:1 */
  --theme-disabled-text: #5A6772;
  --theme-focus-ring: #12648A;         /* used with a 2px offset */
  --theme-success: #157A45;
  --theme-success-bg: #E8F6EE;
  --theme-warning: #96540A;
  --theme-warning-bg: #FDF3E4;
  --theme-error: #B3261E;
  --theme-error-bg: #FBEBEA;
  --theme-info: #12648A;
  --theme-info-bg: #E6F1F6;
  --theme-shadow-elevated: 0 10px 15px -3px rgba(20, 33, 43, 0.12), 0 4px 6px -2px rgba(20, 33, 43, 0.06);
  /* Approved at UI-001 closure: cards 12px, controls 8px. */
  --theme-radius-card: 12px;
  --theme-radius-control: 8px;

  /* ===== COMPONENT TOKENS (IMPLEMENTATION_UI_004A; design §28.4) =====
     Shared components (buttons, inputs, badges, alerts, modals, tabs, cards)
     read these. They alias --theme-*, so the gated Dark theme follows; only
     --input-bg and --selected-bg need their own Dark values (dark block). */
  --btn-primary-bg: var(--theme-primary-bg);
  --btn-primary-hover-bg: var(--theme-primary-hover-bg);
  --on-primary: var(--theme-on-primary);
  --btn-secondary-bg: var(--theme-secondary-bg);
  --btn-secondary-border: var(--theme-secondary-border);
  --btn-secondary-text: var(--theme-secondary-text);
  --btn-secondary-hover-bg: var(--theme-secondary-hover-bg);
  --btn-danger-bg: #B3261E;            /* white text 6.54:1, both themes */
  --btn-danger-hover-bg: #8E1E18;      /* white text 8.94:1 */
  --input-bg: #FFFFFF;
  --input-text: var(--theme-text);
  --input-border: var(--theme-border-strong);
  --input-placeholder: var(--theme-text-muted);
  --selected-bg: #E1EFF5;              /* text 13.93:1 */
  --selected-indicator: var(--theme-link);
  --focus-ring: var(--theme-focus-ring);
  --disabled-bg: var(--theme-disabled-bg);
  --disabled-text: var(--theme-disabled-text);
  --surface-elevated: var(--theme-surface-elevated);

  /* Bootstrap 5.3 variables -> KuyKuy palette, so Bootstrap utilities, links
     and nav tabs never show Bootstrap #0D6EFD. Fill values (white text >=
     5.38:1) stay the same in Dark; text utilities are mapped explicitly
     below because Bootstrap uses one variable for both fill and text. */
  --bs-primary: #12648A;
  --bs-primary-rgb: 18, 100, 138;
  --bs-success: #157A45;
  --bs-success-rgb: 21, 122, 69;
  --bs-warning: #96540A;
  --bs-warning-rgb: 150, 84, 10;
  --bs-danger: #B3261E;
  --bs-danger-rgb: 179, 38, 30;
  --bs-info: #12648A;
  --bs-info-rgb: 18, 100, 138;
  --bs-secondary: #5A6772;
  --bs-secondary-rgb: 90, 103, 114;
  --bs-link-color: #12648A;
  --bs-link-color-rgb: 18, 100, 138;
  --bs-link-hover-color: #0E5474;
  --bs-link-hover-color-rgb: 14, 84, 116;
}

/* ===== THEME FOUNDATION — Dark (IMPLEMENTATION_UI_002) =====
   Applied only when <html data-theme="dark">, which only the gated theme
   code sets (UI_THEME_PREVIEW_ENABLED; unset in real production). Same token
   names as the Light block; brand colours unchanged — on dark surfaces the
   link/focus/info roles move to Light Cyan because Deep Blue fails AA there. */
:root[data-theme="dark"] {
  --theme-color-scheme: dark;
  --theme-bg: #0B1620;
  --theme-surface: #13212C;
  --theme-surface-elevated: #1A2B38;
  --theme-surface-sunken: #0E1A24;
  --theme-text: #E6EDF2;               /* 13.86:1 on surface */
  --theme-text-secondary: #B5C3CE;     /*  9.10:1 */
  --theme-text-muted: #8FA1AE;         /*  6.15:1 */
  --theme-border: #24384A;
  --theme-border-strong: #5D7487;      /*  3.37:1 */
  --theme-link: #6BC6DC;               /*  8.38:1 */
  --theme-primary-bg: #12648A;         /* white text 6.53:1 */
  --theme-primary-hover-bg: #1A73A0;   /* white text 5.24:1 */
  --theme-on-primary: #FFFFFF;
  --theme-secondary-bg: #13212C;
  --theme-secondary-border: #5D7487;
  --theme-secondary-text: #E6EDF2;
  --theme-secondary-hover-bg: #1B2D3B;
  --theme-disabled-bg: #18252F;
  --theme-disabled-text: #8FA1AE;      /* 5.86:1 on disabled bg */
  --theme-focus-ring: #6BC6DC;         /* 8.38:1 on surface */
  --theme-success: #5CCB95;
  --theme-success-bg: #112E21;
  --theme-warning: #E8B15C;
  --theme-warning-bg: #33260F;
  --theme-error: #FF8F85;
  --theme-error-bg: #3B1816;
  --theme-info: #6BC6DC;
  --theme-info-bg: #0F2E3B;
  --theme-shadow-elevated: 0 1px 2px rgba(0, 0, 0, 0.4);

  /* IMPLEMENTATION_UI_003B: Dark sidebar. Reachable only through the UI-002
     gate (data-theme="dark" is never rendered while it is off). Link/label
     7.56:1, hover text 13.53:1, active text 6.53:1, Light Cyan indicator
     and focus ring 9.71:1 vs the sidebar. */
  --shell-sidebar-bg: #08111A;
  --shell-sidebar-border: #1B2A36;
  --shell-sidebar-text: #E6EDF2;
  --shell-sidebar-text-muted: #93A6B4;
  --shell-sidebar-group-label: #93A6B4;
  --shell-sidebar-active-bg: #12648A;
  --shell-sidebar-active-text: #FFFFFF;
  --shell-sidebar-accent: #6BC6DC;
  --shell-sidebar-hover-bg: #132331;
  --shell-sidebar-focus-ring: #6BC6DC;

  /* IMPLEMENTATION_UI_003C: Dark header (gate-only, like the sidebar).
     Text 14.62:1, muted 6.49:1, control borders 3.55:1, accent and focus
     ring 8.84:1, selected 6.53:1, avatar 9.57:1, badge 8.17:1. */
  --topbar-bg: #0F1C26;
  --topbar-border: #1F3040;
  --topbar-text: #E6EDF2;
  --topbar-text-muted: #8FA1AE;
  --topbar-control-border: #5D7487;
  --topbar-hover-bg: #1B2D3B;
  --topbar-accent: #6BC6DC;
  --topbar-focus-ring: #6BC6DC;
  --topbar-selected-bg: #12648A;
  --topbar-on-selected: #FFFFFF;
  --topbar-avatar-bg: #173E55;
  --topbar-avatar-text: #E6EDF2;
  --topbar-badge-bg: #182A38;
  --topbar-badge-text: #B5C3CE;
  /* KD-65 (UI-004A1): Dark canvas, title area and footer. Title 15.45:1,
     subtitle/footer text 6.85:1 on --theme-bg; footer rule 3.75:1. */
  --page-bg: var(--theme-bg);
  --page-title: var(--theme-text);
  --page-subtitle: var(--theme-text-muted);
  --page-footer-text: var(--theme-text-muted);
  --page-footer-border: var(--theme-border-strong);
  /* KD-68 (UI-005A): Dark list surfaces. Text 13.86:1 / muted 6.15:1 on the
     surface, 6.60:1 on alternate rows and headers; hover row text 9.57:1. */
  --list-surface: var(--theme-surface);
  --list-header-bg: var(--theme-surface-sunken);
  --list-row-alt: var(--theme-surface-sunken);
  --list-row-hover: var(--selected-bg);
  --list-border: var(--theme-border);
  --list-text: var(--theme-text);
  --list-text-strong: var(--theme-text);
  --list-text-secondary: var(--theme-text-muted);
  --list-text-muted: var(--theme-text-muted);
  --list-sorted: var(--theme-link);
  --list-page-active-bg: var(--btn-primary-bg);
  --list-state-info: var(--theme-info);
  --spinner-track: var(--theme-border);
  --spinner-head: var(--theme-link);
  --skeleton-base: var(--theme-surface-sunken);
  --skeleton-highlight: var(--theme-border);
  /* KD-69 (UI-005B) */
  --list-info-bg: var(--theme-info-bg);
  --list-info-border: var(--theme-border);
  --list-sunken: var(--theme-surface-sunken);
  --list-border-strong: var(--theme-border-strong);
  --list-border-light: var(--theme-border);
  /* KD-93: text 14.90:1, muted label 6.61:1 on this panel. */
  --modal-panel-bg: var(--theme-surface-sunken);
  /* KD-60 (UI-006A): Dark dashboard cards. The card surface finally themes, so
     the already-themed KPI values (.text-success --theme-success / .text-danger
     --theme-error) sit on --theme-surface instead of white (was 2.01 / 2.21 in
     Dark). Ratios re-measured on the rendered page in the evidence. */
  --card-bg: var(--theme-surface);
  --card-title: var(--theme-text);
  --card-text: var(--theme-text); /* KPI values + last-sync text, 13.86:1 on the card */
  --card-icon-bg: var(--theme-surface-sunken);
  --card-icon-text: var(--theme-link);
  --card-icon-success-bg: var(--theme-success-bg);
  --card-icon-success-text: var(--theme-success);
  --card-icon-error-bg: var(--theme-error-bg);
  --card-icon-error-text: var(--theme-error);
  --bs-secondary-color: var(--theme-text-muted);   /* Bootstrap .text-muted / .form-text */
  /* IMPLEMENTATION_UI_004A: Dark component values (design §28.4). */
  --input-bg: #0E1A23;                 /* text 14.92:1, placeholder 6.62:1 */
  --selected-bg: #173E55;              /* text 9.57:1 */
  --bs-link-color: #6BC6DC;
  --bs-link-color-rgb: 107, 198, 220;
  --bs-link-hover-color: #6BC6DC;
  --bs-link-hover-color-rgb: 107, 198, 220;
  /* KD-62 (UI-004D): theme Bootstrap contextual alerts in gated Dark. The app
     keeps <html data-bs-theme="light"> globally (theme-init.js), so Bootstrap's
     own dark alert values never apply — .alert-{variant} derives from these
     emphasis/subtle vars; map them to the themed success/error/warning/info
     pairs so alerts (incl. the Mapping/Sync toasts) theme in Dark. */
  --bs-success-text-emphasis: var(--theme-success);
  --bs-success-bg-subtle: var(--theme-success-bg);
  --bs-success-border-subtle: var(--theme-success);
  --bs-danger-text-emphasis: var(--theme-error);
  --bs-danger-bg-subtle: var(--theme-error-bg);
  --bs-danger-border-subtle: var(--theme-error);
  --bs-warning-text-emphasis: var(--theme-warning);
  --bs-warning-bg-subtle: var(--theme-warning-bg);
  --bs-warning-border-subtle: var(--theme-warning);
  --bs-info-text-emphasis: var(--theme-info);
  --bs-info-bg-subtle: var(--theme-info-bg);
  --bs-info-border-subtle: var(--theme-info);
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

/* ===== ROOT LAYOUT ===== */
html {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-y: auto; /* Browser scrollbar for entire page */
  overflow-x: hidden; /* safety net: no element (topnav included) can force the
                          whole page to scroll sideways — .app-nav-links has its
                          own internal horizontal scroll for that */
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  /* IMPLEMENTATION_UI_004A: theme surface, so shared components sit on the
     right surface in both themes (Light value ~= the old --background). */
  background-color: var(--theme-bg);
  color: var(--theme-text);
  display: flex;
  flex-direction: column; /* .app-shell (sidebar + main column) fills this */
  min-height: 100vh; /* Allow body to expand beyond viewport */
  overflow-y: visible; /* Use browser scrollbar, not internal scroll */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* IMPLEMENTATION_042A: a plain <code> element had no rule of its own
   anywhere in this stylesheet, so the Bootstrap CDN default (`code {
   color }`, Bootstrap's own hot-pink default) was silently showing through wherever
   the app renders one without its own more-specific class — live-
   confirmed on Company Sync's QBO Customer ID column via computed style
   (`rgb(214, 51, 132)`), and present in several other JS-built tables
   (Chart of Accounts mismatch details, GL Sync Errors' own error-type
   cell) that never intended pink text. A token-driven baseline, matching
   this app's own existing --font-data monospace token — any more
   specific class (.cs-id-code, .readonly-value, etc.) can still override
   color/font-family as needed. */
code {
  color: var(--text-primary);
  font-family: var(--font-data);
}

/* ===== APP SHELL: persistent left sidebar + slim top bar (IMPLEMENTATION_023) =====
   Replaces the old horizontal-top-nav + conditional-contextual-sidebar
   model. .app-shell is the outer full-height row: a persistent dark
   sidebar (.app-shell-sidebar) beside a column (.app-shell-main) holding
   the slim top bar, page content, and footer. */
.app-shell {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
}

.app-shell-sidebar {
  width: 240px;
  min-width: 240px;
  flex: 0 0 auto;
  background: var(--shell-sidebar-bg);
  border-right: 1px solid var(--shell-sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Brand row (IMPLEMENTATION_UI_003A). A container, not a link: the
   dashboard link and the mobile close button sit side by side. The row grows
   to fit the 56px logo plus its plate (approved), so it is taller than the
   56px top bar. */
.app-shell-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  flex: none;
}

.app-shell-brand-link {
  display: inline-flex;
  flex: none;
  border-radius: var(--radius-lg);
  text-decoration: none;
}

/* White plate: the official logo is light-background artwork whose Deep Blue
   parts are 1.85:1 / 2.91:1 on the dark sidebars; on white they are 6.53:1.
   Approved interim presentation until a reversed logo exists. */
.app-shell-brand-plate {
  display: inline-flex;
  align-items: center;
  background: var(--white);
  padding: 6px 10px;
  border-radius: var(--radius-lg); /* 8px */
}

/* Height drives size; width follows the image's own aspect ratio (from its
   width/height attributes), so the mark is never stretched or cropped. */
.app-shell-brand-logo {
  display: block;
  height: 56px;
  width: auto;
  max-width: 100%;
}

.app-shell-nav {
  flex: 1;
  padding: var(--space-sm) var(--space-sm) var(--space-lg);
}

.app-shell-nav-group {
  margin-bottom: var(--space-md);
}

.app-shell-nav-group-label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--shell-sidebar-group-label);
  padding: var(--space-sm) var(--space-sm) 4px;
}

.app-shell-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--shell-sidebar-text-muted);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  margin-bottom: 2px;
}

.app-shell-nav a i {
  width: 18px;
  text-align: center;
  flex: none;
}

.app-shell-nav a:hover {
  background: var(--shell-sidebar-hover-bg);
  color: var(--shell-sidebar-text);
}

/* Active item (IMPLEMENTATION_UI_003B): fill + a 3px Light Cyan bar +
   semibold text, so "current page" never relies on colour alone (the link
   also carries aria-current="page"). Hover above is fill + brighter text
   only, so the two states stay distinguishable. */
.app-shell-nav a.active {
  background: var(--shell-sidebar-active-bg);
  color: var(--shell-sidebar-active-text);
  font-weight: var(--font-weight-semibold);
  box-shadow: inset 3px 0 0 var(--shell-sidebar-accent);
}

/* Keyboard focus inside the sidebar: Light Cyan ring with an offset, so it
   sits on the sidebar background (6.17:1 Light, 9.71:1 Dark) — including
   around the active item, where a ring touching the fill would be weaker. */
.app-shell-sidebar a:focus-visible,
.app-shell-sidebar button:focus-visible {
  outline: 2px solid var(--shell-sidebar-focus-ring);
  outline-offset: 2px;
}

/* Sidebar-close (mobile only) and backdrop */
.app-shell-sidebar-close {
  display: none; /* shown on mobile below */
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--shell-sidebar-text-muted);
  cursor: pointer;
  margin-left: auto;
}

.app-shell-backdrop {
  display: none;
}

/* Main column: slim top bar + content + footer */
.app-shell-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
  background-color: var(--page-bg); /* KD-65 */
}

/* Header ("top bar") — IMPLEMENTATION_UI_003C. Colours from the
   --topbar-* tokens; structure and every control's behaviour unchanged.
   Desktop targets are at least 32px (WCAG 2.5.8 minimum is 24px); at
   768px and below they grow to 44px for touch. */
.app-topnav {
  background-color: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  color: var(--topbar-text);
  height: 56px;
  min-height: 56px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
}

.app-hamburger {
  display: none; /* shown on mobile below */
  border: 1px solid var(--topbar-control-border);
  background: transparent;
  color: var(--topbar-text);
  border-radius: var(--radius-lg);
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

.app-hamburger:hover {
  background: var(--topbar-hover-bg);
}

.app-topnav-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--topbar-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: none;
  margin-left: auto;
}

.app-company-context {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--topbar-text-muted);
  white-space: nowrap;
}

.app-company-context i {
  color: var(--topbar-accent);
}

/* Language (IMPLEMENTATION_024) + theme (UI-003C) preferences, side by
   side. The language form, its POST and its CSRF field are unchanged. */
.app-topbar-prefs {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.app-topbar-lang-slot {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--topbar-control-border);
  border-radius: var(--radius-lg);
  margin: 0;
}

.app-lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 32px;
  padding: 0 var(--space-sm);
  border: none;
  background: transparent;
  color: var(--topbar-text-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: calc(var(--radius-lg) - 2px);
  cursor: pointer;
  line-height: 1;
}

.app-lang-btn:hover {
  background: var(--topbar-hover-bg);
  color: var(--topbar-text);
}

.app-lang-btn.active {
  background: var(--topbar-selected-bg);
  color: var(--topbar-on-selected);
}

.app-user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 2px 2px 2px 4px;
  border: 1px solid var(--topbar-border);
  border-radius: var(--radius-full);
}

.app-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--topbar-avatar-bg);
  color: var(--topbar-avatar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  flex: none;
}

.app-user-name {
  font-size: var(--font-size-sm);
  color: var(--topbar-text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* IMPLEMENTATION_075A: logout is a <button> inside a small POST form (a
   state change must not be a GET link); the form adds no line box.
   UI-003C: the button was a 16x16 icon; it is now a 36px circular target
   (44px on touch) with the same icon, label and form. */
.app-logout-form {
  display: flex;
  align-items: center;
}

.app-logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--topbar-text-muted);
  background: none;
  border: 0;
  border-radius: 50%;
  padding: 0;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.app-logout-link:hover {
  background: var(--topbar-hover-bg);
  color: var(--topbar-text);
}

.qbo-closing-date-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--topbar-badge-text);
  padding: var(--space-xs) var(--space-sm);
  background-color: var(--topbar-badge-bg);
  border-radius: var(--radius-lg);
  white-space: nowrap;
}

.qbo-closing-date-badge i {
  color: var(--topbar-accent);
}

/* Keyboard focus in the header: token ring with an offset (6.53:1 Light,
   8.84:1 Dark against the header). */
.app-topnav a:focus-visible,
.app-topnav button:focus-visible,
.app-topnav .theme-control-option input:focus-visible + span {
  outline: 2px solid var(--topbar-focus-ring);
  outline-offset: 2px;
}

/* Compact theme selector in the header (IMPLEMENTATION_UI_003C): the
   UI-002 control (same form, POST /theme, native radios) in a segmented
   pill matching the language selector. Icons always; text labels visible
   from 992px (below that they are visually hidden but remain each radio's
   accessible name, and each option has a title tooltip). */
.theme-control--compact {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin: 0;
}

.theme-control--compact .theme-control-group {
  display: flex;
}

.theme-control--compact .theme-control-options {
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--topbar-control-border);
  border-radius: var(--theme-radius-control);
  background: transparent;
}

.theme-control--compact .theme-control-option > span {
  min-height: 32px;
  min-width: 36px;
  justify-content: center;
  gap: 6px;
  padding: 0 var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--topbar-text-muted);
}

.theme-control--compact .theme-control-option:hover > span {
  background: var(--topbar-hover-bg);
  color: var(--topbar-text);
}

.theme-control--compact .theme-control-option input:checked + span {
  background: var(--topbar-selected-bg);
  color: var(--topbar-on-selected);
}

/* The text label sits inside the option's span; undo the sizing/padding the
   UI-002 descendant rule (.theme-control-option span) would give it. */
.theme-control--compact .theme-control-option .theme-control-label-text {
  display: inline;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}

/* The selected fill (6.53:1 against the header) marks the choice; the
   check mark used by the full-size control is dropped here for width. */
.theme-control--compact .theme-control-option input:checked + span::before {
  content: none;
}

.theme-control--compact .theme-control-submit {
  margin: 0;
  min-height: 32px;
  border-color: var(--topbar-control-border);
  background: transparent;
  color: var(--topbar-text);
}

@media (max-width: 991px) {
  .theme-control--compact .theme-control-label-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* Content: Main scrollable content area. Capped and centered so it doesn't
   stretch edge-to-edge on wide screens — the top nav and sidebar are chrome
   and still reach the edges, only the column you actually read/scan is
   capped. Tables wider than the column keep their own overflow-x:auto. */
.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-lg);
  flex: 1 1 auto; /* Grow to fill available space in main */
  overflow: visible; /* No internal scroll, content expands naturally */
  min-height: 0; /* Allow flex shrinking if needed */
}

/* ===== CARDS ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-md);
}

.card {
  background-color: var(--card-bg); /* KD-60 */
  color: var(--card-text); /* KD-60: card body text (values, last-sync) themes in Dark */
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card h4 {
  margin: var(--space-sm) 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--card-title); /* KD-60 */
}

/* Optional small icon accent inside a .card's <h4> label (IMPLEMENTATION_027A,
   Dashboard only) — additive and opt-in, doesn't touch the .card/.cards rules
   above so Connection Health and any other .card usage is unaffected (see
   CLAUDE.md: ".card/.cards were deliberately left alone"). */
.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-md);
  background: var(--card-icon-bg); /* KD-60 */
  color: var(--card-icon-text); /* KD-60 */
  font-size: 0.7rem;
  margin-right: var(--space-xs);
  vertical-align: middle;
}

/* KD-60 (UI-006A): GL Successful / Failed accent icons. Replaces the inline
   success/error styles that were in _gl-metrics.ejs so they theme in Dark. */
.card-icon--success {
  background: var(--card-icon-success-bg);
  color: var(--card-icon-success-text);
}

.card-icon--error {
  background: var(--card-icon-error-bg);
  color: var(--card-icon-error-text);
}

/* ===== HEADERS ===== */
.header {
  margin-bottom: var(--space-xl);
}

.header h1 {
  color: var(--page-title); /* KD-65 */
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-sm);
  line-height: var(--line-height-tight);
}

.header p {
  color: var(--page-subtitle); /* KD-65 */
  font-size: var(--font-size-base);
  margin: 0;
}

/* ===== TABLES ===== */
.table-container {
  background: var(--list-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: var(--space-xl);
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--list-surface);
  --bs-table-bg: var(--list-surface); /* Bootstrap 5.3 paints every cell with this */
  margin: 0;
}

.table thead {
  background: var(--list-header-bg);
  color: var(--list-text-strong);
  border-bottom: 1px solid var(--list-border);
}

.table th {
  padding-top: 0.375rem; /* 6px */
  padding-bottom: 0.375rem; /* 6px */
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  color: var(--list-text-strong);
  border-bottom: 1px solid var(--list-border);
  white-space: nowrap;
}

.table td {
  padding-top: 0.375rem; /* 6px */
  padding-bottom: 0.375rem; /* 6px */
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  border-bottom: 1px solid var(--list-border);
  vertical-align: middle;
  color: var(--list-text);
  font-size: var(--font-size-sm);
}

.table tbody tr {
  transition: background-color var(--transition-base);
  background: var(--list-surface);
}

.table tbody tr:nth-child(even) {
  background: var(--list-row-alt);
}

.table tbody tr:hover {
  background-color: var(--list-row-hover);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ===== TABLE CONTROLS ===== */
.table-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: 0;
  padding: var(--space-lg);
  background: var(--list-surface);
  border-bottom: 1px solid var(--list-border);
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  max-width: 300px;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--input-border); /* KD-68: UI-004 input tokens; boundary was 1.2:1 */
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  transition: all var(--transition-base);
  font-family: inherit;
  background-color: var(--input-bg);
  color: var(--input-text);
}

.search-input::placeholder {
  color: var(--input-placeholder);
  opacity: 1;
}

.search-input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus-ring); /* IMPLEMENTATION_UI_004A */
  outline-offset: 2px;
}

.sort-button,
.refresh-button {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  white-space: nowrap;
  font-family: inherit;
}

.sort-button:hover,
/* KD-68: primary button tokens (was white on --accent #7096D1, 3.0:1) */
.refresh-button {
  border: 1px solid var(--btn-primary-bg);
  background: var(--btn-primary-bg);
  color: var(--on-primary);
}

.refresh-button:hover {
  background: var(--btn-primary-hover-bg);
  border-color: var(--btn-primary-hover-bg);
}

/* ===== PAGINATION ===== */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--list-surface);
  border-top: 1px solid var(--list-border);
  margin-top: 0;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.pagination-info {
  font-size: var(--font-size-sm);
  color: var(--list-text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.pagination-button {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--list-border);
  background: var(--list-surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--list-text-secondary);
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  text-decoration: none;
  font-family: inherit;
}

.pagination-button:hover:not(:disabled) {
  background: var(--list-row-alt);
  border-color: var(--accent);
  text-decoration: none;
  color: var(--list-text-secondary);
}

.pagination-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-button.active {
  background: var(--list-page-active-bg);
  color: var(--white);
  border-color: var(--list-page-active-bg);
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-right: var(--space-md);
}

.page-size-selector label {
  font-size: var(--font-size-sm);
  color: var(--list-text-secondary);
}

.page-size-select {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--input-border); /* KD-68: UI-004 input boundary (was 1.2:1) */
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  background: var(--input-bg);
  color: var(--list-text-secondary);
  font-family: inherit;
  cursor: pointer;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  margin: 0 var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--list-text-muted);
  min-width: 2.5rem;
  height: 2.5rem;
}

/* ===== SHARED FLAT-CARD SYSTEM ===== */
/* A flat, bordered surface (no box-shadow, radius-lg) used across Sync
   Manager, Mapping Manager, and Client Config wherever a page needs a
   single panel or a tabbed panel — instead of `.table-container`/
   `.form-container` below, whose shadow-md + radius-xl + big padded
   `.form-header` read as a visually heavier, older style once compared
   side by side with the approved redesign. Originally built for Sync
   Manager (as `.sync-*`-prefixed classes) then promoted here once Mapping
   Manager and Client Config needed the identical treatment — don't
   reintroduce page-specific duplicates of these classes. */
.flat-card {
  background: var(--theme-surface);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-card);
  overflow: hidden;
  /* IMPLEMENTATION_042A: .flat-card never had its own bottom margin —
     harmless for the many pages where something else (a .stat-row's own
     margin-bottom, a page-header, a distinct following section) already
     separated two flat-cards, but a real, live-measured defect (0px
     gap, cards visually touching) wherever a page stacks two or more
     bare .flat-card elements directly, e.g. My Company's 3 stacked
     sections and Connection Health's new chart/details cards. Matches
     .stat-row's own existing margin-bottom value for consistency. */
  margin-bottom: var(--space-lg);
}

.flat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--theme-border);
}

.flat-card-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: var(--font-weight-bold);
}

.flat-card-head p {
  margin: 2px 0 0;
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
}

.flat-card-body {
  padding: var(--space-lg);
}

/* Fuses a Bootstrap `.nav-tabs` bar and its `.tab-content` into one flat,
   bordered card, instead of a tab strip floating above a separately
   shadowed panel further down the page. */
.tab-card {
  background: var(--theme-surface);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-card);
  overflow: hidden;
}

.tab-card > .nav-tabs {
  display: flex;
  flex-wrap: wrap;
  background: var(--theme-surface-sunken);
  border-bottom: 1px solid var(--theme-border);
  margin: 0;
  padding: 0 var(--space-xs);
}

.tab-card > .nav-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--theme-text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  padding: .8rem 1rem;
  margin-bottom: -1px;
  background: transparent;
}

.tab-card > .nav-tabs .nav-link.active {
  color: var(--theme-text);
  border-bottom-color: var(--selected-indicator);
  background: var(--theme-surface);
}

.tab-card > .nav-tabs .nav-link:not(.active):hover {
  color: var(--theme-text);
}

/* IMPLEMENTATION_042A: a real, evidence-cited spacing defect — neither the
   generic `.tab-content`/`.tab-pane` rules elsewhere in this file nor
   anything `.tab-card`-specific ever gave the sub-tab panel body any
   padding at all, so content (helper copy, toolbar, table) sat flush
   against the tab bar's own bottom border with zero breathing room —
   confirmed on GL Sync's "Source System Journal Entries" sub-tab, whose
   helper `<p>` even had an explicit `margin: 0 ...` on its own top edge.
   Applies to every `.tab-card` user (GL/Invoice/Credit Memo Sync sub-tabs,
   Account Matching's Exact/Similar/No Matches results) for one consistent
   vertical rhythm, per this app's own "one shared surface" design
   principle — not a Journal-Entry-only override. */
.tab-card > .tab-content > .tab-pane {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}

/* `.table-container` is kept (not removed) on any panel that needs it for a
   JS structural lookup — e.g. updateSyncErrorsPaginationControls() in
   sync-manager.js and updatePaginationControls() in mapping-manager.js both
   do `element.closest('.table-container')` to find where to append
   pagination controls, rather than targeting a fixed id. Flattened here so
   it still reads as part of the fused card instead of a separate shadowed
   panel — before removing `.table-container` from an element while
   restyling, grep the relevant public/js/*.js file for
   `closest('.table-container')` first. */
/* UI-WALKTHROUGH-001: Sync Manager section tabs. The strip sits above the page
   title as its own bar; each list/errors pane is the card surface itself. */
.tab-card.sync-section-tabs {
  margin-bottom: var(--space-lg);
}

.tab-card.sync-section-tabs > .nav-tabs {
  border-bottom: 0;
}

.tab-card.tab-pane {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}

/* The wrapper of the section panes is not a panel itself: undo the global
   .tab-content surface so the page looks as it did before the tabs moved. */
.tab-content.sync-section-panes {
  background: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.tab-card .table-container,
.flat-card .table-container {
  box-shadow: none;
  border-radius: 0;
  margin: 0;
}

.list-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--list-border);
  flex-wrap: wrap;
}

.list-toolbar .search-input {
  max-width: 320px;
  padding: .42rem .7rem;
  font-size: var(--font-size-sm);
}

.list-toolbar .sort-button,
.list-toolbar .refresh-button {
  padding: .42rem .75rem;
  font-size: var(--font-size-sm);
}

.list-caption {
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted); /* KD-68: Light hex equals the old --text-light */
  margin-right: auto;
}

/* ===== COMPACT FORM ===== */
/* A smaller, tighter form-field pattern than the global `.form-grid`/
   `.form-group`/`.form-input` (16px/24px padding, 2px borders, sized for
   prominent standalone forms like Client Config's General tab). Used where
   a form needs to sit inside a flat-card body without dominating it —
   e.g. Admin's Create User form. */
.form-grid-sm {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.form-row-sm label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--theme-text-muted);
  margin-bottom: .3rem;
}

.form-row-sm input,
.form-row-sm select {
  width: 100%;
  padding: .5rem .7rem;
  border: 1px solid var(--input-border);
  border-radius: var(--theme-radius-control);
  background: var(--input-bg);
  color: var(--input-text);
  font-size: var(--font-size-sm);
  font-family: inherit;
  transition: border-color var(--transition-base);
}

.form-row-sm input:focus,
.form-row-sm select:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: none;
}

/* ===== SHARED STAT ROW ===== */
/* Three-number summary row — Sync Manager's Success Rate (30d)/Avg
   Duration/Last Run (see views/partials/sync-manager/_stat-row.ejs), and
   Admin Dashboard's Total/Successful/Failed Syncs. Originally built
   Sync-Manager-only as `.sync-stat-row`/`.sync-stat*`, promoted here once
   Admin Dashboard needed the same pattern instead of its old
   `style="color: green"`/`style="color: red"` hardcoded-color `.card`s —
   don't reintroduce page-scoped duplicates. */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat {
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-card);
  padding: var(--space-md) var(--space-lg);
}

.stat-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--theme-text-muted);
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-family: var(--font-data);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.01em;
  color: var(--theme-text);
}

.stat-value.good { color: var(--theme-success); }

.stat-value.bad { color: var(--theme-error); }

.stat-sub {
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
  margin-top: 2px;
}

@media (max-width: 900px) {
  .stat-row {
    grid-template-columns: 1fr;
  }
}

/* Optional icon-chip variant (IMPLEMENTATION_027A) — opt-in via
   `.stat--with-icon` plus a `.stat-icon`/`.stat-body` pair inside, so every
   existing `.stat` usage that has neither (Admin Dashboard's stat-row,
   etc.) is completely unaffected. Matches the approved GL Sync reference's
   icon-forward stat treatment (docs/ux/referemce/bridgeconn_gl_sync_approved.png). */
.stat.stat--with-icon {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.stat-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-base);
}

.stat-icon--info    { background: var(--theme-info-bg); color: var(--theme-info); }

.stat-icon--success { background: var(--theme-success-bg); color: var(--theme-success); }

.stat-icon--warning { background: var(--theme-warning-bg); color: var(--theme-warning); }

.stat-icon--error   { background: var(--theme-error-bg); color: var(--theme-error); }

.stat-body {
  flex: 1 1 auto;
  min-width: 0;
}

/* ===== REPORTS (charts) ===== */
/* Replaces the old Bootstrap admin-template layout (.row/.col-xl-4/.card.shadow)
   for the two charts on Operational Health. `.chart-box` gives Chart.js's
   canvas an explicit height — Chart.js's `responsive:true` needs a sized
   container to compute a non-zero canvas size; without one the chart
   silently renders collapsed. (A `min-height` rule for this exact purpose
   existed only in login-style.css, never loaded on the Reports page — see
   public/js/health-charts.js's ensureCtx(), which returns null and skips
   rendering entirely when the canvas has zero width/height.) */
.chart-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  align-items: stretch;
}

@media (max-width: 900px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

.chart-box {
  height: 260px;
  position: relative;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===== FORMS ===== */
.form-container {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.form-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--white);
}

.form-header h2 {
  margin: 0 0 var(--space-md) 0;
  color: var(--text-primary);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

.form-content {
  padding: var(--space-xl);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: var(--font-weight-medium);
  color: var(--theme-text);
  font-size: var(--font-size-sm);
}

.form-group label.required::after {
  content: '*';
  color: var(--theme-error);
  margin-left: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  /* IMPLEMENTATION_UI_004A: 1px --input-border (3.12:1 Light / 3.37:1 Dark);
     the old 2px --lighter border was ~1.1:1, i.e. invisible. */
  border: 1px solid var(--input-border);
  border-radius: var(--theme-radius-control);
  font-size: var(--font-size-base);
  transition: all var(--transition-base);
  background: var(--input-bg);
  color: var(--input-text);
  font-family: inherit;
}

/* Bootstrap's .form-control/.form-select (used directly in views) get the
   same field tokens; Bootstrap's own focus glow is #0D6EFD-based. */
.form-control,
.form-select {
  background-color: var(--input-bg);
  color: var(--input-text);
  border-color: var(--input-border);
}

.form-input::placeholder,
.form-textarea::placeholder,
.form-control::placeholder,
.form-row-sm input::placeholder {
  color: var(--input-placeholder);
  opacity: 1;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus,
.form-check-input:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-color: var(--input-border);
  box-shadow: none;
}

.form-check-input:checked {
  background-color: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--theme-text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-help {
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
  margin-top: var(--space-xs);
}

/* ===== BUTTONS ===== */
.button,
.btn {
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: inherit;
  text-decoration: none;
  line-height: var(--line-height-normal);
  min-height: 36px; /* IMPLEMENTATION_UI_004A: design §30.4 (44px at <=640px below) */
}

/* IMPLEMENTATION_UI_004A: one hierarchy (design §14/§28.4). The --bs-btn-*
   variables keep Bootstrap's own :active/:focus states on the same tokens,
   so a pressed .btn-primary never flashes Bootstrap #0A58CA. */
.button-primary,
.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--on-primary);
  --bs-btn-bg: var(--btn-primary-bg);
  --bs-btn-border-color: var(--btn-primary-bg);
  --bs-btn-color: var(--on-primary);
  --bs-btn-hover-bg: var(--btn-primary-hover-bg);
  --bs-btn-hover-border-color: var(--btn-primary-hover-bg);
  --bs-btn-hover-color: var(--on-primary);
  --bs-btn-active-bg: var(--btn-primary-hover-bg);
  --bs-btn-active-border-color: var(--btn-primary-hover-bg);
  --bs-btn-active-color: var(--on-primary);
}

.button-primary:hover,
.btn-primary:hover {
  background: var(--btn-primary-hover-bg);
  color: var(--on-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button-secondary,
.btn-secondary,
.btn-outline-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--btn-secondary-border);
  --bs-btn-active-bg: var(--btn-secondary-hover-bg);
  --bs-btn-active-color: var(--btn-secondary-text);
  --bs-btn-active-border-color: var(--btn-secondary-border);
}

.button-secondary:hover,
.btn-secondary:hover,
.btn-outline-secondary:hover {
  background: var(--btn-secondary-hover-bg);
  color: var(--btn-secondary-text);
  border-color: var(--btn-secondary-border);
}

.button-group {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--lighter);
}

.sync-button {
  background: var(--btn-primary-bg);
  color: var(--on-primary);
  border: 1px solid var(--btn-primary-bg);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  white-space: nowrap;
}

.sync-button:hover {
  background: var(--btn-primary-hover-bg);
  border-color: var(--btn-primary-hover-bg);
  color: var(--on-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.sync-button:active {
  transform: translateY(0);
  box-shadow: none;
}

.sync-button:disabled {
  background: var(--disabled-bg);
  border-color: var(--theme-border);
  color: var(--disabled-text);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  border-radius: var(--radius-sm);
}

.btn-outline-primary {
  color: var(--theme-link);
  background-color: transparent;
  border: 1px solid currentColor;
}

.btn-outline-primary:hover {
  color: var(--on-primary);
  background-color: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}

.btn-outline-danger {
  color: var(--theme-error);
  background-color: transparent;
  border: 1px solid currentColor;
}

.btn-outline-danger:hover {
  color: var(--on-primary);
  background-color: var(--btn-danger-bg);
  border-color: var(--btn-danger-bg);
}

.btn-danger {
  background-color: var(--btn-danger-bg);
  color: var(--on-primary);
  --bs-btn-active-bg: var(--btn-danger-hover-bg);
  --bs-btn-active-border-color: var(--btn-danger-hover-bg);
}

.btn-danger:hover {
  background-color: var(--btn-danger-hover-bg);
  color: var(--on-primary);
}

/* Tertiary/quiet (design §14): text-only, for low-emphasis actions. */
.btn-link {
  color: var(--theme-link);
  background: transparent;
  border-color: transparent;
}

/* Disabled (design §28.4): fill + not-allowed cursor + no hover, label
   >= 4.5:1. Never opacity — Bootstrap's .btn:disabled uses 0.65. */
.button:disabled,
.button[aria-disabled="true"],
.btn:disabled,
.btn.disabled,
.btn[aria-disabled="true"] {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  border-color: var(--theme-border);
  cursor: not-allowed;
  opacity: 1;
  transform: none;
  box-shadow: none;
}

@media (max-width: 640px) {
  .button,
  .btn,
  .sync-button {
    min-height: 44px; /* touch target, design §30.4 */
  }

}

/* ===== STATUS BADGES ===== */
.status,
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
}

/* IMPLEMENTATION_UI_004A: semantic badges are dark text on a tint, never
   brand colour (design §15); each also gets an icon below. */
.status.active,
.badge-success {
  background-color: var(--theme-success-bg);
  color: var(--theme-success);
}

.status.inactive,
.badge-warning {
  background-color: var(--theme-warning-bg);
  color: var(--theme-warning);
}

.status.pending,
.badge-info {
  background-color: var(--theme-info-bg);
  color: var(--theme-info);
}

.badge-secondary {
  background-color: var(--theme-surface-sunken);
  color: var(--theme-text-muted);
}

.badge-danger {
  background-color: var(--theme-error-bg);
  color: var(--theme-error);
}

.status-badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.connected {
  background-color: var(--theme-success-bg);
  color: var(--theme-success);
  border: 1px solid currentColor;
}

/* Was previously undefined — "Not Connected" tiles rendered as plain
   unstyled text. Neutral chip, matching the pipeline "not run yet" idle
   state elsewhere in the app. */
.status-badge.not-connected {
  background-color: var(--theme-surface-sunken);
  color: var(--theme-text-muted);
  border: 1px solid var(--theme-border-strong);
}

/* IMPLEMENTATION_022: connection is configured but not fully healthy —
   distinct from both "connected" (green) and "not connected" (neutral).
   Reused by the Source Systems / Accounting Targets cards on the
   Connections page, driven by connectionHealthService's real 'degraded'/
   'down' statuses, never guessed. */
.status-badge.attention-needed {
  background-color: var(--theme-warning-bg);
  color: var(--theme-warning);
  border: 1px solid currentColor;
}

/* IMPLEMENTATION_025: Account Matching's three real states (matched/
   suggested/unmatched — today services/glAccountMappingService.js, KD-101).
   Reuses the same .status-badge base as Connections' connected/not-connected/
   attention-needed chips instead of a new chip system. */
.status-badge.matched {
  background-color: var(--theme-success-bg);
  color: var(--theme-success);
  border: 1px solid currentColor;
}

.status-badge.suggested {
  background-color: var(--theme-info-bg);
  color: var(--theme-info);
  border: 1px solid currentColor;
}

.status-badge.unmatched {
  background-color: var(--theme-surface-sunken);
  color: var(--theme-text-muted);
  border: 1px solid var(--theme-border-strong);
}

/* Additional Fields mapping statuses (fields.configured/notMapped/needsReview) */
.status-badge.configured {
  background-color: var(--theme-success-bg);
  color: var(--theme-success);
  border: 1px solid currentColor;
}

.status-badge.not-mapped {
  background-color: var(--theme-surface-sunken);
  color: var(--theme-text-muted);
  border: 1px solid var(--theme-border-strong);
}

.status-badge.needs-review {
  background-color: var(--theme-warning-bg);
  color: var(--theme-warning);
  border: 1px solid currentColor;
}

.status-badge i {
  margin-right: 4px;
}

/* IMPLEMENTATION_UI_004A: status is never colour alone (design §15) — a
   badge without its own <i> icon gets one from its state. Decorative only;
   the text carries the meaning. Labels wrap rather than truncate (ES). */
.status-badge {
  white-space: normal;
}

.status-badge:not(:has(> i))::before,
.status.active::before, .status.inactive::before, .status.pending::before,
.badge-success::before, .badge-warning::before, .badge-info::before,
.badge-secondary::before, .badge-danger::before {
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  margin-right: 4px;
}

.status-badge.connected:not(:has(> i))::before,
.status-badge.matched:not(:has(> i))::before,
.status-badge.configured:not(:has(> i))::before,
.status.active::before,
.badge-success::before { content: "\f00c"; }   /* check */
.status-badge.attention-needed:not(:has(> i))::before,
.status-badge.needs-review:not(:has(> i))::before,
.status.inactive::before,
.badge-warning::before { content: "\f071"; }   /* exclamation-triangle */
.status-badge.suggested:not(:has(> i))::before,
.status.pending::before,
.badge-info::before { content: "\f05a"; }      /* info-circle */
.status-badge.not-connected:not(:has(> i))::before,
.status-badge.unmatched:not(:has(> i))::before,
.status-badge.not-mapped:not(:has(> i))::before,
.badge-secondary::before { content: "\f056"; } /* minus-circle */
.badge-danger::before { content: "\f057"; }    /* times-circle */

/* ===== Matching row pattern (Account Matching, IMPLEMENTATION_025,
   restyled as a connected pipeline in IMPLEMENTATION_029) =====
   One reusable Source -> BridgeConn -> Target -> Status pipeline row, built
   by public/js/mapping-manager.js's renderExactMatchesTable/
   renderSimilarMatchesTable/renderNoMatchesTable via buildMatchingRow().
   Reuses the same "connected stages + arrow connectors" visual language as
   the GL/Invoice/Credit Memo sync pipeline (sync-manager.css's
   .gl-pipeline-*) without sharing markup 1:1 — this pattern is a compact,
   single-row variant (per the approved reference images' density), not a
   card-per-stage layout; see the "do not over-card" note in this task's own
   spec. Desktop: 4 stages left-to-right with connector arrows. Mobile:
   stacks vertically, connectors rotate to point down. */
.matching-list {
  display: flex;
  flex-direction: column;
}

.matching-row {
  display: flex;
  /* IMPLEMENTATION_029B: was align-items: center. Centering flex siblings
     whose own content heights differ (e.g. a longer AccountType string
     wrapping the Accounting Target block to an extra line the Source
     System block doesn't need) centers each block independently, so their
     labels don't land on the same line — confirmed via Feedback029B's own
     screenshot, where ACCOUNTING TARGET sits visibly higher than SOURCE
     SYSTEM. flex-start pins every stage's own label to the row's top edge
     regardless of how much content wraps beneath it; .matching-row-actions
     opts back into vertical centering below, since its single button has
     no label of its own to align. */
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--list-border);
}

.matching-row:last-child {
  border-bottom: none;
}

.matching-row-stages {
  display: flex;
  /* See .matching-row's own comment above — same fix, one level deeper
     (Source System / BridgeConn / Accounting Target are siblings here). */
  align-items: flex-start;
  gap: var(--space-sm);
  flex: 1 1 auto;
  min-width: 0;
}

.matching-row-stage {
  flex: 1 1 0;
  min-width: 0;
}

.matching-row-stage--bridgeconn {
  flex: 0 1 8rem;
}

/* KD-93: row text reads theme/list tokens whose Light values equal the
   legacy ones (--theme-text-muted = --text-light, --list-* alias), so only
   the gated Dark theme changes. */
.matching-row-stage-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

/* Back-compat alias — same rule, old class name kept for any external
   reference; new markup uses .matching-row-stage-label directly. */
.matching-row-party-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.matching-row-party-name {
  font-weight: var(--font-weight-semibold);
  color: var(--list-text-strong);
  overflow-wrap: anywhere;
}

.matching-row-party-meta {
  font-size: var(--font-size-xs);
  color: var(--list-text-muted);
  font-family: var(--font-data);
}

.matching-row-party-empty {
  color: var(--theme-text-muted);
  font-style: italic;
}

.matching-row-bridgeconn-text {
  font-weight: var(--font-weight-semibold);
  color: var(--list-state-info); /* = --secondary in Light; Light Cyan in Dark (UI-DARK-001) */
  font-size: var(--font-size-sm);
  overflow-wrap: anywhere;
}

.matching-row-connector {
  flex: 0 0 auto;
  color: var(--theme-text-muted);
  font-size: var(--font-size-base);
  /* Stays visually centered between the two flanking stage blocks even
     though the row now top-aligns by default (see .matching-row-stages). */
  align-self: center;
}

.matching-row-status {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 6rem;
}

.matching-row-confidence {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-family: var(--font-data);
}

.matching-row-actions {
  flex: 0 0 auto;
  display: flex;
  gap: var(--space-sm);
  /* Unlike Source System/BridgeConn/Accounting Target/Status, the action
     button has no label of its own to top-align against — centering it
     against the row's tallest column reads as intentional, not offset. */
  align-self: center;
}

@media (max-width: 900px) {
  .matching-row-stage--bridgeconn {
    flex-basis: 6rem;
  }

  /* KD-93's .em-row wrap fix, extended to plain Account Matching rows: a
     company_admin's Change Match / Remove buttons otherwise squeezed the
     three stage columns to a few words per line at tablet width (members
     see no buttons, so only admins hit it). The 24rem basis keeps a
     buttonless row on one line; with buttons, status and actions wrap to
     the next line instead of crushing the names. */
  .matching-row {
    flex-wrap: wrap;
  }

  .matching-row-stages {
    flex: 1 1 24rem;
  }

  .matching-row-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .matching-row {
    flex-wrap: wrap;
  }

  .matching-row-stages {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: var(--space-xs);
  }

  .matching-row-stage--bridgeconn {
    flex-basis: auto;
  }

  .matching-row-connector {
    align-self: center;
    transform: rotate(90deg);
  }

  .matching-row-status,
  .matching-row-actions {
    width: 100%;
    align-items: stretch;
  }

  .matching-row-status {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
    margin-top: var(--space-xs);
  }
}

/* Manual Matching modal (IMPLEMENTATION_029, compact redesign in
   IMPLEMENTATION_029A per Feedback029.docx — "large unused white space...
   weak hierarchy... target search feels isolated"). Same Source/Target
   visual language as .matching-row. Presentation only;
   #vistaSuiteCode/#vistaSuiteName/#qbAccountSearch/#qbAccountDropdown/
   #selectedQbAccountInfo/#saveManualMapping keep their exact ids and
   behavior (see _account-sync.ejs's own comment). */
.manual-match-dialog {
  /* IMPLEMENTATION_036: widened from 640px — a real UAT blocker (client
     screenshot showed "Search by name or …" placeholder clipped mid-word,
     "What's after or? It doesn't show"). Root cause: the two-column
     source/target layout plus the search input's own clear (×) button
     left the QuickBooks-account search input too narrow at 640px total
     modal width to render its full placeholder ("Search by name or
     number…") at normal desktop widths. Verified live at 1440/1280/390px
     after this change — placeholder renders in full at desktop/laptop
     widths, and the modal still fits with no horizontal overflow at
     390px (its own existing @media (max-width: 640px) column-stacking
     rule, below, is unaffected by this width change). */
  max-width: 820px;
}

.manual-match-header {
  padding: var(--space-md) var(--space-lg);
}

.manual-match-body {
  padding: var(--space-md) var(--space-lg);
}

.manual-match-columns {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.manual-match-column {
  flex: 1 1 0;
  min-width: 0;
}

.manual-match-connector-col {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  height: 100%;
  padding-top: 2.25rem;
}

.manual-match-provider {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.manual-match-source-card {
  background: var(--lighter);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  min-height: 2.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.manual-match-search-group {
  margin-bottom: 2px;
}

/* IMPLEMENTATION_036: the biggest single contributor to the placeholder-
   truncation UAT blocker turned out not to be the modal's own width at
   all — it was this icon-only clear (×) button inheriting the app-wide
   `.btn` rule's `padding: var(--space-md) var(--space-xl)` (16px/32px),
   meant for normal text buttons like "Confirm Match", not a single
   14px icon. That padding alone made the button ~75px wide inside a
   ~293px column, leaving the actual search input only ~217px — too
   narrow for "Search by name or number…" at any reasonable modal width.
   Scoped to this one button only (not a global `.btn` change) so no
   other button anywhere else in the app is affected. */
#clearQBSearch {
  padding: var(--space-sm);
  flex: 0 0 auto;
}

/* IMPLEMENTATION_036: the search-example helper text (§21 UAT fix — a
   real, verified example the client explicitly asked for). */
.manual-match-search-example {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.manual-match-selected {
  margin-top: var(--space-sm);
}

.manual-match-selected-card {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  min-height: 2.75rem;
  display: flex;
  align-items: center;
}

.manual-match-selected-card.manual-match-selected-card--filled {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--text-primary);
}

.manual-match-error {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--theme-error-bg); /* KD-93: Light values equal --error-light/--error */
  border: 1px solid var(--theme-error);
  border-radius: var(--radius-md);
  color: var(--theme-error);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.manual-match-footer {
  padding: var(--space-sm) var(--space-lg) var(--space-md);
}

/* IMPLEMENTATION_042A: business-safe QuickBooks-accounts-load-failure
   state inside the target search dropdown (see mapping-manager.js's
   renderQbAccountsLoadError()) — replaces a previous raw error.message
   display with a fixed primary message, a next-step line, and a Retry
   action, matching this modal's existing error-state visual language
   (.manual-match-error) rather than plain unstyled dropdown text. */
.qb-load-error {
  white-space: normal;
}

.qb-load-error-nextstep {
  margin-top: 2px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.qb-load-error-retry {
  margin-top: var(--space-sm);
}

@media (max-width: 640px) {
  .manual-match-columns {
    flex-direction: column;
  }

  .manual-match-connector-col {
    align-self: center;
    padding-top: 0;
    transform: rotate(90deg);
  }
}

/* ===== Mapping grid pattern (Additional Fields, IMPLEMENTATION_025,
   restyled as a connected pipeline in IMPLEMENTATION_029, then corrected
   into a dense ETL-style configuration grid in IMPLEMENTATION_029A per
   product-owner acceptance feedback) =====
   IMPLEMENTATION_029A: the 029-era "Source -> BridgeConn -> Target ->
   Status" 4-stage card-per-row layout (.mapping-row / .mapping-row-stages)
   was reported as too spacious/hard to scan for a list of many field
   mappings (14 rows on Invoice). This is a CONFIGURATION GRID, not the
   connected-pipeline visualization used for Sync workflows or Account
   Matching (see .matching-row-stages, unchanged) — see the "UX pattern"
   note in docs/04_UI_UX_SPECIFICATION.md. Column labels render once in
   .mapping-grid-header instead of being repeated on every row, and the
   redundant middle "BridgeConn" stage box is dropped (its only content —
   Mapped / Not configured / Needs review / Unsaved — already duplicates
   the Status column). Target Field renders as plain text, not a select:
   IMPLEMENTATION_029A's evidence-based assessment concluded dynamic
   target selection is DEFERRED_ARCHITECTURAL_CHANGE (mapping_gl_fields /
   mapping_invoice_fields are target-keyed, UNIQUE(qbo_field_key) — see
   IMPLEMENTATION_029A completion report), so the lock icon here is a
   deliberate, documented affordance, not an omission. */
/* ===== IMPLEMENTATION_030: page-level composition, matching the two
   product-owner-approved mockups (docs/ux/referemce/journalEntryAdditionalFields.png,
   InvoiceAdditionalFields.png) — summary metrics, toolbar with capability
   note, the grid (below), and a supporting info panel beside it on desktop.
   Behavior/persistence contracts are unchanged from 029A/029B; this section
   is presentation-only. */
.mapping-page {
  margin-top: var(--space-md);
}

.mapping-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.mapping-summary-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--white);
}

.mapping-summary-icon {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-base);
}

.mapping-summary-card--configured .mapping-summary-icon {
  background: var(--success-light);
  color: var(--success);
}

.mapping-summary-card--not-configured .mapping-summary-icon {
  background: var(--lighter);
  color: var(--text-light);
}

.mapping-summary-card--needs-review .mapping-summary-icon {
  background: var(--warning-light);
  color: var(--warning);
}

.mapping-summary-card--pending-removal .mapping-summary-icon {
  background: var(--error-light);
  color: var(--error);
}

.mapping-summary-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.mapping-summary-count {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
}

.mapping-summary-sub {
  font-size: var(--font-size-xs);
  color: var(--text-light);
}

.mapping-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.mapping-toolbar .search-input {
  flex: 0 0 auto;
  width: 260px;
  max-width: 100%;
}

.mapping-status-filter {
  flex: 0 0 auto;
  width: auto;
}

.mapping-capability-note {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--space-sm) var(--space-md);
  background: var(--lighter);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.mapping-capability-note i {
  color: var(--secondary);
  flex: 0 0 auto;
}

/* Main grid + supporting info panel, side by side on desktop. */
.mapping-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-lg);
  align-items: start;
}

.mapping-main {
  min-width: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.mapping-info-panel {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  background: var(--white);
  position: sticky;
  top: var(--space-md);
}

.mapping-info-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--lighter);
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-sm);
}

.mapping-info-panel h3 {
  font-size: var(--font-size-base);
  margin: 0 0 var(--space-sm);
  color: var(--text-primary);
}

.mapping-info-panel p {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-sm);
}

.mapping-info-panel p:last-child {
  margin-bottom: 0;
}

.mapping-list {
  display: flex;
  flex-direction: column;
}

.mapping-grid-header,
.mapping-grid-row {
  display: grid;
  /* IMPLEMENTATION_030: Source gets more share than Target — the source
     select's own visible text (an existing, pre-030 field key/description
     pattern from syncManagerController.js) needs more room than Target's
     short, curated business-friendly label ever does. */
  grid-template-columns: minmax(0, 1.4fr) 2rem minmax(0, 1fr) minmax(130px, auto) minmax(90px, auto);
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  padding: var(--space-xs) var(--space-lg);
}

.mapping-grid-header {
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--theme-text-muted);
  border-bottom: 1px solid var(--list-border);
}

.mapping-grid-header-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mapping-grid-readonly-hint {
  color: var(--theme-text-muted);
  cursor: help;
  font-size: var(--font-size-xs);
}

.mapping-grid-row {
  /* IMPLEMENTATION_029B: focused polish pass — a fixed min-height keeps row
     heights consistent regardless of whether a given row's status cell
     also shows the (rare) Needs Review help line, so scanning many rows
     doesn't feel jumpy. Still the same compact grid direction from 029A,
     not a redesign. */
  min-height: 2.75rem;
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--list-border);
}

.mapping-grid-row:last-child {
  border-bottom: none;
}

.mapping-grid-mobile-label {
  display: none;
}

.mapping-grid-cell {
  min-width: 0;
}

.mapping-grid-cell--source select {
  width: 100%;
}

.mapping-grid-source-desc {
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
  margin-top: 2px;
}

.mapping-grid-action-label {
  margin-left: 4px;
}

/* IMPLEMENTATION_030: the compact "BridgeConn" connector cell — a small
   semantic icon plus a dotted line and arrow, matching the approved
   mockups' per-row connector exactly. This is presentation only: it does
   not repeat the "Configured"/"Not mapped" text the Status column already
   states (that redundancy was deliberately removed in 029A), just a
   glanceable visual link between the two field columns. aria-hidden since
   it carries no information beyond what Source/Target/Status already
   convey to assistive tech. */
.mapping-grid-cell--connector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--theme-text-muted);
}

.mapping-grid-connector-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-md);
  background: var(--list-info-bg);
  color: var(--list-sorted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex: 0 0 auto;
}

.mapping-grid-connector-line {
  flex: 1 1 auto;
  height: 0;
  border-top: 1px dotted var(--list-border);
  min-width: 6px;
}

.mapping-grid-connector-arrow {
  flex: 0 0 auto;
  font-size: 0.7rem;
}

.mapping-grid-target-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--list-text-strong);
  overflow-wrap: anywhere;
}

.mapping-grid-target-value i {
  color: var(--theme-text-muted);
  font-size: 0.8em;
}

.mapping-grid-cell--status {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mapping-grid-cell--action {
  display: flex;
  justify-content: flex-end;
}

.mapping-row-help {
  font-size: var(--font-size-xs);
  color: var(--warning);
}

.mapping-grid-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

/* Save/Discard bar placed directly under the grid (IMPLEMENTATION_029A —
   moved from above the lineage canvas, far from the editable rows, to
   sit immediately adjacent to what it acts on). IMPLEMENTATION_030 added
   the left-aligned live dirty-state status text, matching the approved
   mockups' "N unsaved changes" pattern. */
.mapping-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--border-color);
  background: var(--lighter);
  position: sticky;
  bottom: 0;
}

.mapping-save-bar-status {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* A CSS-generated dot (not a real child element) so JS can safely set this
   element's textContent directly without wiping out a nested indicator
   node. */
.mapping-save-bar-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--secondary);
  flex: 0 0 auto;
}

.mapping-save-bar-status--clean::before {
  background: var(--text-light);
}

.mapping-save-bar-actions {
  display: flex;
  gap: var(--space-sm);
}

@media (max-width: 1100px) {
  .mapping-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mapping-layout {
    grid-template-columns: 1fr;
  }

  .mapping-info-panel {
    position: static;
    order: 2;
  }

  .mapping-main {
    order: 1;
  }
}

@media (max-width: 900px) {
  .mapping-grid-header,
  .mapping-grid-row {
    grid-template-columns: minmax(0, 1.3fr) 1.5rem minmax(0, 1fr) minmax(110px, auto) minmax(80px, auto);
  }
}

@media (max-width: 640px) {
  .mapping-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .mapping-toolbar .search-input {
    width: 100%;
  }

  .mapping-grid-header {
    display: none;
  }

  .mapping-grid-row {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
    padding: var(--space-sm);
  }

  .mapping-grid-mobile-label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--theme-text-muted);
    margin-bottom: 2px;
  }

  /* The connector cell collapses to a small centered down-arrow between
     Source and Target when stacked, instead of the desktop's horizontal
     icon+dotted-line — same information (a link exists), shape adapted to
     a single column so it doesn't look like an orphaned row. */
  .mapping-grid-cell--connector {
    justify-content: center;
    padding: 2px 0;
  }

  .mapping-grid-connector-line {
    display: none;
  }

  .mapping-grid-cell--action {
    justify-content: stretch;
  }

  .mapping-grid-cell--action .button {
    width: 100%;
    justify-content: center;
  }

  .mapping-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

  /* The status text stacks above the button row (the .mapping-actions-bar
     rule above); within that row, Discard/Save now split evenly instead of
     staying at their natural (button-text) width, which previously
     squeezed both labels down to a couple of truncated characters. */
  .mapping-save-bar-actions {
    display: flex;
    gap: var(--space-sm);
  }

  .mapping-save-bar-actions .button {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    white-space: normal;
    text-align: center;
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  .mapping-save-bar-actions .button i {
    flex-shrink: 0;
  }
}

/* ===== ALERTS ===== */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
}

/* IMPLEMENTATION_UI_004A: semantic tint + semantic text (>= 4.83:1 Light,
   >= 7.17:1 Dark); replaces the three Bootstrap-era literals. */
.alert-info {
  background: var(--theme-info-bg);
  color: var(--theme-info);
  border: 1px solid currentColor;
}

.alert-success {
  background: var(--theme-success-bg);
  color: var(--theme-success);
  border: 1px solid currentColor;
}

.alert-error,
.alert-danger {
  background: var(--theme-error-bg);
  color: var(--theme-error);
  border: 1px solid currentColor;
}

.alert-warning {
  background: var(--theme-warning-bg);
  color: var(--theme-warning);
  border: 1px solid currentColor;
}

/* ===== TABS ===== */
.nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--theme-border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  margin-bottom: 0;
  background: var(--theme-surface-sunken);
}

.nav-tabs .nav-item {
  flex: 1;
}

.nav-tabs .nav-link {
  flex: 1;
  padding: var(--space-md) var(--space-xl);
  background: none;
  border: none;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--theme-text-secondary);
  cursor: pointer;
  transition: all var(--transition-slow);
  position: relative;
  text-align: center;
  border-radius: 0;
  font-family: inherit;
}

.nav-tabs .nav-link:hover {
  background: var(--btn-secondary-hover-bg);
  color: var(--theme-text);
}

.nav-tabs .nav-link.active {
  background: var(--theme-surface);
  color: var(--theme-text);
  font-weight: var(--font-weight-semibold);
}

.nav-tabs .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--selected-indicator); /* design §30.4: indicator, not colour alone */
}

.tab-content {
  background: var(--theme-surface);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* ===== SYNC MANAGER TABS ===== */
/* Main tab panels - only one should be visible at a time */

/* Base state: all tab panels are hidden */
.tab-pane {
  display: none;
}

/* Active tab panel should be visible */
.tab-pane.active.show,
.tab-pane.show.active {
  display: block;
}

/* Bootstrap 5 compatibility - ensure show class also displays */
.tab-pane.show {
  display: block;
}

/* CRITICAL: Sync Manager specific rules - ensure only one main panel is visible */
/* These rules override the general tab-pane rules for Sync Manager tabs */
#syncManagerTabContent .tab-pane {
  display: none !important;
}

#syncManagerTabContent .tab-pane.active.show {
  display: block !important;
}

/* When GL Sync panel is active and shown, Invoice Sync must be hidden */
#syncManagerTabContent #gl-sync.active.show ~ #invoice-sync {
  display: none !important;
  visibility: hidden !important;
}

#syncManagerTabContent #invoice-sync.active.show ~ #gl-sync {
  display: none !important;
  visibility: hidden !important;
}

/* Ensure panels are properly hidden when not active */
#syncManagerTabContent #gl-sync:not(.active):not(.show) {
  display: none !important;
  visibility: hidden !important;
}

#syncManagerTabContent #invoice-sync:not(.active):not(.show) {
  display: none !important;
  visibility: hidden !important;
}

/* Ensure nested tab-panes (sub-tabs) are visible only when parent GL Sync panel is active */
/* Sub-tabs inside GL Sync should only show when GL Sync panel is active */
#gl-sync:not(.active):not(.show) .tab-pane {
  display: none !important;
}

#gl-sync.active.show .tab-pane.active.show {
  display: block !important;
}

/* Ensure Invoice Sync panel content is only visible when Invoice tab is active */
#invoice-sync.active.show {
  display: block !important;
}

/* ===== CONTEXT BAR (for client-config customer switcher) ===== */
.context-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--theme-info-bg); /* IMPLEMENTATION_UI_004A: holds a themed .form-select */
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.context-bar-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--theme-link);
  white-space: nowrap;
}

.context-bar select.form-select {
  min-width: 280px;
}

.context-bar-hint {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--theme-text-muted);
}

/* ===== CUSTOM TABS (client-config's tab switcher; also reused by Reports'
   period-selector links) ===== */
/* Fused into one flat, bordered card — .tabs-container is now the card
   surface itself (matching .tab-card's treatment elsewhere), .tabs is the
   header strip, and .tab-content-container no longer carries its own
   shadow-md/radius-xl since the outer container already provides the card
   chrome. Note this restyle also reaches Reports' period-selector tabs
   (same classes, different page) — that's an intentional side effect since
   it's a strict visual improvement, not a functional change; Reports'
   fuller redesign is a separate pass. */
.tabs-container {
  margin-top: var(--space-lg);
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-card);
  overflow: hidden;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--theme-surface-sunken);
  border-bottom: 1px solid var(--theme-border);
  margin-bottom: 0;
}

.tab {
  padding: .8rem 1.1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--theme-text-muted);
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: inherit;
  position: relative;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-block;
}

.tab:hover {
  color: var(--theme-text);
  background: transparent;
}

.tab.active {
  color: var(--theme-text);
  font-weight: var(--font-weight-semibold);
  border-bottom-color: var(--selected-indicator);
  background: var(--theme-surface);
}

.tab-content-container {
  background: var(--theme-surface);
  overflow: hidden;
  min-height: 300px;
}

.tab-content {
  padding: 0;
}

/* Scoped to .tab-content-container (client-config.js's custom tab pattern)
   only — plain .tab-content is reused elsewhere as a Bootstrap tab-content
   *wrapper* (see e.g. views/partials/sync-manager/_gl.ejs), which must stay
   visible regardless of any .active class, since Bootstrap toggles its
   .tab-pane children instead. */
.tab-content-container .tab-content {
  display: none;
}

.tab-content-container .tab-content.active {
  display: block;
}

/* Read-only form styling */
/* IMPLEMENTATION_UI_004A: disabled/read-only by fill + cursor, never opacity
   (label 5.11:1 Light / 5.86:1 Dark). */
.form-input[readonly],
.form-select[disabled] {
  background-color: var(--disabled-bg) !important;
  color: var(--disabled-text);
  cursor: not-allowed !important;
  opacity: 1;
}

/* ===== DROPDOWN ===== */
.dropdown-container {
  position: relative;
  display: inline-block;
}

.dropdown-button {
  background: var(--secondary);
  color: var(--white);
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: all var(--transition-base);
  font-family: inherit;
}

.dropdown-button:hover {
  background: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--white);
  border: 1px solid var(--light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-base);
  z-index: var(--z-dropdown);
  min-width: 150px;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  padding: var(--space-md) var(--space-lg);
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--lighter);
  transition: all var(--transition-base);
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: var(--lighter);
  color: var(--text-secondary);
  padding-left: 1.25rem;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-modal-backdrop);
  backdrop-filter: blur(5px);
}

/* IMPLEMENTATION_UI_004A: the centred, flex "loading" card is scoped to its
   own .modal-overlay. It used to apply to every Bootstrap .modal-content too,
   centring all dialog text (UI-002 finding #1). */
.modal-overlay .modal-content {
  background-color: var(--surface-elevated);
  padding: var(--space-xl) var(--space-2xl);
  border-radius: var(--theme-radius-card);
  text-align: center;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  box-shadow: var(--theme-shadow-elevated);
  color: var(--theme-text);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
}

/* Bootstrap dialogs (design §30.4): elevated surface, neutral header, the
   destructive action uses .btn-danger (--btn-danger-bg). */
.modal .modal-content {
  background-color: var(--surface-elevated);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-card);
  box-shadow: var(--theme-shadow-elevated);
}

.modal-header {
  background-color: var(--surface-elevated);
  color: var(--theme-text);
  border-bottom: 1px solid var(--theme-border);
  padding: var(--space-lg);
}

.modal-header .modal-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: var(--font-weight-semibold);
}

:root[data-theme="dark"] .modal-header .btn-close {
  filter: invert(1); /* Bootstrap's dark X on the dark elevated surface */
}

.modal-footer {
  border-top: 1px solid var(--theme-border);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

.modal-footer .btn {
  padding: var(--space-md) var(--space-lg);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
}

/* ===== LOADING STATES ===== */
.spinner {
  border: 4px solid var(--spinner-track);
  border-top: 4px solid var(--spinner-head);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-highlight) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

.skeleton-line {
  height: 20px;
  margin: var(--space-sm) 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-highlight) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

/* ===== FOOTER ===== */
/* Footer: Fixed at bottom of main content area */
.footer {
  background-color: var(--primary);
  color: var(--white);
  padding: var(--space-xl) var(--space-lg) var(--space-md);
  flex: 0 0 auto; /* Don't grow or shrink, use natural height */
  flex-shrink: 0;
  overflow: visible; /* No internal scroll */
}

.footer-bottom {
  border-top: 1px solid var(--secondary);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-bottom p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* KD-65 (UI-004A1): the authenticated footer (views/partials/app-footer.ejs)
   only; the login layout's footer keeps its own colours. */
.app-shell-main > footer .footer-bottom {
  border-top-color: var(--page-footer-border);
}

.app-shell-main > footer .footer-bottom p {
  color: var(--page-footer-text);
}

/* ===== SYNC MANAGER ===== */
.sync-manager-container {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ===== CONFIG PAGE ===== */
/* UI-DARK-002: the Connections rules below read list/theme tokens whose Light
   values equal the legacy ones they replace, so Light is unchanged and in the
   gated Dark theme the tiles, sync path and checklist follow the dark surface. */
.config-container {
  padding: var(--space-xl);
  max-width: 1200px;
  margin: 0 auto;
}

.connections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* Flat, bordered tile — was shadow-md + gradient background + hover-lift
   transform, the same heavier style already flattened everywhere else in
   the app. Status distinction (connected/not) stays as a border color +
   icon badge, just without the shadow/gradient/motion. */
.connection-tile {
  background: var(--list-surface);
  border: 1px solid var(--list-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.connection-tile.connected {
  border-color: var(--theme-success);
}

.tile-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.tile-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  flex-shrink: 0;
  background: var(--list-info-bg);
  color: var(--list-text-muted);
}

.connection-tile.connected .tile-icon {
  background: var(--theme-success-bg);
  color: var(--theme-success);
}

/* Connection provider logo lane — Vista Suite + QuickBooks logos sit here.
   Separate from .tile-icon (shared with Connection Health) so the connected/
   attention status tints never sit behind a logo. Left-aligned on a neutral
   plate; the lane widens to fit a wordmark. */
.tile-logo-lane {
  height: 48px;
  min-width: 48px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-md);
  background: var(--list-info-bg);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
  overflow: hidden;
}

.tile-logo {
  height: 32px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
  display: block;
}

/* Theme-swapped wordmark: dark-text in light theme, white in dark. A logo
   with no dark variant uses the bare .tile-logo and shows in both themes. */
.tile-logo-dark { display: none; }
:root[data-theme="dark"] .tile-logo-light { display: none; }
:root[data-theme="dark"] .tile-logo-dark { display: block; }

/* ===== SETUP CHECKLIST STYLES ===== */
/* Flat card matching the rest of the app — was shadow-md + thick borders. */
.setup-checklist-section {
  background: var(--list-surface);
  border: 1px solid var(--list-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  margin-top: var(--space-xl);
}

.checklist-header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--list-border);
}

.checklist-header h3 {
  color: var(--list-text-strong);
  margin-bottom: var(--space-sm);
  font-size: 1.25rem;
  font-weight: 700;
}

.checklist-header p {
  margin: 0;
  font-size: 0.95rem;
}

.checklist-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.checklist-item {
  background: var(--list-surface);
  border: 1px solid var(--list-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: border-color var(--transition-base);
}

.checklist-item:hover {
  border-color: var(--accent);
}

.checklist-item.item-complete {
  background: var(--theme-success-bg);
  border-color: var(--theme-success);
}

.checklist-item-content {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
}

.checklist-item-status {
  flex-shrink: 0;
  font-size: 1.5rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checklist-item-details {
  flex: 1;
  min-width: 0;
}

.checklist-item-title {
  margin: 0 0 var(--space-xs) 0;
  color: var(--list-text-strong);
  font-size: 1rem;
  font-weight: 600;
}

.checklist-item-description {
  margin: 0 0 var(--space-xs) 0;
  color: var(--list-text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.checklist-item-note {
  margin: var(--space-xs) 0 0 0;
  font-size: 0.85rem;
  font-style: italic;
}

.checklist-item-action {
  flex-shrink: 0;
}

.checklist-item-action .btn {
  white-space: nowrap;
}

/* IMPLEMENTATION_027A: pre-existing mobile bug found during this task's own
   responsive verification pass (not introduced by this task — .checklist-item*
   was not otherwise touched here). Below 576px, .checklist-item-content's
   flex row squeezed .checklist-item-details into a column too narrow for
   its title text, which wrapped directly beside the fixed-width, nowrap
   action button and read as visually overlapping/jumbled. Stack instead. */
@media (max-width: 576px) {
  .checklist-item-content {
    flex-direction: column;
    align-items: stretch;
  }

  .checklist-item-action {
    align-self: flex-start;
  }
}

.tile-title {
  flex: 1;
}

.tile-title h4 {
  margin: 0 0 var(--space-sm) 0;
  color: var(--list-text-strong);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

.tile-content {
  margin-bottom: var(--space-lg);
}

.tile-content p {
  margin: var(--space-sm) 0;
  color: var(--list-text-muted);
  font-size: var(--font-size-sm);
}

.tile-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ===== CONNECTIONS PAGE RESTRUCTURE (IMPLEMENTATION_022) =====
   Source Systems / Accounting Targets / Active Sync Path. Extends the
   existing connection-tile, tile, and status-badge system above rather
   than replacing it — same flat-bordered card language used everywhere else.
   IMPLEMENTATION_027A: this comment used to name three class fragments
   separated by slashes, and the middle fragment ended in an asterisk right
   before the next slash — that two-character sequence (asterisk immediately
   followed by slash) is the CSS comment terminator, so it closed this
   comment early. Everything after that point was silently parsed as one
   giant, invalid selector reaching all the way to the opening brace of
   whatever rule came next — confirmed with a real CSS parser (the `css` npm
   package), not just by reading the file. Browsers recover from this kind
   of error by discarding that one bogus rule and resuming normal parsing
   right after its closing brace, so the bug was invisible until
   IMPLEMENTATION_027A inserted a new, meaningful rule immediately after this
   comment and that rule silently stopped working. Never let a CSS comment's
   text contain an asterisk directly followed by a slash, for exactly this
   reason. */

/* IMPLEMENTATION_027A: Source Systems / Accounting Targets side by side on
   wide screens (matches the approved Connections reference), stacking back
   to one column at the same breakpoint the existing .connections-grid
   already uses for its own responsive collapse (see media query below). */
.connections-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

@media (max-width: 900px) {
  .connections-columns {
    grid-template-columns: 1fr;
  }
}

.connections-section {
  margin-bottom: var(--space-xl);
}

.connections-section-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--list-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 var(--space-md);
}

/* Attention-needed tiles get an amber border, mirroring .connected's green
   border — never relying on the status chip's color alone. */
.connection-tile.attention-needed {
  border-color: var(--theme-warning);
}

.connection-tile.attention-needed .tile-icon {
  background: var(--theme-warning-bg);
  color: var(--theme-warning);
}

.tile-role {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--list-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 2px;
}

/* Active Sync Path — informational only, no path-creation UI. Horizontal
   on desktop, stacks vertically (arrow rotates) on narrow viewports so the
   source->target relationship never depends on horizontal space. */
.active-sync-path {
  background: var(--list-surface);
  border: 1px solid var(--list-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  text-align: center;
  flex-wrap: wrap;
}

.active-sync-path.inactive {
  border-style: dashed;
  color: var(--list-text-muted);
}

.active-sync-path-node {
  font-weight: var(--font-weight-semibold);
  color: var(--list-text-strong);
  font-size: var(--font-size-lg);
}

.active-sync-path-arrow {
  font-size: var(--font-size-xl);
  color: var(--list-state-info);
}

.active-sync-path.inactive .active-sync-path-arrow {
  color: var(--theme-text-muted);
}

.active-sync-path-note {
  width: 100%;
  margin: var(--space-sm) 0 0;
  font-size: var(--font-size-sm);
  color: var(--list-text-muted);
}

@media (max-width: 576px) {
  .active-sync-path {
    flex-direction: column;
  }
  .active-sync-path-arrow {
    transform: rotate(90deg);
  }
}

.no-connections {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.no-connections-content {
  text-align: center;
  padding: var(--space-2xl);
  background: var(--white);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 400px;
}

.no-connections-content i {
  font-size: var(--space-3xl);
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.no-connections-content h3 {
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.no-connections-content p {
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* ===== UTILITY CLASSES ===== */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-5 { margin-top: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-5 { margin-bottom: var(--space-xl); }

.p-1 { padding: var(--space-xs); }
.p-2 { padding: var(--space-sm); }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-5 { padding: var(--space-xl); }

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
  .mapping-manager-container {
    max-width: 100%;
    padding: 0 var(--space-md);
  }
  
  .table-controls {
    padding: var(--space-md);
  }
  
  .search-input {
    max-width: 250px;
  }
}

@media (max-width: 992px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .connections-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
  
  .table-controls {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }
  
  .search-input {
    max-width: 200px;
    min-width: 150px;
  }
  
  .table th,
  .table td {
    padding-top: 0.25rem; /* 4px */
    padding-bottom: 0.25rem; /* 4px */
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

@media (max-width: 768px) {
  /* App shell on mobile: the persistent sidebar becomes an off-canvas
     drawer, opened by #open-sidebar-btn (the single hamburger in the slim
     top bar) and closed via #close-sidebar-btn, a backdrop click, or
     selecting a link (see public/js/ui.js). */
  .app-hamburger {
    display: flex;
  }

  /* Unchanged since IMPLEMENTATION_023: the closing-date badge is hidden on
     mobile (it carries a date, so an icon alone would say nothing). */
  .qbo-closing-date-badge {
    display: none;
  }

  /* IMPLEMENTATION_UI_003C: 44px touch targets. */
  .app-lang-btn,
  .theme-control--compact .theme-control-option > span {
    min-width: 44px;
    min-height: 44px;
  }

  .app-logout-link {
    width: 44px;
    height: 44px;
  }

  .app-topnav {
    padding: 0 var(--space-md);
  }

  .app-nav-right {
    gap: var(--space-sm);
  }

  .app-user-name {
    display: none;
  }

  .app-company-context span {
    display: none; /* icon only on mobile; the full name is still in the sidebar's own header */
  }

  /* IMPLEMENTATION_UI_003B: a closed drawer is visibility:hidden (after the
     slide-out finishes), so nothing inside it can take keyboard focus even
     before public/js/sidebar-drawer.js adds `inert`. */
  .app-shell-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: var(--z-fixed);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--transition-slow), visibility 0s linear var(--transition-slow);
    box-shadow: var(--shadow-xl);
  }

  .app-shell-sidebar.show {
    transform: translateX(0);
    visibility: visible;
    transition: transform var(--transition-slow), visibility 0s;
  }

  /* 44×44 touch target (WCAG 2.5.8 minimum is 24; 44 is the mobile goal). */
  .app-shell-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-lg);
  }

  .app-shell-sidebar-close:hover {
    background: var(--shell-sidebar-hover-bg);
    color: var(--shell-sidebar-text);
  }

  .app-shell-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-fixed) - 1);
  }

  .content {
    padding: var(--space-md);
  }
  
  .header h1 {
    font-size: var(--font-size-2xl);
  }
  
  .nav-tabs {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }
  
  .nav-tabs .nav-link {
    font-size: var(--font-size-sm);
    padding: var(--space-md) var(--space-lg);
    white-space: nowrap;
  }
  
  .table-controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
    padding: var(--space-md);
  }
  
  .search-input {
    max-width: none;
    width: 100%;
  }
  
  .sort-button,
  .refresh-button,
  .sync-button {
    width: 100%;
    justify-content: center;
  }
  
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table {
    min-width: 800px;
  }
  
  .table th,
  .table td {
    padding-top: 0.25rem; /* 4px */
    padding-bottom: 0.25rem; /* 4px */
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
    font-size: var(--font-size-xs);
  }
  
  .pagination-container {
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md);
  }
  
  .pagination-controls {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .page-size-selector {
    margin-right: 0;
    margin-bottom: var(--space-sm);
  }
  
  .form-content {
    padding: var(--space-lg);
  }
  
  .button-group {
    flex-direction: column;
  }
  
  .button,
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
  
  .connections-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575px) {
  .mapping-manager-container {
    padding: 0 var(--space-sm);
  }
  
  .table {
    min-width: 600px;
    font-size: var(--font-size-xs);
  }
  
  .table th,
  .table td {
    padding: var(--space-xs) var(--space-xs);
    white-space: nowrap;
  }
  
  .pagination-button {
    padding: var(--space-sm);
    min-width: 2rem;
    font-size: var(--font-size-xs);
  }
  
  .form-header {
    padding: var(--space-md);
  }
  
  .form-header h2 {
    font-size: var(--font-size-xl);
  }
  
  .table-controls {
    padding: var(--space-sm);
  }
  
  .search-input {
    font-size: var(--font-size-xs);
    padding: var(--space-sm) var(--space-md);
  }
  
  .sort-button,
  .refresh-button,
  .sync-button {
    padding: var(--space-sm);
    font-size: var(--font-size-xs);
  }
  
  .config-container {
    padding: var(--space-md);
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .nav-tabs,
  .table-controls,
  .pagination-container,
  .modal,
  .btn,
  .button {
    display: none !important;
  }
  
  .table {
    font-size: var(--font-size-xs);
  }
  
  .table th,
  .table td {
    padding: var(--space-xs);
    border: 1px solid #000;
  }
  
  .table-container {
    box-shadow: none;
    border: 1px solid #000;
  }
}

/* ===== THEME CONTROL (IMPLEMENTATION_UI_002) =====
   Reusable System/Light/Dark control (views/partials/_theme-control.ejs).
   Rendered only while the Dark exposure gate is on. It sits on today's
   Light chrome, so it uses the existing tokens, not --theme-*. */
.theme-control-group {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.theme-control-legend {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  float: none;
  width: auto;
}

.theme-control-options {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: var(--space-xs);
  border: 1px solid var(--border-strong);
  border-radius: var(--theme-radius-control);
  background: var(--white);
}

.theme-control-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin: 0;
  cursor: pointer;
}

/* The native radio stays in the accessibility tree and keeps native
   keyboard behaviour (arrow keys); only its default dot is visually hidden. */
.theme-control-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.theme-control-option span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-md);
  border-radius: calc(var(--theme-radius-control) - 2px);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.theme-control-option:hover span {
  background: var(--bg-hover);
}

/* Selected state is fill + weight + a check mark, never colour alone. */
.theme-control-option input:checked + span {
  background: var(--theme-brand-primary);
  color: var(--white);
  font-weight: var(--font-weight-semibold);
}

.theme-control-option input:checked + span::before {
  content: "\2713";
  margin-right: var(--space-xs);
}

.theme-control-option input:focus-visible + span {
  outline: 2px solid var(--theme-brand-primary);
  outline-offset: 2px;
}

.theme-control-hint,
.theme-control-status {
  margin: var(--space-sm) 0 0;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.theme-control-status:empty {
  display: none;
}

.theme-control-submit {
  margin-top: var(--space-sm);
  min-height: 36px;
  padding: 0 var(--space-md);
  border: 1px solid var(--border-strong);
  border-radius: var(--theme-radius-control);
  background: var(--white);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

/* With JavaScript, choosing an option saves it — the button is redundant. */
.theme-control--enhanced .theme-control-submit {
  display: none;
}

/* IMPLEMENTATION_UI_003C: at phone width, with the theme selector present
   (gate on), the header's controls need about 450px at 44px touch size, so
   the preferences (language + theme) move to a second row instead of
   shrinking targets or hiding anything. With the gate off the header keeps
   its single 56px row. */
@media (max-width: 576px) {
  /* The bar itself stays one flex row (menu button | controls); only the
     controls group wraps, giving two rows: company + user, then
     language + theme. */
  .app-topnav--with-theme {
    height: auto;
    padding-top: var(--space-xs);
    padding-bottom: var(--space-xs);
  }

  .app-topnav--with-theme .app-nav-right {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: var(--space-xs);
  }

  .app-topbar-prefs--with-theme {
    order: 10;
    flex-basis: 100%;
    justify-content: flex-end;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
/* IMPLEMENTATION_UI_004A: the focus-ring token (design §28.4): 2px + 2px
   offset, so it sits on the surface (6.53:1 Light / 8.38:1 Dark) even
   next to a primary button. Bootstrap's blue focus glow is removed. */
*:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Bootstrap sets outline: 0 on these at higher specificity than *:focus-visible */
.btn:focus-visible,
.button:focus-visible,
.nav-link:focus-visible,
.btn-close:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: none;
}

/* Bootstrap text utilities -> theme text roles (Bootstrap reuses one variable
   for fill and text, which cannot satisfy both on Dark surfaces). */
.text-primary { color: var(--theme-link) !important; }

.text-info { color: var(--theme-info) !important; }

.text-success { color: var(--theme-success) !important; }

.text-warning { color: var(--theme-warning) !important; }

.text-danger { color: var(--theme-error) !important; }

.text-secondary { color: var(--theme-text-muted) !important; }

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: var(--white);
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  z-index: var(--z-tooltip);
}

.skip-link:focus {
  top: 0;
}

/* ===== EMPTY / ERROR STATE PANEL (IMPLEMENTATION_020) =====
   Reusable across server-rendered EJS partials (views/partials/_state-panel.ejs)
   and client-JS-driven screens (e.g. Account Matching, Company Sync) that
   build this same markup as an innerHTML string — one shared visual system
   for "explain what happened, is it expected, what can I do next" states.
   Severity is conveyed by icon + text + color, never color alone. */
.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-xs);
  padding: var(--space-lg) var(--space-md);
  max-width: 32rem;
  margin: 0 auto;
}

.state-panel-icon {
  font-size: 1.75rem;
  margin-bottom: var(--space-xs);
}

.state-panel-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--list-text-strong);
}

.state-panel-message {
  font-size: var(--font-size-sm);
  color: var(--list-text-muted);
  line-height: 1.5;
}

.state-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  margin-top: var(--space-sm);
}

.state-panel--info    .state-panel-icon { color: var(--list-state-info); }
/* KD-68: the theme semantic tokens equal --success/--warning/--error in Light */
.state-panel--success .state-panel-icon { color: var(--theme-success); }
.state-panel--warning .state-panel-icon { color: var(--theme-warning); }
.state-panel--error   .state-panel-icon { color: var(--theme-error); }

@media (max-width: 576px) {
  .state-panel-actions {
    flex-direction: column;
    width: 100%;
  }
}

/* ===== Customer/Vendor Matching (IMPLEMENTATION_034F2) =====
   Reuses .matching-row, .matching-list, .matching-row-stage (and its
   variants), .status-badge, .manual-match- (and its variants),
   .state-panel (and its variants), .stat-row, .list-toolbar, and
   .flat-card as-is
   (see public/js/entity-matching.js) — only genuinely new, narrow classes
   live here. Rows here render 2 stages (Vista Company -> QuickBooks
   target), not Account Matching's 3 (no "BridgeConn" middle stage — that
   stage represented Account Matching's own algorithm-classification
   concept, which doesn't apply here); .matching-row-stages' flex layout
   already accommodates 2 children with no changes needed. */

.status-badge.needs-matching {
  background-color: var(--lighter);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* KD-93: warning/error colours read --theme-* tokens, whose Light values
   equal the legacy --warning(-light)/--error(-light); Dark gets its own. */
.status-badge.ambiguous,
.status-badge.conflict {
  background-color: var(--theme-warning-bg);
  color: var(--theme-warning);
  border: 1px solid var(--theme-warning);
}

.status-badge.invalid {
  background-color: var(--theme-error-bg);
  color: var(--theme-error);
  border: 1px solid var(--theme-error);
}

/* KD-93: entity rows wrap. Without it .em-banner's flex-basis: 100% and
   three action buttons squeezed the names to a few letters per line at
   tablet width and pushed the details past the card edge. The bases keep
   a Matched row on one line at desktop width; narrower rows move the
   actions and details to the next line, and the banner always gets its
   own full-width line. */
.em-row {
  flex-wrap: wrap;
}

.em-row > .matching-row-stages {
  flex: 1 1 20rem;
}

.em-row > .matching-row-actions {
  flex-wrap: wrap;
}

.em-row > .em-secondary {
  flex: 0 1 13rem;
}

.em-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-sm);
  margin-top: 4px;
  font-size: var(--font-size-xs);
  color: var(--list-text-muted);
}

.em-secondary-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.em-snapshot-box {
  margin-top: 4px;
  padding: 2px 0;
  font-size: var(--font-size-xs);
  color: var(--list-text-muted);
  font-style: italic;
}

.em-banner {
  flex-basis: 100%;
  order: 10;
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.em-banner--invalid {
  background: var(--theme-error-bg);
  color: var(--theme-error);
  border: 1px solid var(--theme-error);
}

.em-banner--conflict {
  background: var(--theme-warning-bg);
  color: var(--theme-warning);
  border: 1px solid var(--theme-warning);
}

/* KD-102: shared QuickBooks account number on a mapped row. */
.em-shared-number {
  display: inline-block;
  margin-top: var(--space-xs);
  padding: 0 var(--space-xs);
  border: 1px solid var(--theme-warning);
  border-radius: var(--radius-md);
  color: var(--theme-warning);
  background: var(--theme-warning-bg);
  font-size: var(--font-size-sm);
}

.matching-row-party-id {
  overflow-wrap: anywhere;
}

/* KD-95: Match Accounts refusal — message plus the duplicated numbers. */
.em-banner-body {
  min-width: 0;
  flex: 1 1 auto;
}

.em-banner-text {
  margin: 0;
}

.em-banner-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-sm);
  margin: var(--space-xs) 0 0;
  padding: 0;
  list-style: none;
}

.em-banner-list code {
  color: inherit;
  background: transparent;
  overflow-wrap: anywhere;
}

/* KD-93: the target list sits inside a dialog; it follows the dialog's
   tokens rather than the global .dropdown-menu (white in both themes). */
.em-target-list {
  background: var(--surface-elevated);
  border-color: var(--theme-border);
  box-shadow: none;
  margin-top: var(--space-sm);
}

.em-target-status:not(:empty) {
  margin-top: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--theme-text-muted);
}

.em-target-option {
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  border-bottom-color: var(--theme-border);
  white-space: normal; /* Bootstrap's .dropdown-item is nowrap: long names ran past the list edge */
  overflow-wrap: anywhere;
}

/* KD-93: icon-only clear button beside the target search, scoped like
   #clearQBSearch: the app-wide .btn padding and the <=768px full-width
   .btn rule pushed it onto its own line under the search box. */
#emTargetSearchClear {
  padding: var(--space-sm) var(--space-md);
  flex: 0 0 auto;
  width: auto;
}

.em-target-option:hover,
.em-target-option:focus {
  background: var(--selected-bg);
  padding-left: 0.9rem;
}

.em-target-option:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.em-target-option[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.em-target-option-name {
  font-weight: var(--font-weight-semibold);
  color: var(--theme-text);
}

.em-target-option-meta {
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
}

.em-connection-banner {
  margin-bottom: var(--space-md);
}

/* A class, not an inline style, so .stat-row's own
   @media (max-width: 900px) { grid-template-columns: 1fr; } rule can still
   win at mobile widths — an inline style attribute's specificity beats any
   class-based media-query rule and silently defeats it (confirmed via a
   live Playwright screenshot at 390px, where an earlier inline-style
   version of this rule left 3 stat tiles squeezed into one row instead of
   stacking). */
.em-stat-row-3 {
  grid-template-columns: repeat(3, 1fr);
}

.em-readonly-note {
  font-size: var(--font-size-xs);
  color: var(--list-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.em-scope-note {
  font-size: var(--font-size-xs);
  color: var(--list-text-muted);
  margin: 0 0 var(--space-md);
}

.em-modal-party {
  background: var(--modal-panel-bg);
  border: 1px solid var(--list-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
}

.em-modal-party-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

@media (max-width: 640px) {
  .em-target-selector-modal .modal-dialog,
  .em-confirm-modal .modal-dialog {
    margin: var(--space-sm);
  }

  .em-row > .em-secondary {
    flex-basis: 100%;
  }
}


/* ============================================================
   IMPLEMENTATION_042A (promoted from sync-manager.css by IMPLEMENTATION_044) — shared mobile error/issue cards. A real, specific user
   complaint: even with the 768px column-hiding above, the remaining
   Status/Transaction/Reason/Actions columns still force horizontal
   scrolling on a true mobile viewport (390px) — an inconvenient scrollbar
   for reviewing operational error data. Below 640px, the table itself is
   hidden and a card list (same fetched data, same fields, same actions —
   no new capability) takes over. GL/Invoice/Credit Memo Sync Errors each
   share this one card component (`.sync-error-cards`/`.sync-error-card*`)
   rather than three separate mobile layouts, even though each JS file
   builds its own cards from its own already-fetched row shape. See
   public/js/gl-sync-errors.js / invoice-sync-errors.js /
   credit-memo-errors.js's own renderCard()-equivalent functions. */
.sync-error-cards {
  display: none;
}

@media (max-width: 640px) {
  .sync-error-table-wrap {
    display: none;
  }

  .sync-error-cards {
    display: block;
    padding: var(--space-sm) var(--space-md) var(--space-md);
  }
}

.sync-error-card {
  border: 1px solid var(--list-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  background: var(--list-surface);
}

.sync-error-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.sync-error-card-title {
  font-weight: var(--font-weight-semibold);
  color: var(--list-text-strong);
  word-break: break-word;
}

.sync-error-card-timestamp {
  font-size: var(--font-size-xs);
  color: var(--theme-text-muted);
  white-space: nowrap;
}

.sync-error-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--font-size-sm);
}

.sync-error-card-row {
  display: flex;
  gap: var(--space-sm);
}

.sync-error-card-label {
  color: var(--list-text-muted);
  flex: 0 0 auto;
  min-width: 84px;
}

.sync-error-card-value {
  color: var(--list-text-strong);
  word-break: break-word;
}

.sync-error-card-reason {
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--list-border);
  font-size: var(--font-size-sm);
  color: var(--list-text-strong);
  word-break: break-word;
  white-space: normal;
}

.sync-error-card-actions {
  margin-top: var(--space-sm);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.sync-error-card-empty,
.sync-error-card-load-error {
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  color: var(--list-text-muted);
}


/* ============================================================
   IMPLEMENTATION_046: shared filter-toolbar controls (.si-pill /
   .si-filter-group / .si-select-label / .si-select) and page states
   (.si-state / .si-empty-icon / .si-error-icon / .si-empty-title),
   PROMOTED here from sync-issues.css (044) — the Sync Run History page
   uses the same components and does not load that stylesheet. Same
   promotion path as the flat-card system and the mobile error cards.
   Do not reintroduce page-scoped duplicates. */
.si-filter-group {
  display: inline-flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.si-pill {
  border: 1px solid var(--list-border);
  background: var(--list-surface);
  color: var(--list-text-muted);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.si-pill:hover { background: var(--list-row-alt); color: var(--list-text-strong); }

.si-pill--active {
  background: var(--list-info-bg);
  border-color: var(--list-state-info);
  color: var(--list-state-info);
  font-weight: var(--font-weight-semibold);
}

.si-select-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--list-text-muted);
  margin: 0;
}

.si-select {
  border: 1px solid var(--list-border);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  font-size: var(--font-size-sm);
  color: var(--list-text-strong);
  background: var(--list-surface);
}


/* States */
.si-state {
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  color: var(--list-text-muted);
}

.si-empty-icon { font-size: 2rem; color: var(--theme-success); display: block; margin-bottom: var(--space-sm); }
.si-error-icon { font-size: 2rem; color: var(--theme-error); display: block; margin-bottom: var(--space-sm); }
.si-empty-title { font-size: var(--font-size-base); color: var(--list-text-strong); margin: 0 0 var(--space-sm); }

/* ────────────────────────────────────────────────────────────────────────
   IMPLEMENTATION_048 — global data-list standard (promoted primitives).
   The BridgeConn operational data-list contract's shared pieces live
   here: .data-list-toolbar (the filter/search row every operational list
   uses — consolidated from the byte-identical .si-toolbar/.srh-toolbar
   page copies) and the 042B sortable-header family (.bc-sortable-th /
   .bc-th-sort-btn — promoted from sync-manager.css when Company Sync
   became its second consumer). Page CSS must not redeclare these.
   ──────────────────────────────────────────────────────────────────── */

.data-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-lg);
  margin-bottom: var(--space-sm);
}

.bc-sortable-th {
  white-space: nowrap;
}

.bc-th-sort-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.bc-th-sort-btn .fa-sort {
  opacity: 0.4;
}

.bc-sortable-th--active .bc-th-sort-btn {
  color: var(--list-sorted);
}

/* KD-69 (UI-005B), design §12/§28.7: numeric and amount columns align right;
   cells use the data font with tabular figures. Class hook only — no logic. */
.table th.bc-num,
.table td.bc-num {
  text-align: right;
}

.table td.bc-num {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* KD-69: an expanded ("selected") Run History run — design §28.7 selected row:
   --selected-bg plus a 3px --selected-indicator bar, never fill alone. Driven
   by the existing aria-expanded state; no JS change. */
.srh-table tr:has(+ .srh-detail-tr:not([hidden])) > td,
.srh-table .srh-detail-tr:not([hidden]) > td {
  background-color: var(--selected-bg);
}

.srh-table tr:has(+ .srh-detail-tr:not([hidden])) > td:first-child,
.srh-table .srh-detail-tr:not([hidden]) > td:first-child {
  box-shadow: inset 3px 0 0 var(--selected-indicator);
}

.sync-error-card:has([data-srh-card-toggle][aria-expanded="true"]) {
  border-left: 3px solid var(--selected-indicator);
  background: var(--selected-bg);
}

/* KD-69: on phones a list that shows only a state row (loading, empty, error,
   reconnect — one full-width colspan cell) drops its header and minimum width,
   so the message is readable without horizontal scrolling. */
@media (max-width: 640px) {
  .table-responsive table:has(> tbody > tr:only-child > td[colspan]:only-child) {
    min-width: 0;
    width: 100%;
  }

  .table-responsive table:has(> tbody > tr:only-child > td[colspan]:only-child) > thead {
    display: none;
  }

  .table-responsive table > tbody > tr:only-child > td[colspan]:only-child {
    white-space: normal;
  }
}

/* IMPLEMENTATION_048D: the shared enhancer's no-results recovery action
   (rendered next to common.noSearchResults inside the table body). */
.bc-clear-search { margin-left: var(--space-sm); }

/* ────────────────────────────────────────────────────────────────────────
   IMPLEMENTATION_048B — canonical pagination additions. The base
   vocabulary above (.pagination-container/-info/-controls/-button
   [.active/:disabled], .page-size-selector/-select, .pagination-ellipsis)
   IS the global visual contract; these rules add the shared nav wrapper
   and the ONE global mobile pattern: numbered buttons collapse to a
   compact "current / total" indicator at ≤640px on every surface. */

.pagination-nav { display: inline-flex; }

.pagination-compact {
  display: none;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--list-text-secondary);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .pagination-number { display: none !important; }
  .pagination-compact { display: inline-flex; }
}
