/* Stripe-Inspired Bootstrap Overrides for TastyTrade Tracker */
:root {
  --tt-primary: #635BFF;
  --tt-primary-dark: #4B44C2;
  --tt-primary-light: #857DFF;
  --tt-secondary: #0A2540;
  --tt-secondary-light: #1D3E5F;
  --tt-accent: #00D4FF;
  --tt-surface: #FFFFFF;
  --tt-container: #F6F9FC;
  --tt-container-dark: #E6EBF1;
  --tt-text-primary: #1A1F36;
  --tt-text-secondary: #697386;
  --tt-text-disabled: #A5AFBD;
  --tt-border-neutral: #E6EBF1;
  --tt-border-focus: #635BFF;
  --tt-success: #32D583;
  --tt-info: #3E7BFA;
  --tt-warning: #FFC107;
  --tt-error: #FF4757;
  --tt-success-light: #E3F9EF;
  --tt-info-light: #EBF2FF;
  --tt-warning-light: #FFF8E6;
  --tt-error-light: #FFEBEE;
  --tt-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --tt-font-size-xs: 0.75rem;
  --tt-font-size-sm: 0.875rem;
  --tt-font-size-md: 1rem;
  --tt-font-size-lg: 1.125rem;
  --tt-font-size-xl: 1.25rem;
  --tt-font-size-2xl: 1.5rem;
  --tt-font-size-3xl: 1.875rem;
  --tt-font-size-4xl: 2.25rem;
  --tt-font-weight-normal: 400;
  --tt-font-weight-medium: 500;
  --tt-font-weight-semibold: 600;
  --tt-font-weight-bold: 700;
  --tt-line-height-tight: 1.2;
  --tt-line-height-normal: 1.5;
  --tt-line-height-loose: 1.8;
  --tt-space-1: 0.25rem;
  --tt-space-2: 0.5rem;
  --tt-space-3: 0.75rem;
  --tt-space-4: 1rem;
  --tt-space-5: 1.5rem;
  --tt-space-6: 2rem;
  --tt-space-7: 2.5rem;
  --tt-space-8: 3rem;
  --tt-space-9: 4rem;
  --tt-space-10: 5rem;
  --tt-radius-sm: 4px;
  --tt-radius-md: 8px;
  --tt-radius-lg: 12px;
  --tt-radius-full: 9999px;
  --tt-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --tt-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --tt-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --tt-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Story 57.6 — distribution color roles (design contract §10): the
     percentile band track visuals theme via these three tokens only.
     fill = the nested middle-68% band; mid = median line / accent;
     tail = the wide muted middle-95% band. Teal-theme values land with
     the 57.13 teal-in-Settings wiring (teal dist-mid: #1f8a8a). */
  --tt-dist-fill: rgba(99, 91, 255, 0.28);
  --tt-dist-mid: var(--tt-primary);
  --tt-dist-tail: rgba(105, 115, 134, 0.16);
}

/* ============================================================
   STORY 29.16 — DARK MODE TOKENS
   Activated when <html data-theme="dark"> is set by the inline
   pre-paint script in base.html / base_minimal.html. Palette
   derived from the landing-page --brand-* system so authenticated
   pages feel consistent with the public site users see at signup.
   ============================================================ */
[data-theme="dark"] {
  /* Surfaces */
  --tt-surface: #14141B;
  --tt-container: #0A0A0F;
  --tt-container-dark: #1A1A24;

  /* Text */
  --tt-text-primary: #F1F5F9;
  --tt-text-secondary: #94A3B8;
  --tt-text-disabled: #64748B;

  /* Borders */
  --tt-border-neutral: rgba(255, 255, 255, 0.08);
  --tt-border-focus: #635BFF;

  /* Semantic — brightened for AA contrast on dark bg */
  --tt-success: #10B981;
  --tt-info: #60A5FA;
  --tt-warning: #FBBF24;
  --tt-error: #F87171;

  /* Semantic backgrounds — low-opacity tints */
  --tt-success-light: rgba(16, 185, 129, 0.12);
  --tt-info-light: rgba(96, 165, 250, 0.12);
  --tt-warning-light: rgba(251, 191, 36, 0.12);
  --tt-error-light: rgba(248, 113, 113, 0.12);

  /* Shadows — deeper for dark bg */
  --tt-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --tt-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --tt-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --tt-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.3);

  /* Story 57.6 — distribution color roles (dark): accent brightens to the
     mockup's dark accent (--tt-primary-light) for contrast on dark bg. */
  --tt-dist-fill: rgba(133, 125, 255, 0.32);
  --tt-dist-mid: var(--tt-primary-light);
  --tt-dist-tail: rgba(148, 163, 184, 0.18);
}

/* ============================================================
   EPIC 63 (Story 63.2) — ONE BRAND
   Every rule from here down to the dark-mode body rule is scoped under
   html[data-design="new"], which every app root template (base.html,
   base_minimal.html, transactions_standalone.html) sets as a fixed
   attribute since Story 63.11 removed the old design and the switch.
   Light = light-palette.md v2 (approved 2026-10-15); dark = the E2
   tokens in docs/design/tokens.md. Story 63.11 deleted the retired
   third theme's token block. The :root and [data-theme="dark"] blocks above stay:
   the public landing (apps/public/.../base_public.html) links this
   file with no data-design attribute and renders from them.

   The brand family is self-hosted (v1.7.2, OFL: static/fonts/geist/OFL.txt)
   and declared here once. A browser fetches a face only when a rule uses
   the family, and only the scoped --tt-font-family below does, so a
   page with no data-design attribute (the landing) downloads nothing new. The relative url() is served
   as written: the manifest storage is inert on Django 5.2 (no
   staticfiles.json); should it ever run, Django rewrites url() itself.
   ============================================================ */
@font-face {
  font-family: 'Geist';
  src: url('../fonts/geist/Geist-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('../fonts/geist/Geist-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('../fonts/geist/Geist-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('../fonts/geist/GeistMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('../fonts/geist/GeistMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* Light palette v2 — the new design's default (no data-theme, or
   data-theme="light"). Specificity (0,1,1) beats :root and
   [data-theme="x"] (0,1,0). */
html[data-design="new"] {
  /* Accent: one blue family. --tt-accent-text is the ONLY accent for
     small text (labels, eyebrows, links, outline-button text); the raw
     fill #2563EB is 4.06:1 on black (tokens.md) and 4.19:1 on #E2E8F0
     (measured). */
  --tt-primary: #2563EB;
  --tt-primary-dark: #1D4ED8;
  --tt-primary-light: #7DA2F7;
  --tt-secondary: #0F172A;
  --tt-secondary-light: #334155;
  --tt-accent: #2563EB;
  --tt-accent-text: #1D4ED8;

  /* Surfaces: navy bar, slate page ground, white panels with a visible
     border and shadow so panels read as separate windows (CAP-2). */
  --tt-surface: #FFFFFF;
  --tt-container: #E2E8F0;
  --tt-container-dark: #F1F5F9;
  --tt-quiet-bg: #E2E8F0;
  --tt-divider: #E2E8F0;
  --tt-tile-bg: #EFF4FF;
  --tt-tile-border: #BFD3FE;
  --tt-card-accent: #2563EB;

  /* Text */
  --tt-text-primary: #0F172A;
  --tt-text-secondary: #334155;
  --tt-text-disabled: #475569;

  /* Borders */
  --tt-border-neutral: #CBD5E1;
  --tt-border-focus: #2563EB;

  /* Semantic. Gain TEXT is #065F46, not the palette's #047857: measured
     4.45:1 on the #E2E8F0 page ground (AA needs 4.5); recorded before ->
     after in light-palette.md "Measured (Story 63.2)". The gain / loss
     BARS keep the palette fills. Warning: the palette is silent; amber-800
     is 5.75:1 on the page ground. */
  --tt-success: #065F46;
  --tt-success-fill: #059669;
  --tt-info: #1D4ED8;
  --tt-warning: #92400E;
  --tt-error: #B91C1C;
  --tt-error-fill: #DC2626;
  /* Epic 63 fix-5: the Sync button state fills (rows 1-2). Amber fill for
     stale (market closed); --tt-on-fill is the white ink on blue / red. */
  --tt-warning-fill: #F59E0B;
  --tt-on-fill: #FFFFFF;
  --tt-success-light: #ECFDF5;
  --tt-info-light: #EFF4FF;
  --tt-warning-light: #FFFBEB;
  --tt-error-light: #FEF2F2;

  /* Top bar and footer: navy in light, black in dark. */
  --tt-nav-bg: #0F172A;
  --tt-nav-text: #94A3B8;
  --tt-nav-text-active: #F1F5F9;
  --tt-nav-hover: rgba(255,255,255,.08);
  --tt-nav-brand: #7DA2F7;
  /* Epic 63 stitch-1: defined here so the token exists in both new-design
     blocks (spec); 6.45:1 on #0F172A, but no light surface paints it today
     (phones in light use --tt-error; the desktop / tablet Log Out is
     unchanged). The dark block's value is the red Log Out on the phone. */
  --tt-nav-danger: #F87171;

  /* Type (tokens.md): Geist, Geist Mono for numbers (pages opt in). */
  --tt-font-family: Geist, ui-sans-serif, system-ui, sans-serif;
  --tt-font-mono: 'Geist Mono', ui-monospace, monospace;
  --tt-font-size-xs: 0.75rem;
  --tt-font-size-sm: 0.875rem;
  --tt-font-size-md: 1rem;
  --tt-font-size-lg: 1.125rem;
  --tt-font-size-xl: 1.25rem;
  --tt-font-size-2xl: 1.5rem;
  --tt-font-size-3xl: 1.875rem;
  --tt-font-size-4xl: 2.25rem;
  --tt-font-weight-normal: 400;
  --tt-font-weight-medium: 500;
  --tt-font-weight-semibold: 600;
  --tt-font-weight-bold: 700;
  --tt-line-height-tight: 1.2;
  --tt-line-height-normal: 1.5;
  --tt-line-height-loose: 1.8;

  /* Spacing (unchanged scale) */
  --tt-space-1: 0.25rem;
  --tt-space-2: 0.5rem;
  --tt-space-3: 0.75rem;
  --tt-space-4: 1rem;
  --tt-space-5: 1.5rem;
  --tt-space-6: 2rem;
  --tt-space-7: 2.5rem;
  --tt-space-8: 3rem;
  --tt-space-9: 4rem;
  --tt-space-10: 5rem;

  /* Radius (tokens.md): cards 16px; sm / md unchanged */
  --tt-radius-sm: 4px;
  --tt-radius-md: 8px;
  --tt-radius-lg: 16px;
  --tt-radius-full: 9999px;

  /* Shadow: the palette's card shadow, one value for every step (no
     glow, no hover lift). */
  --tt-shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.06);
  --tt-shadow-md: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.06);
  --tt-shadow-lg: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.06);
  --tt-shadow-xl: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.06);

  /* Story 57.6 distribution roles on the blue family */
  --tt-dist-fill: rgba(37,99,235,.28);
  --tt-dist-mid: var(--tt-primary);
  --tt-dist-tail: rgba(51,65,85,.16);

  /* Categorical chart palette (Brian 2026-10-17, "A"; supersedes the
     2026-10-16 eight slots): seven slots in this order, brand blue first,
     no two blues side by side, none that reads as the P&L gain or loss
     colour. Violet (slot 5) is the one purple-band colour allowed, and only
     as a chart series, legend dot or swatch. Validated with the dataviz
     validate_palette.js on the card surface (#FFFFFF), adjacent pairs, ALL
     CHECKS PASS. A chart with more series folds its smallest into one
     "Other" slice or labels lines directly. */
  --tt-chart-1: #2563EB;
  --tt-chart-2: #D97706;
  --tt-chart-3: #0891B2;
  --tt-chart-4: #DB2777;
  --tt-chart-5: #9333EA;
  --tt-chart-6: #A16207;
  --tt-chart-7: #0284C7;
  /* Named chart roles are aliases into the palette, never new hues. The
     lifecycle chart's legs take slots 2-3, so Roll and Adjustment take the
     slots no leg uses (4 and 7). */
  --tt-chart-roll: var(--tt-chart-4);
  --tt-chart-adjustment: var(--tt-chart-7);

  /* Bootstrap 5.1.3 bridge: the --bs-* root variables that exist in
     5.1.3 (body, .text-*, .bg-* read them) re-pointed at the tokens.
     --bs-link-color / --bs-card-bg do not exist in 5.1.3; the hard-coded
     rules get the scoped overrides further down. */
  --bs-font-sans-serif: var(--tt-font-family);
  --bs-font-monospace: var(--tt-font-mono);
  --bs-body-font-family: var(--tt-font-family);
  --bs-body-bg: var(--tt-container);
  --bs-body-color: var(--tt-text-primary);
  --bs-primary-rgb: 37, 99, 235;
  --bs-success-rgb: 6, 95, 70;
  --bs-danger-rgb: 185, 28, 28;
  --bs-warning-rgb: 146, 64, 14;
  --bs-info-rgb: 29, 78, 216;
}

/* Dark: the E2 tokens (docs/design/tokens.md), black page, #1F1F1F
   panels with a hairline, no shadows. Specificity (0,2,1) beats every
   other token block in this file. The existing [data-theme="dark"]
   component rules below still apply and read these tokens. */
html[data-design="new"][data-theme="dark"] {
  --tt-primary: #2563EB;
  --tt-primary-dark: #1D4ED8;
  --tt-primary-light: #7DA2F7;
  --tt-secondary: #334155;
  --tt-secondary-light: #475569;
  --tt-accent: #2563EB;
  --tt-accent-text: #7DA2F7;

  --tt-surface: #1F1F1F;
  --tt-container: #000000;
  --tt-container-dark: #272727;
  --tt-quiet-bg: #272727;
  --tt-divider: rgba(255,255,255,.08);
  --tt-tile-bg: #1F1F1F;
  --tt-tile-border: rgba(255,255,255,.08);
  --tt-card-accent: transparent;

  --tt-text-primary: #F1F5F9;
  --tt-text-secondary: #94A3B8;
  --tt-text-disabled: rgba(241,245,249,.62);

  --tt-border-neutral: rgba(255,255,255,.08);
  --tt-border-focus: #2563EB;

  /* Loss TEXT is #F87171 (--brand-loss-text): #EF4444 on #1F1F1F is
     4.38:1. The loss BAR keeps #EF4444. */
  --tt-success: #10B981;
  --tt-success-fill: #10B981;
  --tt-info: #7DA2F7;
  --tt-warning: #FBBF24;
  --tt-error: #F87171;
  --tt-error-fill: #EF4444;
  /* Epic 63 fix-5: the Sync button state fills (rows 1-2). Amber fill for
     stale (market closed); --tt-on-fill is the white ink on blue (dark
     stale + open red takes --tt-nav-bg ink). */
  --tt-warning-fill: #F59E0B;
  --tt-on-fill: #FFFFFF;
  --tt-success-light: rgba(16,185,129,.12);
  --tt-info-light: rgba(125,162,247,.12);
  --tt-warning-light: rgba(251,191,36,.12);
  --tt-error-light: rgba(248,113,113,.12);

  --tt-nav-bg: #000000;
  --tt-nav-text: #94A3B8;
  --tt-nav-text-active: #F1F5F9;
  --tt-nav-hover: rgba(255,255,255,.08);
  --tt-nav-brand: #7DA2F7;
  /* Epic 63 stitch-1: the red Log Out on the black menu (7.59:1 on
     #000000). */
  --tt-nav-danger: #F87171;

  --tt-font-family: Geist, ui-sans-serif, system-ui, sans-serif;
  --tt-font-mono: 'Geist Mono', ui-monospace, monospace;
  --tt-font-size-xs: 0.75rem;
  --tt-font-size-sm: 0.875rem;
  --tt-font-size-md: 1rem;
  --tt-font-size-lg: 1.125rem;
  --tt-font-size-xl: 1.25rem;
  --tt-font-size-2xl: 1.5rem;
  --tt-font-size-3xl: 1.875rem;
  --tt-font-size-4xl: 2.25rem;
  --tt-font-weight-normal: 400;
  --tt-font-weight-medium: 500;
  --tt-font-weight-semibold: 600;
  --tt-font-weight-bold: 700;
  --tt-line-height-tight: 1.2;
  --tt-line-height-normal: 1.5;
  --tt-line-height-loose: 1.8;

  --tt-space-1: 0.25rem;
  --tt-space-2: 0.5rem;
  --tt-space-3: 0.75rem;
  --tt-space-4: 1rem;
  --tt-space-5: 1.5rem;
  --tt-space-6: 2rem;
  --tt-space-7: 2.5rem;
  --tt-space-8: 3rem;
  --tt-space-9: 4rem;
  --tt-space-10: 5rem;

  --tt-radius-sm: 4px;
  --tt-radius-md: 8px;
  --tt-radius-lg: 16px;
  --tt-radius-full: 9999px;

  /* Dark cards are hairline-only (tokens.md: surfaces step by lightness) */
  --tt-shadow-sm: none;
  --tt-shadow-md: none;
  --tt-shadow-lg: none;
  --tt-shadow-xl: none;

  --tt-dist-fill: rgba(125,162,247,.32);
  --tt-dist-mid: var(--tt-accent-text);
  --tt-dist-tail: rgba(148,163,184,.18);

  /* The same seven hues on the dark card (#1F1F1F); only slot 6 (gold)
     is lifted. Validated the same way, ALL CHECKS PASS. */
  --tt-chart-1: #2563EB;
  --tt-chart-2: #D97706;
  --tt-chart-3: #0891B2;
  --tt-chart-4: #DB2777;
  --tt-chart-5: #9333EA;
  --tt-chart-6: #B98A08;
  --tt-chart-7: #0284C7;
  --tt-chart-roll: var(--tt-chart-4);
  --tt-chart-adjustment: var(--tt-chart-7);

  --bs-success-rgb: 16, 185, 129;
  --bs-danger-rgb: 248, 113, 113;
  --bs-warning-rgb: 251, 191, 36;
  --bs-info-rgb: 125, 162, 247;
}

/* Bootstrap 5.1.3 hard-codes these (a, .text-muted,
   .form-check-input:checked, .bg-light, .bg-white, .border*): one scoped
   override each, mirroring the [data-theme="dark"] utility block below.
   html[data-design="new"] .x is (0,2,1), one above [data-theme="dark"] .x.
   The link rule keeps Bootstrap's own (0,0,1) via :where(), so a class
   rule (.btn-primary, .dropdown-item, .nav-link) still beats it exactly as
   it beats Bootstrap's a {}; it wins over that rule by source order. */
:where(html[data-design="new"]) a {
  color: var(--tt-accent-text);
}
:where(html[data-design="new"]) a:hover,
:where(html[data-design="new"]) a:focus {
  color: var(--tt-accent-text);
}
html[data-design="new"] .text-muted {
  color: var(--tt-text-disabled) !important;
}
html[data-design="new"] .text-primary {
  color: var(--tt-accent-text) !important;
}
html[data-design="new"] .form-check-input:checked {
  background-color: var(--tt-primary);
  border-color: var(--tt-primary);
}
html[data-design="new"] .bg-light {
  background-color: var(--tt-container) !important;
}
html[data-design="new"] .bg-white {
  background-color: var(--tt-surface) !important;
}
html[data-design="new"] .border,
html[data-design="new"] .border-top,
html[data-design="new"] .border-end,
html[data-design="new"] .border-bottom,
html[data-design="new"] .border-start {
  border-color: var(--tt-border-neutral) !important;
}

/* Shared chrome: top bar and footer on the nav tokens. */
html[data-design="new"] .stripe-navbar,
html[data-design="new"] .navbar {
  background: var(--tt-nav-bg) !important;
  border-bottom-color: var(--tt-nav-hover);
  box-shadow: none;
}
html[data-design="new"] .navbar .nav-link {
  color: var(--tt-nav-text) !important;
}
html[data-design="new"] .navbar .nav-link:hover,
html[data-design="new"] .navbar .nav-link:focus,
html[data-design="new"] .navbar .nav-link.active {
  color: var(--tt-nav-text-active) !important;
  background-color: var(--tt-nav-hover) !important;
}
html[data-design="new"] .navbar-brand {
  color: var(--tt-nav-brand) !important;
}
html[data-design="new"] .navbar-brand:hover {
  color: var(--tt-nav-text-active) !important;
}
html[data-design="new"] .navbar-toggler-icon:before,
html[data-design="new"] .navbar-toggler-icon:after,
html[data-design="new"] .navbar-toggler-icon div {
  background: var(--tt-nav-text-active);
}
/* The footer carries .bg-light (an !important Bootstrap background), so
   the .footer.bg-light selector (0,3,1) is what wins. */
html[data-design="new"] .footer,
html[data-design="new"] .footer.bg-light {
  background: var(--tt-nav-bg) !important;
  border-top-color: var(--tt-nav-hover);
  color: var(--tt-nav-text);
  box-shadow: none;
}
html[data-design="new"] .footer .text-muted {
  color: var(--tt-nav-text) !important;
}
html[data-design="new"] .footer a {
  color: var(--tt-nav-brand);
}

/* Buttons: outline text on the accent TEXT token; the sync button's
   cyan gradient end becomes flat blue (no gradients, mood.md). */
html[data-design="new"] .btn-outline-primary {
  color: var(--tt-accent-text);
  border-color: var(--tt-primary);
}
html[data-design="new"] .btn-outline-primary.stripe-action {
  color: var(--tt-accent-text) !important;
}
html[data-design="new"] .btn-outline-primary:hover,
html[data-design="new"] .btn-outline-primary:focus {
  background-color: var(--tt-primary);
  color: #fff;
}
html[data-design="new"] .btn-outline-primary.stripe-action:hover,
html[data-design="new"] .btn-outline-primary.stripe-action:focus {
  background: var(--tt-quiet-bg);
  color: var(--tt-accent-text) !important;
}
html[data-design="new"] .btn-sync,
html[data-design="new"] .btn-primary.sync-now {
  background: var(--tt-primary);
}
html[data-design="new"] .btn-sync:hover,
html[data-design="new"] .btn-primary.sync-now:hover {
  background: var(--tt-primary-dark);
}

/* Cards: no hover lift (tokens.md motion table; 59.4 D12). */
html[data-design="new"] .card:hover,
html[data-design="new"] .tt-stat-card:hover {
  box-shadow: var(--tt-shadow-sm);
}

/* Bootstrap 5.1.3 hard-coded blues (#0d6efd / #86b7fe) and the two
   Stripe-purple literals that still applied in the new design. Visited
   links add no specificity via :where(), so they cannot outrank
   component classes such as .btn-primary. */
:where(html[data-design="new"]) :where(a:visited) {
  color: var(--tt-accent-text);
}
html[data-design="new"] .btn-link {
  color: var(--tt-accent-text);
}
html[data-design="new"] .page-link {
  color: var(--tt-accent-text);
}
html[data-design="new"] .page-item.active .page-link {
  background-color: var(--tt-primary);
  border-color: var(--tt-primary);
  color: #fff;
}
html[data-design="new"] .progress-bar {
  background-color: var(--tt-primary);
}
html[data-design="new"] .form-control:focus {
  box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}
html[data-design="new"] .form-select:focus,
html[data-design="new"] .form-check-input:focus {
  border-color: var(--tt-border-focus);
  box-shadow: 0 0 0 .25rem rgba(37,99,235,.25);
}
html[data-design="new"] .btn-outline-primary:active,
html[data-design="new"] .btn-outline-primary.active {
  background-color: var(--tt-primary-dark);
  border-color: var(--tt-primary-dark);
  color: #fff;
}
html[data-design="new"] #sync-progress .alert {
  background-color: var(--tt-info-light);
}

/* The legacy dark visited-link selector also applies to button anchors.
   Keep their foreground on the filled-button contract in either mode. */
html[data-design="new"] a.btn-primary:visited {
  color: #fff;
}

/* Sync states use semantic colours as fills, not as text on dark surfaces.
   Dark semantic fills therefore pair with dark ink (including on hover). */
html[data-design="new"][data-theme="dark"] #navbar-sync-button[data-sync-status="synced"],
html[data-design="new"][data-theme="dark"] #navbar-sync-button[data-sync-status="stale"] {
  color: var(--tt-container) !important;
}

/* Mobile menu: the collapsed navbar opens as a panel on the nav colours,
   not on the card surface (its links are --tt-nav-text). */
@media (max-width: 991.98px) {
  html[data-design="new"] .navbar-collapse {
    background: var(--tt-nav-bg);
    box-shadow: none;
    border: 1px solid var(--tt-nav-hover);
  }
}


[data-theme="dark"] body {
  background-color: var(--tt-container);
  color: var(--tt-text-primary);
}

/* Base Styles */
body {
  font-family: var(--tt-font-family);
  color: var(--tt-text-primary);
  background-color: var(--tt-container);
  line-height: var(--tt-line-height-normal);
}

.tt-bg-container {
  background-color: var(--tt-container);
}

/* Main Content Area */
main.container {
  max-width: 1200px;
  padding: var(--tt-space-6) var(--tt-space-4);
}

/* Fix for container-fluid to use full width */
main.container-fluid,
.container-fluid {
  max-width: 100% !important;
  width: 100% !important;
  padding-left: var(--tt-space-4);
  padding-right: var(--tt-space-4);
}

/* Typography Classes */
.tt-heading-1 {
  font-size: var(--tt-font-size-3xl);
  font-weight: var(--tt-font-weight-bold);
  line-height: var(--tt-line-height-tight);
  color: var(--tt-text-primary);
  margin-bottom: 1.5rem;
}

.tt-heading-2 {
  font-size: var(--tt-font-size-2xl);
  font-weight: var(--tt-font-weight-semibold);
  line-height: var(--tt-line-height-tight);
  color: var(--tt-text-primary);
  margin-bottom: 1.25rem;
}

.tt-heading-3 {
  font-size: var(--tt-font-size-xl);
  font-weight: var(--tt-font-weight-semibold);
  line-height: var(--tt-line-height-tight);
  color: var(--tt-text-primary);
  margin-bottom: 1rem;
}

.tt-text-primary {
  color: var(--tt-text-primary);
}

.tt-text-secondary {
  color: var(--tt-text-secondary);
}

/* Stat Cards */
.tt-stat-card {
  background-color: var(--tt-surface);
  border-radius: var(--tt-radius-lg);
  padding: var(--tt-space-5);
  box-shadow: var(--tt-shadow-sm);
  transition: box-shadow 0.15s ease;
  border: 1px solid var(--tt-border-neutral);
}

.tt-stat-card:hover {
  box-shadow: var(--tt-shadow-md);
}

.tt-stat-card-label {
  font-size: var(--tt-font-size-sm);
  color: var(--tt-text-secondary);
  margin-bottom: var(--tt-space-2);
  font-weight: var(--tt-font-weight-medium);
}

.tt-stat-card-value {
  font-size: var(--tt-font-size-2xl);
  font-weight: var(--tt-font-weight-bold);
  color: var(--tt-text-primary);
  margin-bottom: var(--tt-space-2);
}

.tt-stat-card-change {
  font-size: var(--tt-font-size-sm);
  font-weight: var(--tt-font-weight-medium);
  color: var(--tt-text-secondary);
}

.tt-positive {
  color: var(--tt-success);
}

.tt-negative {
  color: var(--tt-error);
}

/* Data Table Container */
.tt-data-table-container {
  background-color: var(--tt-surface);
  border-radius: var(--tt-radius-lg);
  box-shadow: var(--tt-shadow-sm);
  overflow: hidden;
  border: 1px solid var(--tt-border-neutral);
}

.tt-data-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--tt-space-4) var(--tt-space-5);
  border-bottom: 1px solid var(--tt-border-neutral);
  background-color: var(--tt-primary);
  color: white;
}

.tt-data-table-header h3 {
  color: white;
  margin: 0;
}

/* Buttons */
.btn-primary {
  background-color: var(--tt-primary);
  border-color: var(--tt-primary);
  border-radius: var(--tt-radius-md);
  font-weight: var(--tt-font-weight-medium);
  padding: 0.625rem 1.25rem;
  transition: all 0.15s ease;
  box-shadow: var(--tt-shadow-sm);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--tt-primary-dark);
  border-color: var(--tt-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--tt-shadow-md);
}
.btn-secondary {
  background-color: var(--tt-surface);
  border-color: var(--tt-border-neutral);
  color: var(--tt-text-primary);
  border-radius: var(--tt-radius-md);
  font-weight: var(--tt-font-weight-medium);
  padding: 0.625rem 1.25rem;
  transition: all 0.15s ease;
}
.btn-secondary:hover, .btn-secondary:focus {
  background-color: var(--tt-container);
  border-color: var(--tt-border-neutral);
  color: var(--tt-text-primary);
}
.btn-outline-primary {
  color: var(--tt-primary);
  border-color: var(--tt-primary);
  border-radius: var(--tt-radius-md);
  font-weight: var(--tt-font-weight-medium);
  padding: 0.625rem 1.25rem;
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
  background-color: var(--tt-primary);
  color: white;
}

/* Cards */
.card {
  border: 1px solid var(--tt-border-neutral);
  border-radius: var(--tt-radius-lg);
  box-shadow: var(--tt-shadow-sm);
  transition: box-shadow 0.15s ease;
}
.card:hover {
  box-shadow: var(--tt-shadow-md);
}
.card-header {
  background-color: var(--tt-surface);
  border-bottom: 1px solid var(--tt-border-neutral);
  padding: var(--tt-space-4) var(--tt-space-5);
}
.card-body {
  padding: var(--tt-space-5);
}
.card-footer {
  background-color: var(--tt-container);
  border-top: 1px solid var(--tt-border-neutral);
  padding: var(--tt-space-4) var(--tt-space-5);
}

/* Forms */
.form-control {
  border: 1px solid var(--tt-border-neutral);
  border-radius: var(--tt-radius-md);
  padding: 0.625rem 0.75rem;
  font-size: var(--tt-font-size-md);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.form-control:focus {
  border-color: var(--tt-border-focus);
  box-shadow: 0 0 0 4px rgba(99, 91, 255, 0.15);
}
.form-label {
  font-size: var(--tt-font-size-sm);
  font-weight: var(--tt-font-weight-medium);
  color: var(--tt-text-secondary);
  margin-bottom: var(--tt-space-2);
}
.form-text {
  font-size: var(--tt-font-size-sm);
  color: var(--tt-text-secondary);
  margin-top: var(--tt-space-2);
}

/* Alerts */
.alert {
  border: none;
  border-radius: var(--tt-radius-md);
  padding: var(--tt-space-4) var(--tt-space-5);
}
.alert-success {
  background-color: var(--tt-success-light);
  color: var(--tt-success);
}
.alert-info {
  background-color: var(--tt-info-light);
  color: var(--tt-info);
}
.alert-warning {
  background-color: var(--tt-warning-light);
  color: var(--tt-warning);
}
.alert-danger {
  background-color: var(--tt-error-light);
  color: var(--tt-error);
}

/* Badges */
.badge {
  font-weight: var(--tt-font-weight-medium);
  padding: 0.35em 0.65em;
  border-radius: var(--tt-radius-full);
}
.badge-primary {
  background-color: var(--tt-primary);
}
.badge-success {
  background-color: var(--tt-success);
}
.badge-info {
  background-color: var(--tt-info);
}
.badge-warning {
  background-color: var(--tt-warning);
  color: var(--tt-text-primary);
}
.badge-danger {
  background-color: var(--tt-error);
}

/* Tables */
.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: var(--tt-container);
  --bs-table-striped-color: var(--tt-text-primary);
  --bs-table-active-bg: var(--tt-container-dark);
  --bs-table-active-color: var(--tt-text-primary);
  --bs-table-hover-bg: var(--tt-container);
  --bs-table-hover-color: var(--tt-text-primary);
  border-color: var(--tt-border-neutral);
}

/* --- Stripe-Inspired Navbar (Stripe.com accurate) --- */
.stripe-navbar, .navbar {
  background: var(--tt-surface) !important;
  box-shadow: 0 2px 8px 0 rgba(99,91,255,0.04);
  border-bottom: 1px solid var(--tt-border-neutral);
  font-family: var(--tt-font-family);
  min-height: 64px;
  padding: 0 var(--tt-space-5);
  z-index: 1000;
}

.navbar-brand {
  font-size: var(--tt-font-size-xl);
  font-weight: var(--tt-font-weight-bold);
  color: var(--tt-primary) !important;
  letter-spacing: -0.5px;
  padding: 0;
  margin-right: var(--tt-space-8);
  transition: color 0.18s;
  text-decoration: none;
  flex-shrink: 0;
}
.navbar-brand:hover {
  color: var(--tt-primary-dark) !important;
  text-decoration: none;
}

/* Ensure container-fluid uses flexbox properly */
.navbar .container-fluid {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
}

/* Force horizontal navbar layout */
.navbar-nav {
  flex-direction: row !important;
  display: flex !important;
  gap: var(--tt-space-1);
  align-items: center;
}

.navbar-nav .nav-item {
  display: inline-block !important;
  float: none !important;
  margin-right: var(--tt-space-2);
}

.navbar-collapse {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.navbar-nav .nav-link {
  color: var(--tt-text-secondary) !important;
  font-weight: var(--tt-font-weight-medium);
  font-size: var(--tt-font-size-md);
  padding: var(--tt-space-3) var(--tt-space-4);
  border-radius: var(--tt-radius-md);
  transition: all 0.15s ease;
  text-decoration: none;
  margin: 0 var(--tt-space-1);
  white-space: nowrap;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus,
.navbar-nav .nav-link.active {
  color: var(--tt-text-primary) !important;
  background-color: var(--tt-container) !important;
  text-decoration: none;
}

.navbar-nav .dropdown-toggle::after {
  margin-left: var(--tt-space-2);
}

/* Override Bootstrap default navbar behavior with high specificity */
.navbar.navbar-expand-lg .navbar-nav {
  flex-direction: row !important;
  display: flex !important;
}

.navbar.navbar-expand-lg .navbar-collapse {
  display: flex !important;
  flex-basis: auto !important;
  width: auto !important;
}

.navbar.stripe-navbar .navbar-nav {
  flex-direction: row !important;
  display: flex !important;
}

.navbar.stripe-navbar .navbar-collapse {
  display: flex !important;
  flex-direction: row !important;
}

/* Ensure navbar stays horizontal on desktop */
@media (min-width: 992px) {
  .navbar-nav {
    flex-direction: row !important;
  }
  
  .navbar-collapse {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  .navbar-expand-lg .navbar-nav {
    flex-direction: row !important;
  }
  
  .navbar-expand-lg .navbar-collapse {
    display: flex !important;
    flex-basis: auto !important;
  }
  
  /* Ensure dropdown works properly on desktop */
  .dropdown-menu {
    display: none !important;
  }
  
  .dropdown:hover .dropdown-menu,
  .dropdown.show .dropdown-menu {
    display: block !important;
  }
}

/* --- Stripe-Inspired Action Buttons --- */
.btn-primary.stripe-action,
.btn.stripe-action {
  background: var(--tt-primary);
  color: #fff !important;
  font-weight: var(--tt-font-weight-medium);
  font-size: var(--tt-font-size-sm);
  border-radius: var(--tt-radius-md);
  box-shadow: var(--tt-shadow-sm);
  padding: var(--tt-space-3) var(--tt-space-5);
  border: 1px solid var(--tt-primary);
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary.stripe-action:hover,
.btn.stripe-action:hover {
  background: var(--tt-primary-dark);
  border-color: var(--tt-primary-dark);
  box-shadow: var(--tt-shadow-md);
  transform: translateY(-1px);
  color: #fff !important;
}

.btn-outline-primary.stripe-action {
  background: transparent;
  color: var(--tt-primary) !important;
  font-weight: var(--tt-font-weight-medium);
  font-size: var(--tt-font-size-sm);
  border-radius: var(--tt-radius-md);
  box-shadow: none;
  padding: var(--tt-space-3) var(--tt-space-5);
  border: 1px solid var(--tt-border-neutral);
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-outline-primary.stripe-action:hover,
.btn-outline-primary.stripe-action:focus {
  background: var(--tt-container);
  color: var(--tt-primary) !important;
  border-color: var(--tt-border-neutral);
  text-decoration: none;
}

/* --- Footer --- */
.footer {
  background: var(--tt-surface);
  border-top: 1.5px solid var(--tt-border-neutral);
  box-shadow: 0 -2px 8px 0 rgba(99,91,255,0.03);
  font-family: var(--tt-font-family);
  font-size: var(--tt-font-size-sm);
  color: var(--tt-text-secondary);
  padding: var(--tt-space-6) 0 var(--tt-space-4) 0;
}
.footer .text-muted {
  color: var(--tt-text-secondary) !important;
}

/* --- Stripe-Inspired Sync Button --- */
.btn-sync, .btn-primary.sync-now {
  background: linear-gradient(90deg, var(--tt-primary) 60%, var(--tt-accent) 100%);
  color: #fff !important;
  font-weight: var(--tt-font-weight-bold);
  font-size: var(--tt-font-size-lg);
  border-radius: var(--tt-radius-full);
  box-shadow: var(--tt-shadow-md);
  padding: 0.75rem 2.25rem;
  border: none;
  letter-spacing: 0.5px;
  transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
}
.btn-sync:hover, .btn-primary.sync-now:hover {
  background: linear-gradient(90deg, var(--tt-primary-dark) 60%, var(--tt-accent) 100%);
  box-shadow: var(--tt-shadow-lg);
  transform: translateY(-2px) scale(1.03);
}

/* --- Dropdown Menu --- */
.dropdown-menu {
  background: var(--tt-surface);
  border: 1px solid var(--tt-border-neutral);
  border-radius: var(--tt-radius-lg);
  box-shadow: var(--tt-shadow-lg);
  min-width: 180px;
  padding: var(--tt-space-2) 0;
  margin-top: var(--tt-space-1);
  font-family: var(--tt-font-family);
  display: none !important; /* Hide by default */
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
}

/* Show dropdown on hover or when clicked */
.dropdown:hover .dropdown-menu,
.dropdown.show .dropdown-menu {
  display: block !important;
}

.dropdown-item {
  color: var(--tt-text-primary);
  font-size: var(--tt-font-size-sm);
  font-weight: var(--tt-font-weight-normal);
  padding: var(--tt-space-3) var(--tt-space-4);
  transition: all 0.15s ease;
  text-decoration: none;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--tt-container);
  color: var(--tt-text-primary);
  text-decoration: none;
}

/* Ensure dropdown positioning */
.dropdown {
  position: relative;
}

/* --- Hamburger & Mobile Nav --- */
.navbar-toggler {
  border: none;
  background: none;
  outline: none;
  box-shadow: none;
}
.navbar-toggler-icon {
  background-image: none;
  width: 1.5em;
  height: 1.5em;
  position: relative;
  display: inline-block;
}
.navbar-toggler-icon:before, .navbar-toggler-icon:after, .navbar-toggler-icon div {
  content: '';
  display: block;
  background: var(--tt-text-primary);
  height: 3px;
  border-radius: 2px;
  margin: 5px 0;
  transition: all 0.2s;
}
.navbar-toggler-icon:before { margin-top: 0; }
.navbar-toggler-icon:after { margin-bottom: 0; }

@media (max-width: 991.98px) {
  /* Story 57.13 (AC #4e): anchor the mobile dropdown BELOW the navbar.
     Without a `top`, the absolute panel resolved to its in-flow position
     INSIDE the header row, so when open it covered the brand and the
     toggler itself (the toggler could never close it). Scoped mobile-only. */
  .navbar.stripe-navbar { position: relative; }

  .navbar-collapse {
    background: var(--tt-surface);
    box-shadow: 0 8px 32px 0 rgba(99,91,255,0.08);
    border-radius: var(--tt-radius-lg);
    margin-top: var(--tt-space-2);
    padding: var(--tt-space-4);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 999;
  }

  /* Story 57.13 (AC #4e): restore Bootstrap collapse semantics on mobile.
     The desktop rules above force `display: flex !important` on
     .navbar-collapse, which also defeated Bootstrap's `.collapse` hiding
     below the 991.98px breakpoint — the nav panel rendered permanently
     expanded over the page on every mobile view. Scoped INSIDE this media
     query (equal specificity, later in file wins), so desktop behavior is
     byte-identical: closed until the .navbar-toggler adds .show/.collapsing,
     then the existing overlay styles apply. */
  .navbar-collapse:not(.show):not(.collapsing) {
    display: none !important;
  }
  
  /* Stack navbar items vertically on mobile */
  .navbar-nav {
    flex-direction: column !important;
    gap: var(--tt-space-2);
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 1.5rem;
    font-size: var(--tt-font-size-lg);
    margin: 0;
  }
  
  /* Mobile dropdown behavior */
  .dropdown-menu {
    position: static !important;
    display: block !important;
    box-shadow: none;
    border: none;
    background: var(--tt-container);
    margin-left: var(--tt-space-4);
  }
  
  .d-flex.align-items-center {
    margin-top: var(--tt-space-3);
    justify-content: flex-start;
  }
  
  /* Stack stat cards on mobile */
  .tt-stat-card {
    margin-bottom: var(--tt-space-4);
  }
  
  /* Adjust button sizes on mobile */
  .btn.stripe-action {
    font-size: var(--tt-font-size-sm);
    padding: var(--tt-space-2) var(--tt-space-4);
  }
  
  /* Adjust heading sizes on mobile */
  .tt-heading-1 {
    font-size: var(--tt-font-size-2xl);
  }
  
  .tt-heading-2 {
    font-size: var(--tt-font-size-xl);
  }
  
  .tt-heading-3 {
    font-size: var(--tt-font-size-lg);
  }
}

/* Small mobile devices */
@media (max-width: 576px) {
  main.container {
    padding: var(--tt-space-4) var(--tt-space-3);
  }
  
  .tt-stat-card-value {
    font-size: var(--tt-font-size-xl);
  }
  
  .navbar-brand {
    font-size: var(--tt-font-size-lg);
  }
  
  .d-flex.flex-wrap.gap-3 {
    gap: var(--tt-space-2) !important;
  }
  
  .btn.stripe-action {
    width: 100%;
    margin-bottom: var(--tt-space-2);
  }
}

/* Sync Loading States */
#sync-progress {
  transition: all 0.3s ease-in-out;
}

#sync-progress .alert {
  border: 1px solid var(--tt-info);
  background-color: rgba(99, 91, 255, 0.05);
  border-radius: var(--tt-radius-md);
}

#sync-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#sync-loading .spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

#sync-progress .spinner-border-sm {
  width: 1.25rem;
  height: 1.25rem;
  border-width: 0.125rem;
  color: var(--tt-primary);
}

#sync-progress-text {
  color: var(--tt-text-secondary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  transition: opacity 0.2s ease-in-out;
}

/* Smooth transitions for loading states */
.btn .spinner-border {
  animation: spin 1s linear infinite;
}

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

/* Progress animation */
#sync-progress-text {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Navbar Sync Button States */
#navbar-sync-button[data-sync-status="never"] {
  background-color: var(--tt-primary);
  color: white;
  border-color: var(--tt-primary);
}

#navbar-sync-button[data-sync-status="synced"] {
  background-color: var(--tt-success);
  color: white;
  border-color: var(--tt-success);
}

#navbar-sync-button[data-sync-status="synced"]:hover {
  background-color: #198754;
  border-color: #198754;
}

#navbar-sync-button[data-sync-status="syncing"] {
  background-color: var(--tt-primary);
  color: white;
  border-color: var(--tt-primary);
}

#navbar-sync-button[data-sync-status="stale"] {
  background-color: var(--tt-warning);
  color: white;
  border-color: var(--tt-warning);
}

#navbar-sync-button[data-sync-status="stale"]:hover {
  background-color: #e0a800;
  border-color: #e0a800;
}

#navbar-sync-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Market hours indicator */
.market-status {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-left: 0.5rem;
}

.market-open {
  color: var(--tt-success);
}

.market-closed {
  color: var(--tt-text-secondary);
}

/* Enhanced button states with urgency */
#navbar-sync-button[data-sync-status="stale"][data-market="open"] {
  background-color: #dc3545; /* More urgent red during market hours */
  border-color: #dc3545;
  animation: pulse-urgent 2s infinite;
}

#navbar-sync-button[data-sync-status="stale"][data-market="closed"] {
  background-color: var(--tt-warning); /* Less urgent orange after hours */
  border-color: var(--tt-warning);
}

@keyframes pulse-urgent {
  0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Global Sync Status Box */
#global-sync-status {
  transition: all 0.3s ease-in-out;
}

#global-sync-status .alert {
  border-radius: var(--tt-radius-md);
  border: 1px solid;
  margin-bottom: 0;
}

#global-sync-status .alert-primary {
  background-color: rgba(99, 91, 255, 0.1);
  border-color: var(--tt-primary);
  color: var(--tt-primary);
}

#global-sync-status .alert-success {
  background-color: rgba(25, 135, 84, 0.1);
  border-color: var(--tt-success);
  color: var(--tt-success);
}

#global-sync-status .alert-warning {
  background-color: rgba(255, 193, 7, 0.1);
  border-color: var(--tt-warning);
  color: #856404;
}

#global-sync-status .alert-danger {
  background-color: rgba(220, 53, 69, 0.1);
  border-color: #dc3545;
  color: #721c24;
}

#sync-status-icon {
  min-width: 1.5rem;
  text-align: center;
}

#sync-status-title {
  margin-bottom: 0;
  line-height: 1.4;
}

#sync-status-detail {
  opacity: 0.8;
  line-height: 1.3;
}

/* ============================================================
   STORY 29.16 — DARK MODE BOOTSTRAP UTILITY OVERRIDES
   Bootstrap utility classes (.bg-light, .bg-white, .text-muted)
   are used in many templates and have hardcoded light values.
   These overrides flip them when dark mode is active.
   ============================================================ */
[data-theme="dark"] .bg-light {
  background-color: var(--tt-container) !important;
}

[data-theme="dark"] .bg-white {
  background-color: var(--tt-surface) !important;
}

[data-theme="dark"] .text-muted {
  color: var(--tt-text-secondary) !important;
}

[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-end,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start {
  border-color: var(--tt-border-neutral) !important;
}

/* Footer uses .bg-light — covered above. Adjust text-muted explicitly. */
[data-theme="dark"] .footer .text-muted {
  color: var(--tt-text-secondary) !important;
}

/* Global sync status box: explicit color overrides for warning/danger
   alerts (their light-mode rules use hardcoded text colors). */
[data-theme="dark"] #global-sync-status .alert-warning {
  color: var(--tt-warning);
}

[data-theme="dark"] #global-sync-status .alert-danger {
  color: var(--tt-error);
}

/* Bootstrap form-check inputs render as a literal white square in dark
   mode without this; force the bg to surface so the checkmark is visible. */
[data-theme="dark"] .form-check-input {
  background-color: var(--tt-container-dark);
  border-color: var(--tt-border-neutral);
}

[data-theme="dark"] .form-check-input:checked {
  background-color: var(--tt-primary);
  border-color: var(--tt-primary);
}

/* Form controls (inputs, selects, textareas) need explicit dark surfaces */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: var(--tt-container-dark);
  color: var(--tt-text-primary);
  border-color: var(--tt-border-neutral);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: var(--tt-container-dark);
  color: var(--tt-text-primary);
  border-color: var(--tt-border-focus);
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--tt-text-disabled);
}

/* ============================================================
   STORY 29.16 — DARK MODE BOOTSTRAP COMPONENT FIXES
   Bootstrap's .card defaults to white via --bs-card-bg. The
   tokenized .card-header rule we wrote earlier doesn't help
   because .card itself sets the body background. Override
   the Bootstrap CSS vars under [data-theme="dark"] so every
   card body, table, breadcrumb, etc. picks up the dark surface
   without per-template changes.
   ============================================================ */
[data-theme="dark"] {
  --bs-body-bg: var(--tt-container);
  --bs-body-color: var(--tt-text-primary);
  --bs-card-bg: var(--tt-surface);
  --bs-card-color: var(--tt-text-primary);
  --bs-card-border-color: var(--tt-border-neutral);
  --bs-card-cap-bg: var(--tt-surface);
  --bs-secondary-bg: var(--tt-container-dark);
  --bs-tertiary-bg: var(--tt-container-dark);
  --bs-border-color: var(--tt-border-neutral);
  --bs-emphasis-color: var(--tt-text-primary);
  --bs-secondary-color: var(--tt-text-secondary);
  --bs-tertiary-color: var(--tt-text-disabled);
  --bs-link-color: var(--tt-primary-light);
  --bs-link-hover-color: var(--tt-primary);
  --bs-heading-color: var(--tt-text-primary);
}

/* Belt-and-suspenders: explicit .card body in case Bootstrap
   variables aren't in use (older bootstrap or overridden CSS) */
[data-theme="dark"] .card,
[data-theme="dark"] .card-body {
  background-color: var(--tt-surface);
  color: var(--tt-text-primary);
}

/* Modal content + body */
[data-theme="dark"] .modal-content {
  background-color: var(--tt-surface);
  color: var(--tt-text-primary);
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: var(--tt-border-neutral);
}

/* Tables: bg + striping + borders + headers */
[data-theme="dark"] .table {
  --bs-table-bg: var(--tt-surface);
  --bs-table-color: var(--tt-text-primary);
  --bs-table-striped-bg: var(--tt-container-dark);
  --bs-table-striped-color: var(--tt-text-primary);
  --bs-table-hover-bg: var(--tt-container-dark);
  --bs-table-hover-color: var(--tt-text-primary);
  --bs-table-border-color: var(--tt-border-neutral);
  color: var(--tt-text-primary);
}
[data-theme="dark"] .table thead th {
  background-color: var(--tt-container-dark);
  color: var(--tt-text-secondary);
  border-color: var(--tt-border-neutral);
}
[data-theme="dark"] .table tbody td {
  border-color: var(--tt-border-neutral);
  color: var(--tt-text-primary);
}

/* List groups */
[data-theme="dark"] .list-group-item {
  background-color: var(--tt-surface);
  color: var(--tt-text-primary);
  border-color: var(--tt-border-neutral);
}

/* Breadcrumbs */
[data-theme="dark"] .breadcrumb {
  background-color: transparent;
}
[data-theme="dark"] .breadcrumb-item,
[data-theme="dark"] .breadcrumb-item a {
  color: var(--tt-text-secondary);
}
[data-theme="dark"] .breadcrumb-item.active {
  color: var(--tt-text-primary);
}

/* Pagination */
[data-theme="dark"] .page-link {
  background-color: var(--tt-surface);
  color: var(--tt-text-primary);
  border-color: var(--tt-border-neutral);
}
[data-theme="dark"] .page-link:hover {
  background-color: var(--tt-container-dark);
  color: var(--tt-text-primary);
  border-color: var(--tt-border-neutral);
}
[data-theme="dark"] .page-item.disabled .page-link {
  background-color: var(--tt-container);
  color: var(--tt-text-disabled);
  border-color: var(--tt-border-neutral);
}

/* Dropdowns: belt-and-suspenders for items + dividers + visited link colors */
[data-theme="dark"] .dropdown-menu {
  background-color: var(--tt-surface);
  border-color: var(--tt-border-neutral);
}
[data-theme="dark"] .dropdown-item {
  color: var(--tt-text-primary);
  background-color: transparent;
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  background-color: var(--tt-container-dark);
  color: var(--tt-text-primary);
}
[data-theme="dark"] .dropdown-item:visited {
  color: var(--tt-text-primary);
}
/* Force visited <a> in dropdowns to keep contrast */
[data-theme="dark"] .dropdown-menu a:visited {
  color: var(--tt-text-primary);
}
[data-theme="dark"] .dropdown-divider,
[data-theme="dark"] hr.dropdown-divider {
  border-color: var(--tt-border-neutral);
  background-color: transparent;
}
/* Delete Account uses .text-danger inside dropdown — keep it red but readable */
[data-theme="dark"] .dropdown-item.text-danger {
  color: var(--tt-error) !important;
}
[data-theme="dark"] .dropdown-item.text-danger:hover,
[data-theme="dark"] .dropdown-item.text-danger:focus {
  background-color: rgba(248, 113, 113, 0.12);
  color: var(--tt-error) !important;
}

/* Generic <a> visited fix anywhere on dark pages */
[data-theme="dark"] a:visited {
  color: var(--tt-primary-light);
}

/* Form select: native arrow + dropdown options */
[data-theme="dark"] select.form-select,
[data-theme="dark"] select.form-control {
  background-color: var(--tt-container-dark);
  color: var(--tt-text-primary);
  border-color: var(--tt-border-neutral);
}
[data-theme="dark"] select.form-select option,
[data-theme="dark"] select.form-control option {
  background-color: var(--tt-container-dark);
  color: var(--tt-text-primary);
}

/* Heading text color */
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
  color: var(--tt-text-primary);
}

/* Bootstrap utility text colors that are dark-on-dark by default */
[data-theme="dark"] .text-dark {
  color: var(--tt-text-primary) !important;
}

/* Stripe-inspired tt-* container surfaces (dashboard cards) */
[data-theme="dark"] .tt-stat-card,
[data-theme="dark"] .tt-data-table-container,
[data-theme="dark"] .tt-chart-card {
  background-color: var(--tt-surface);
  color: var(--tt-text-primary);
}

/* Inline-styled card headers in settings.html use solid hex backgrounds
   with white text — they remain readable. No override needed. */

/* ============================================================
   STORY 29.16 — DARK MODE TEXT ELEMENT FALLBACKS
   Bootstrap 5.1.3 (what this project loads) does NOT use
   --bs-emphasis-color; variable overrides above are no-ops in
   that version. Add explicit rules for common text elements
   so <strong>, <label>, <p>, list items, etc. inherit the
   proper foreground color under dark mode.
   ============================================================ */
[data-theme="dark"] label,
[data-theme="dark"] .form-check-label,
[data-theme="dark"] .form-check-label strong,
[data-theme="dark"] .form-label strong,
[data-theme="dark"] label strong,
[data-theme="dark"] .card-body,
[data-theme="dark"] .card-body strong,
[data-theme="dark"] .card-body p,
[data-theme="dark"] .card-body li,
[data-theme="dark"] .card-body h1,
[data-theme="dark"] .card-body h2,
[data-theme="dark"] .card-body h3,
[data-theme="dark"] .card-body h4,
[data-theme="dark"] .card-body h5,
[data-theme="dark"] .card-body h6,
[data-theme="dark"] p,
[data-theme="dark"] li,
[data-theme="dark"] strong,
[data-theme="dark"] b {
  color: var(--tt-text-primary);
}

/* Small/secondary text stays muted but readable */
[data-theme="dark"] small,
[data-theme="dark"] .small,
[data-theme="dark"] .text-muted,
[data-theme="dark"] .form-text {
  color: var(--tt-text-secondary) !important;
}

/* ============================================================
   STORY 29.16 — home.html INLINE DASHBOARD STYLES
   The dashboard template has its own <style> block with
   hardcoded #ffffff, #E3E8EF, #F6F8FA, #1A1D24 values for
   .dashboard-section, .section-header, .section-title,
   .section-content, etc. Override them in dark mode.
   ============================================================ */
[data-theme="dark"] .dashboard-section {
  background: var(--tt-surface) !important;
  border-color: var(--tt-border-neutral) !important;
}
[data-theme="dark"] .section-header {
  background-color: var(--tt-container-dark) !important;
  border-bottom-color: var(--tt-border-neutral) !important;
}
[data-theme="dark"] .section-title {
  color: var(--tt-text-primary) !important;
}
[data-theme="dark"] .section-subtitle {
  color: var(--tt-text-secondary) !important;
}
[data-theme="dark"] .section-content {
  background-color: var(--tt-surface) !important;
  color: var(--tt-text-primary) !important;
}
[data-theme="dark"] .allocation-chart-title,
[data-theme="dark"] .allocation-chart-panel {
  color: var(--tt-text-primary) !important;
}
[data-theme="dark"] .allocation-chart-panel {
  background-color: var(--tt-surface) !important;
}
[data-theme="dark"] .chart-legend,
[data-theme="dark"] .legend-header-row,
[data-theme="dark"] .legend-header-spacer {
  color: var(--tt-text-primary) !important;
}

/* Recent Activity list on dashboard */
[data-theme="dark"] .activity-item,
[data-theme="dark"] .activity-list {
  background-color: var(--tt-surface) !important;
  color: var(--tt-text-primary) !important;
  border-color: var(--tt-border-neutral) !important;
}

/* Any section-content child that renders table/list content */
[data-theme="dark"] .section-content table,
[data-theme="dark"] .section-content tr,
[data-theme="dark"] .section-content td,
[data-theme="dark"] .section-content th {
  background-color: transparent !important;
  color: var(--tt-text-primary) !important;
  border-color: var(--tt-border-neutral) !important;
}
