/* Custom CSS for FO Shiny App */
/* DIAGNOSTIC: If you can see a red border on the body, this CSS is loading */
/* Version: 2026-02-20-10-25-NUCLEAR-FIX */

/* ============================================================
   TOOLTIP THEME STYLES (consolidated from app_ui.R inline CSS)
   ============================================================ */

/* Consistent tooltip styling for both regular tooltips and DataTable tooltips */
.tooltip-inner,
.dataTables_wrapper .tooltip-inner {
  background-color: rgba(0, 0, 0, 0.9);
  color: white;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  max-width: 220px;
}

/* ============================================================
   DARK MODE TOOLTIP STYLING - ULTRA-AGGRESSIVE FIX
   ============================================================ */
/* IMPORTANT: Tooltips are appended as CHILDREN of body, not siblings!
   Bootstrap creates: <body><div class="tooltip">...</div></body>
   So we use descendant selector: body.dark-mode .tooltip
   NOT sibling selector: body.dark-mode ~ .tooltip (doesn't work!)
*/

/* ULTRA-SPECIFIC: When body has dark-mode class, style ALL tooltip-inner elements */
/* Using multiple selectors to catch all possible cases */
body.dark-mode .tooltip .tooltip-inner,
html body.dark-mode .tooltip .tooltip-inner,
body.dark-mode > .tooltip .tooltip-inner,
body.dark-mode .tooltip-inner,
body.dark-mode .dataTables_wrapper .tooltip .tooltip-inner {
  background-color: rgba(255, 255, 255, 0.95) !important;
  color: #000000 !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

/* Also support dark-mode-tooltip class added by JavaScript (fallback) */
html .dark-mode-tooltip .tooltip-inner,
.dark-mode-tooltip .tooltip-inner,
.tooltip.dark-mode-tooltip .tooltip-inner {
  background-color: rgba(255, 255, 255, 0.95) !important;
  color: #000000 !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

/* Tooltip arrow consistency */
.tooltip.bs-tooltip-top .arrow::before,
.dataTables_wrapper .tooltip.bs-tooltip-top .arrow::before {
  border-top-color: rgba(0, 0, 0, 0.9);
}

/* Dark mode arrows - ULTRA-AGGRESSIVE with multiple selectors */
body.dark-mode .tooltip.bs-tooltip-top .arrow::before,
html body.dark-mode .tooltip.bs-tooltip-top .arrow::before,
body.dark-mode > .tooltip.bs-tooltip-top .arrow::before,
html .dark-mode-tooltip.bs-tooltip-top .arrow::before,
.dark-mode-tooltip.bs-tooltip-top .arrow::before {
  border-top-color: rgba(255, 255, 255, 0.95) !important;
}

/* Other arrow directions */
.tooltip.bs-tooltip-bottom .arrow::before {
  border-bottom-color: rgba(0, 0, 0, 0.9);
}

body.dark-mode .tooltip.bs-tooltip-bottom .arrow::before,
html body.dark-mode .tooltip.bs-tooltip-bottom .arrow::before,
body.dark-mode > .tooltip.bs-tooltip-bottom .arrow::before,
html .dark-mode-tooltip.bs-tooltip-bottom .arrow::before,
.dark-mode-tooltip.bs-tooltip-bottom .arrow::before {
  border-bottom-color: rgba(255, 255, 255, 0.95) !important;
}

.tooltip.bs-tooltip-left .arrow::before {
  border-left-color: rgba(0, 0, 0, 0.9);
}

body.dark-mode .tooltip.bs-tooltip-left .arrow::before,
html body.dark-mode .tooltip.bs-tooltip-left .arrow::before,
body.dark-mode > .tooltip.bs-tooltip-left .arrow::before,
html .dark-mode-tooltip.bs-tooltip-left .arrow::before,
.dark-mode-tooltip.bs-tooltip-left .arrow::before {
  border-left-color: rgba(255, 255, 255, 0.95) !important;
}

.tooltip.bs-tooltip-right .arrow::before {
  border-right-color: rgba(0, 0, 0, 0.9);
}

body.dark-mode .tooltip.bs-tooltip-right .arrow::before,
html body.dark-mode .tooltip.bs-tooltip-right .arrow::before,
body.dark-mode > .tooltip.bs-tooltip-right .arrow::before,
html .dark-mode-tooltip.bs-tooltip-right .arrow::before,
.dark-mode-tooltip.bs-tooltip-right .arrow::before {
  border-right-color: rgba(255, 255, 255, 0.95) !important;
}

/* ============================================================
   END TOOLTIP THEME STYLES
   ============================================================ */

/* Fix selectize dropdown arrow visibility in dark mode */
/* Only change the arrow color to white in dark mode, keep all other styling as default */

/* Dark mode - make the dropdown arrow white */
body.dark-mode .selectize-control .selectize-input::after {
  border-color: rgba(255, 255, 255, 0.8) transparent transparent transparent !important;
}

/* Pastel-green highlighting for "Add X" options in selectize dropdown.
 * Uses the unified `--fo-asset` pastel-green (release `5.0.0.9063`,
 * Items 1 + 2 palette unification) so the affirmative-action colour
 * reads the same as the Dashboard pastel triad app-wide. */
/* Light mode - apply to dropdown options */
.selectize-dropdown .selectize-add-option {
  color: var(--fo-asset) !important;
  font-weight: 500;
}

/* Light mode - apply to selected item */
.selectize-control .selectize-input .selectize-add-option {
  color: var(--fo-asset) !important;
  font-weight: 500;
}

/* Dark mode - apply to dropdown options */
body.dark-mode .selectize-dropdown .selectize-add-option {
  color: var(--fo-asset) !important;
  font-weight: 500;
}

/* Dark mode - apply to selected item */
body.dark-mode .selectize-control .selectize-input .selectize-add-option {
  color: var(--fo-asset) !important;
  font-weight: 500;
}

/* Conditional Tooltips - Simplified since JavaScript handles visibility */

/* Basic rule for tooltips - keep interactive */
body [data-toggle="tooltip"] {
  pointer-events: auto;
}

/* TOOLTIP ICON VISIBILITY CONTROL */
/* Handles two patterns:
   1. tooltip() function: <span data-toggle="tooltip"><i class="fa fa-info-circle"></i></span>
   2. DataTables: <i class="fa fa-info-circle" data-toggle="tooltip"></i>
*/

/* Hide tooltip icons when help mode is NOT active */
/* Pattern 1: Icon inside element with data-toggle */
body:not(.help-mode-active) [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) [data-toggle="tooltip"] i.fa.fa-info-circle,
body:not(.help-mode-active) span[data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) span[data-toggle="tooltip"] i.fa.fa-info-circle,
/* Pattern 2: Icon itself has data-toggle (DataTables) */
body:not(.help-mode-active) i.fa-info-circle[data-toggle="tooltip"],
body:not(.help-mode-active) i.fa.fa-info-circle[data-toggle="tooltip"],
body:not(.help-mode-active) i[class*="fa-info-circle"][data-toggle="tooltip"],
/* Pattern 3: Icons in box headers, card headers, and other containers */
body:not(.help-mode-active) .card-title [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) .card-title span[data-toggle="tooltip"],
body:not(.help-mode-active) .box-title [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) .box-title span[data-toggle="tooltip"],
body:not(.help-mode-active) h3 [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) h3 span[data-toggle="tooltip"],
body:not(.help-mode-active) h4 [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) h4 span[data-toggle="tooltip"],
/* Pattern 4: Icons in input labels and form controls */
body:not(.help-mode-active) label [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) label span[data-toggle="tooltip"],
body:not(.help-mode-active) .form-group label [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) .form-group label span[data-toggle="tooltip"],
body:not(.help-mode-active) .control-label [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) .control-label span[data-toggle="tooltip"],
body:not(.help-mode-active) .shiny-input-container label [data-toggle="tooltip"] i.fa-info-circle,
body:not(.help-mode-active) .shiny-input-container label span[data-toggle="tooltip"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  /* font-size: 0 removed - was conflicting with tooltip sizing CSS */
  width: 0 !important;
  height: 0 !important;
}

/* Hide pseudo-elements for tooltip icons when help mode is NOT active */
body:not(.help-mode-active) [data-toggle="tooltip"] i.fa-info-circle::before,
body:not(.help-mode-active) [data-toggle="tooltip"] i.fa.fa-info-circle::before,
body:not(.help-mode-active) span[data-toggle="tooltip"] i.fa-info-circle::before,
body:not(.help-mode-active) span[data-toggle="tooltip"] i.fa.fa-info-circle::before,
body:not(.help-mode-active) i.fa-info-circle[data-toggle="tooltip"]::before,
body:not(.help-mode-active) i.fa.fa-info-circle[data-toggle="tooltip"]::before,
/* Box headers and titles */
body:not(.help-mode-active) .card-title [data-toggle="tooltip"]::before,
body:not(.help-mode-active) .card-title span[data-toggle="tooltip"]::before,
body:not(.help-mode-active) .box-title [data-toggle="tooltip"]::before,
body:not(.help-mode-active) .box-title span[data-toggle="tooltip"]::before,
body:not(.help-mode-active) h3 [data-toggle="tooltip"]::before,
body:not(.help-mode-active) h3 span[data-toggle="tooltip"]::before,
body:not(.help-mode-active) h4 [data-toggle="tooltip"]::before,
body:not(.help-mode-active) h4 span[data-toggle="tooltip"]::before,
/* Labels and form controls */
body:not(.help-mode-active) label [data-toggle="tooltip"]::before,
body:not(.help-mode-active) label span[data-toggle="tooltip"] i.fa-info-circle::before,
body:not(.help-mode-active) .form-group label [data-toggle="tooltip"]::before,
body:not(.help-mode-active) .form-group label span[data-toggle="tooltip"]::before,
body:not(.help-mode-active) .control-label [data-toggle="tooltip"]::before,
body:not(.help-mode-active) .control-label span[data-toggle="tooltip"]::before,
body:not(.help-mode-active) .shiny-input-container label [data-toggle="tooltip"]::before,
body:not(.help-mode-active) .shiny-input-container label span[data-toggle="tooltip"]::before {
  content: none !important;
  display: none !important;
}

/* When help mode is OFF, hide the icon inside [data-toggle="tooltip"]
   spans -- but NEVER the parent span itself. The parent may legitimately
   contain user-visible text (e.g. the summary page wraps "Assets",
   "Liabilities", etc. in tt_span() which renders
   <span data-toggle="tooltip">Assets<i class="fa fa-info-circle"></i></span>).
   Hiding the span erased that text; we only hide the icon child. */
body:not(.help-mode-active) span[data-toggle="tooltip"] > i.fa-info-circle,
body:not(.help-mode-active) span[data-toggle="tooltip"] > i.fa.fa-info-circle {
  display: none !important;
  visibility: hidden !important;
}

/* SHOW tooltip icons when help mode IS active */
/* Pattern 1: Icon inside element with data-toggle */
body.help-mode-active [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active [data-toggle="tooltip"] i.fa.fa-info-circle,
body.help-mode-active span[data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active span[data-toggle="tooltip"] i.fa.fa-info-circle,
/* Pattern 2: Icon itself has data-toggle (DataTables) */
body.help-mode-active i.fa-info-circle[data-toggle="tooltip"],
body.help-mode-active i.fa.fa-info-circle[data-toggle="tooltip"],
body.help-mode-active i[class*="fa-info-circle"][data-toggle="tooltip"],
/* Pattern 3: Icons in box headers and titles */
body.help-mode-active .card-title [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active .card-title span[data-toggle="tooltip"],
body.help-mode-active .box-title [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active .box-title span[data-toggle="tooltip"],
body.help-mode-active h3 [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active h3 span[data-toggle="tooltip"],
body.help-mode-active h4 [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active h4 span[data-toggle="tooltip"],
/* Pattern 4: Icons in input labels and form controls */
body.help-mode-active label [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active label span[data-toggle="tooltip"],
body.help-mode-active .form-group label [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active .form-group label span[data-toggle="tooltip"],
body.help-mode-active .control-label [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active .control-label span[data-toggle="tooltip"],
body.help-mode-active .shiny-input-container label [data-toggle="tooltip"] i.fa-info-circle,
body.help-mode-active .shiny-input-container label span[data-toggle="tooltip"] {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto !important;
  height: auto !important;
  /* CRITICAL: Add sizing properties for maximum specificity */
  font-size: 0.65em !important;
  vertical-align: super !important;
  position: relative !important;
  top: -0.3em !important;
  line-height: 0 !important;
  margin-left: 3px !important;
  cursor: help !important;
}

/* Show pseudo-elements for tooltip icons when help mode IS active */
body.help-mode-active [data-toggle="tooltip"] i.fa-info-circle::before,
body.help-mode-active [data-toggle="tooltip"] i.fa.fa-info-circle::before,
body.help-mode-active span[data-toggle="tooltip"] i.fa-info-circle::before,
body.help-mode-active span[data-toggle="tooltip"] i.fa.fa-info-circle::before,
body.help-mode-active i.fa-info-circle[data-toggle="tooltip"]::before,
body.help-mode-active i.fa.fa-info-circle[data-toggle="tooltip"]::before,
/* Box headers and titles */
body.help-mode-active .card-title [data-toggle="tooltip"]::before,
body.help-mode-active .card-title span[data-toggle="tooltip"] i.fa-info-circle::before,
body.help-mode-active .box-title [data-toggle="tooltip"]::before,
body.help-mode-active .box-title span[data-toggle="tooltip"] i.fa-info-circle::before,
body.help-mode-active h3 [data-toggle="tooltip"]::before,
body.help-mode-active h3 span[data-toggle="tooltip"] i.fa-info-circle::before,
body.help-mode-active h4 [data-toggle="tooltip"]::before,
body.help-mode-active h4 span[data-toggle="tooltip"] i.fa-info-circle::before,
/* Labels and form controls */
body.help-mode-active label [data-toggle="tooltip"]::before,
body.help-mode-active label span[data-toggle="tooltip"] i.fa-info-circle::before,
body.help-mode-active .form-group label [data-toggle="tooltip"]::before,
body.help-mode-active .form-group label span[data-toggle="tooltip"]::before,
body.help-mode-active .control-label [data-toggle="tooltip"]::before,
body.help-mode-active .control-label span[data-toggle="tooltip"]::before,
body.help-mode-active .shiny-input-container label [data-toggle="tooltip"]::before,
body.help-mode-active .shiny-input-container label span[data-toggle="tooltip"]::before {
  display: inline-block !important;
  visibility: visible !important;
}

/* Visual indicator when help mode is active */
body.help-mode-active [data-toggle="tooltip"] {
  cursor: help;
}

/* Hover effect for tooltip icons when help mode is active */
body.help-mode-active [data-toggle="tooltip"] i.fa-info-circle:hover,
body.help-mode-active [data-toggle="tooltip"] i.fa.fa-info-circle:hover {
  opacity: 0.8;
}

/* ============================================================
   TOOLTIP ICON SIZING - UNIVERSAL RULE
   ============================================================ */

/* ULTRA-AGGRESSIVE TOOLTIP ICON SIZING */
/* Using maximum CSS specificity with body prefix */
/* This MUST override any other CSS including Font Awesome defaults */

/* NUCLEAR OPTION: Target ALL fa-info-circle icons */
body i.fa-info-circle,
body i.fa.fa-info-circle {
  font-size: 0.65em !important;
  vertical-align: super !important;
  position: relative !important;
  top: -0.3em !important;
  line-height: 0 !important;
  margin-left: 3px !important;
  cursor: help !important;
}

/* Extra specificity for tooltip contexts */
body [data-toggle="tooltip"] i.fa-info-circle,
body [data-toggle="tooltip"] i.fa.fa-info-circle,
body span[data-toggle="tooltip"] i.fa-info-circle,
body span[data-toggle="tooltip"] i.fa.fa-info-circle,
body i.fa-info-circle[data-toggle="tooltip"],
body i.fa.fa-info-circle[data-toggle="tooltip"],

/* Table context with body prefix */
body table i.fa-info-circle,
body thead i.fa-info-circle,
body th i.fa-info-circle,
body td i.fa-info-circle,

/* Box/card title context with body prefix */
body .card-title i.fa-info-circle,
body .box-title i.fa-info-circle,
body .card-header i.fa-info-circle,
body h3 i.fa-info-circle,
body h4 i.fa-info-circle,

/* Label context with body prefix */
body label i.fa-info-circle,
body .form-group i.fa-info-circle,
body .control-label i.fa-info-circle,
body .shiny-input-container i.fa-info-circle {
  font-size: 0.65em !important;
  vertical-align: super !important;
  position: relative !important;
  top: -0.3em !important;
  line-height: 0 !important;
  margin-left: 3px !important;
  cursor: help !important;
}

/* ============================================================
   END TOOLTIP ICON SIZING
   ============================================================ */

/* Class used by JavaScript (not currently used but keeping for compatibility) */
.tooltip-icon-hidden {
  display: none !important;
  visibility: hidden !important;
}

/* Visual debugging indicator - only show when authenticated */
body[data-app-state="authenticated"].help-mode-active::before {
  content: "Help Mode: ON";
  position: fixed;
  bottom: 10px;
  right: 10px;
  background-color: #17a2b8;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 99999;
  opacity: 0.8;
}

body[data-app-state="authenticated"]:not(.help-mode-active)::before {
  content: "Help Mode: OFF";
  position: fixed;
  bottom: 10px;
  right: 10px;
  background-color: var(--fo-liability);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 99999;
  opacity: 0.8;
}

/* ============================================================
   TOPBAR NAVIGATION ICONS
   ============================================================ */

/* Hide bs4Dash's built-in dark-mode switch widget entirely.  We provide
   our own icon-only #fo_dark_mode_btn instead; the bs4Dash checkbox is
   still in the DOM (so input$dark_mode and click-delegation keep
   working) — it's just visually removed.  We cover both bs4Dash 2.x
   shapes: the custom-switch (#theme_switch / #dark_mode_switcher inside
   a .custom-control.custom-switch) and the [data-widget="navbar-dark-mode"]
   anchor. */
.main-header .custom-control.custom-switch:has(#theme_switch),
.main-header .custom-control.custom-switch:has(#dark_mode_switcher),
.main-header [data-widget="navbar-dark-mode"],
.main-header .dark-mode-toggle {
  display: none !important;
}
/* Fallback for browsers without :has() — hide the checkbox + its label
   and any sibling icon so nothing is visible even if the wrapper remains. */
.main-header #theme_switch,
.main-header #dark_mode_switcher,
.main-header label[for="theme_switch"],
.main-header label[for="dark_mode_switcher"],
.main-header .dark-theme-icon {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Custom dark/light mode icon (sun <-> moon). */
.fo-dark-mode-icon > i {
  font-size: 1.05rem;
  line-height: 1;
}

/* Custom help-mode icon (question-mark circle).  Dim while OFF, brightens
   while ON.  The hidden #help_switch checkbox lives inside the anchor and
   must never be visible. */
.fo-help-switch-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.fo-help-icon > i {
  font-size: 1.05rem;
  line-height: 1;
  transition: color 0.2s ease, transform 0.2s ease;
}
/* OFF state — same dim white as other topbar icons. */
.fo-help-icon > i { color: rgba(255, 255, 255, 0.85); }
/* ON state — match the teal "Help Mode: ON" bubble (#17a2b8). */
.fo-help-icon.fo-help-icon-active > i {
  color: #17a2b8;
}
.fo-help-icon.fo-help-icon-active {
  /* Keep the white nav-link colour but ensure the icon's teal shows. */
  color: white !important;
}

/* All nav-link items in the header are white when authenticated.
   AdminLTE's default navbar color (rgba(0,0,0,.5)) is invisible against
   the dark primary header background; this overrides it. */
body[data-app-state="authenticated"] .main-header .nav-link,
body[data-app-state="authenticated"] .main-header .nav-link i,
body[data-app-state="authenticated"] .main-header .nav-link svg {
  color: white !important;
}

/* Topbar navigation icon buttons */
.topbar-nav-icon {
  transition: opacity 0.2s ease;
  opacity: 0.85;
  color: white !important;
}

.topbar-nav-icon:hover {
  opacity: 1;
  text-decoration: none;
  color: white !important;
}

/* Hide topbar nav icons on pre-auth pages */
body:not([data-app-state="authenticated"]) .topbar-nav-icon {
  display: none !important;
}

/* ------------------------------------------------------------------
   bs4Dash → bslib migration: PR #4 (release 5.0.0.9004, "rc.4").

   Under the bslib outer shell (FO.bslib_shell = TRUE), the dark-mode
   toggle is `bslib::input_dark_mode()` — a `<bslib-input-dark-mode>`
   custom element with shadow DOM. The default rendering does NOT
   visually match the icon-only Contact / Help / Logout affordances
   that sit next to it in the topbar (different size, default colour,
   block-ish alignment).

   `app_ui()` wraps the custom element in
   `<span class="fo-bslib-dark-mode topbar-nav-icon">`. The
   `.topbar-nav-icon` rules above already supply the shared topbar
   icon contract (white colour, hover opacity, hide-when-unauth).
   The rules below add the bslib-specific tweaks: inline alignment so
   the toggle sits on the same baseline as the other icons, a
   consistent icon-sized footprint, and a `currentColor` hand-off so
   the bslib element inherits the white topbar colour through its
   `--bs-emphasis-color` / `color` custom properties.

   These selectors only match the bslib branch — the legacy bs4Dash
   shell is unaffected. */
.fo-bslib-dark-mode {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  line-height: 1;
}

.fo-bslib-dark-mode > bslib-input-dark-mode {
  /* Match the ~1.05rem icon size of `.fo-dark-mode-icon > i` and
     `.fo-help-icon > i` so all three topbar icons share a footprint. */
  font-size: 1.05rem;
  line-height: 1;
  /* PR follow-up — drop the explicit `#007bff` colouring. The sun /
     moon glyph now inherits `currentColor` from the surrounding
     `.topbar-nav-icon` wrapper, so it tracks the other topbar icons
     (Contact, Help, Logout) — white in dark mode, dark in light mode
     via the existing `html[data-bs-theme="light"] body[data-app-state=
     "authenticated"] .topbar-nav-icon` override block. Keep the
     bslib custom-element `--bs-*` hand-off properties bound to
     `currentColor` so the shadow-DOM SVGs continue to paint with the
     same colour as the host. */
  color: currentColor;
  --bs-emphasis-color: currentColor;
  --bs-body-color: currentColor;
  vertical-align: middle;
}

/* Legacy #help_switch slider styling removed — the checkbox is now
   visually hidden (see .fo-help-switch-hidden above) and the affordance
   is the #fo_help_mode_btn icon in the topbar. */

/* Hide sidebar menu items that are only for topbar navigation */
.topbar-only-tab {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* ============================================================
   SIDEBAR AND LAYOUT STYLES (moved from app_ui.R inline CSS)
   ============================================================ */
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active {
  background-color: #007bff !important;
  color: white !important;
}
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-treeview > .nav-item > .nav-link.active {
  background-color: rgba(0, 123, 255, 0.8) !important;
  color: white !important;
}
.sidebar-dark-primary .nav-sidebar > .nav-item.menu-open > .nav-link {
  background-color: rgba(0, 123, 255, 0.4) !important;
}
/* Hide sidebar when not logged in - dark mode */
.main-sidebar.sidebar-hidden {
  background-color: #343a40 !important;
  border-right: none !important;
}
/* Hide sidebar when not logged in - light mode */
body:not(.dark-mode) .main-sidebar.sidebar-hidden {
  background-color: #f4f6f9 !important;
}
/* Hide all sidebar content when sidebar-hidden class is present */
.main-sidebar.sidebar-hidden .brand-link,
.main-sidebar.sidebar-hidden .brand-image,
.main-sidebar.sidebar-hidden .brand-text,
.main-sidebar.sidebar-hidden .nav-sidebar {
  visibility: hidden !important;
}

/* Ensure brand-link fills the full sidebar width with no left gap */
.brand-link {
  padding-left: 0.8125rem !important;
  margin-left: 0 !important;
  left: 0 !important;
}
/* Only force 250px width when sidebar is NOT in mini-collapsed state */
body:not(.sidebar-mini) .brand-link,
body.sidebar-mini:not(.sidebar-collapse) .brand-link {
  width: 250px !important;
}

/* Landing page overlay styles */
#landing-page-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  background-color: #0b0e14;
  overflow-y: auto;
  /* Explicitly set visible state as default */
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.15s ease-in-out, visibility 0.15s ease-in-out, pointer-events 0.15s ease-in-out;
}
#landing-page-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Hide help button when landing page is visible */
#landing-page-overlay:not(.hidden) ~ * [data-widget='control-sidebar'],
body:has(#landing-page-overlay:not(.hidden)) [data-widget='control-sidebar'] {
  display: none !important;
}

/* ============================================================
   LOGIN/SIGNUP/FORGOT PASSWORD PAGE STYLES
   ============================================================ */

/* Hide card headers on login/signup/forgot-password pages */
.box.box-solid.box-primary > .card-header,
#sign_up_page_div > .card-header {
  display: none !important;
}

/* ============================================================
   WELCOME PAGE STYLES
   ============================================================ */

/* Hide card header on welcome page */
#welcome_page > .box > .card-header {
  display: none !important;
}

/* ============================================================
   SUMMARY PAGE STYLES
   ============================================================ */

#summary-summary_text { white-space: pre-wrap; }
body.dark-mode #summary-summary_text { color: white !important; }
body.dark-mode #summary-summary_text { color: white !important; }

/* Fix dark mode for DataTable */
body.dark-mode .dataTables_wrapper .dataTables_length,
body.dark-mode .dataTables_wrapper .dataTables_filter,
body.dark-mode .dataTables_wrapper .dataTables_info,
body.dark-mode .dataTables_wrapper .dataTables_paginate {
  color: white !important;
}
body.dark-mode .dataTables_wrapper .dataTables_length,
body.dark-mode .dataTables_wrapper .dataTables_filter,
body.dark-mode .dataTables_wrapper .dataTables_info,
body.dark-mode .dataTables_wrapper .dataTables_paginate {
  color: white !important;
}

/* Fix dark mode for table headers */
body.dark-mode table.dataTable thead th,
body.dark-mode table.dataTable thead td {
  color: white !important;
}
body.dark-mode table.dataTable thead th,
body.dark-mode table.dataTable thead td {
  color: white !important;
}

/* Fix dark mode for table body */
body.dark-mode table.dataTable tbody td,
body.dark-mode table.dataTable tbody td {
  color: white !important;
}

/* ============================================================
   LIGHT MODE TEXT COLORS - Ensure text visibility
   ============================================================ */

/* Light mode text colors for DataTable body cells */
body:not(.dark-mode) table.dataTable tbody td {
  color: #212529 !important;
}

/* Light mode text colors for DataTable headers */
body:not(.dark-mode) table.dataTable thead th,
body:not(.dark-mode) table.dataTable thead td {
  color: #212529 !important;
}

/* Light mode text colors for DataTable wrapper elements */
body:not(.dark-mode) .dataTables_wrapper .dataTables_length,
body:not(.dark-mode) .dataTables_wrapper .dataTables_filter,
body:not(.dark-mode) .dataTables_wrapper .dataTables_info,
body:not(.dark-mode) .dataTables_wrapper .dataTables_paginate {
  color: #212529 !important;
}

/* Fix column alignment in summary table */
#summary-summary_combined_table table.dataTable tbody td:nth-child(1) {
  text-align: left !important;
  width: auto !important;
}
#summary-summary_combined_table table.dataTable tbody td:nth-child(2) {
  text-align: left !important;
}
#summary-summary_combined_table table.dataTable tbody td:nth-child(3),
#summary-summary_combined_table table.dataTable tbody td:nth-child(4),
#summary-summary_combined_table table.dataTable tbody td:nth-child(5),
#summary-summary_combined_table table.dataTable tbody td:nth-child(6) {
  text-align: right !important;
}
#summary-summary_combined_table table.dataTable thead th:nth-child(1) {
  text-align: left !important;
  width: auto !important;
}
#summary-summary_combined_table table.dataTable thead th:nth-child(2) {
  text-align: left !important;
}
#summary-summary_combined_table table.dataTable thead th:nth-child(3),
#summary-summary_combined_table table.dataTable thead th:nth-child(4),
#summary-summary_combined_table table.dataTable thead th:nth-child(5),
#summary-summary_combined_table table.dataTable thead th:nth-child(6) {
  text-align: right !important;
}

/* Dark mode styling for reporting date selector */
body.dark-mode #summary-summary_reporting_date,
body.dark-mode #summary-summary_reporting_date {
  background-color: #343a40 !important;
  color: white !important;
  border-color: #6c757d !important;
}
body.dark-mode .selectize-input,
body.dark-mode .selectize-input {
  background-color: #343a40 !important;
  color: white !important;
  border-color: #6c757d !important;
}
body.dark-mode .selectize-dropdown,
body.dark-mode .selectize-dropdown {
  background-color: #343a40 !important;
  color: white !important;
  border-color: #6c757d !important;
}
body.dark-mode .selectize-dropdown-content .option,
body.dark-mode .selectize-dropdown-content .option {
  color: white !important;
}
body.dark-mode .selectize-dropdown-content .option.active,
body.dark-mode .selectize-dropdown-content .option:hover,
body.dark-mode .selectize-dropdown-content [data-selectable].active,
body.dark-mode .selectize-dropdown-content [data-selectable]:hover,
body.dark-mode .selectize-dropdown .active {
  background-color: #495057 !important;
  color: #ffffff !important;
}

/* Light mode text colors for selectize inputs and dropdowns */
body:not(.dark-mode) .selectize-input {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-color: #ced4da !important;
}

body:not(.dark-mode) .selectize-dropdown {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-color: #ced4da !important;
}

body:not(.dark-mode) .selectize-dropdown-content .option {
  color: #212529 !important;
}

body:not(.dark-mode) .selectize-dropdown-content .option.active,
body:not(.dark-mode) .selectize-dropdown-content .option:hover,
body:not(.dark-mode) .selectize-dropdown-content [data-selectable].active,
body:not(.dark-mode) .selectize-dropdown-content [data-selectable]:hover {
  background-color: #e9ecef !important;
  color: #212529 !important;
}

/* Light mode text colors for summary page elements */
body:not(.dark-mode) #summary-summary_text {
  color: #212529 !important;
}

body:not(.dark-mode) #summary-summary_reporting_date {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-color: #ced4da !important;
}

/* Summary page inline select styling */
.summary-text-container {
  position: relative;
  font-family: monospace;
}
.summary-inline-row {
  display: block;
  margin: 0;
  padding: 0;
}
.summary-inline-select-wrapper {
  display: inline-block;
  vertical-align: baseline;
  white-space: nowrap;
  margin: 0;
  position: relative;
}
/* Style the select input to look like monospace text */
.summary-inline-select-wrapper .selectize-input {
  font-family: monospace !important;
  font-size: 1em !important;
  padding: 0 20px 0 2px !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  display: inline-block !important;
  min-height: auto !important;
  line-height: 1.2 !important;
  vertical-align: baseline !important;
  white-space: nowrap !important;
}
.summary-inline-select-wrapper .selectize-input input {
  font-family: monospace !important;
  font-size: 1em !important;
}
.summary-inline-select-wrapper .selectize-input .item {
  line-height: 1.2 !important;
  padding: 0 !important;
}
/* Make dropdown arrow visible and positioned correctly */
.summary-inline-select-wrapper .selectize-input::after {
  content: '\25bc' !important;
  border: none !important;
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6em;
  opacity: 0.6;
}
/* Style dropdown to match */
.summary-inline-select-wrapper .selectize-dropdown {
  font-family: monospace !important;
  font-size: 0.9em !important;
}
.summary-inline-select-wrapper .selectize-dropdown .option {
  padding: 5px 8px !important;
  white-space: nowrap !important;
}
.summary-text-before,
.summary-text-after {
  display: inline;
  white-space: normal;
  font-family: monospace;
}
.summary-financial-data {
  display: block;
  white-space: pre;
  margin-top: 0;
  font-family: monospace;
}

/* Light mode text colors for summary page text elements */
body:not(.dark-mode) .summary-text-before,
body:not(.dark-mode) .summary-text-after,
body:not(.dark-mode) .summary-financial-data {
  color: #212529 !important;
}

/* Tooltip icon inside the summary inline row: keep it compact and aligned */
.summary-inline-row [data-toggle="tooltip"] i.fa-info-circle,
.summary-inline-row [data-toggle="tooltip"] i.fa.fa-info-circle,
.summary-inline-row [data-toggle="tooltip"] i[class*="fa-info-circle"],
.summary-inline-row [data-toggle="tooltip"] svg[data-icon="circle-info"] {
  font-size: 0.55em !important;
  vertical-align: middle !important;
  position: relative !important;
  top: 0 !important;
  line-height: 1 !important;
  margin-left: 3px !important;
  cursor: help !important;
}

/* ============================================================
   EXTRACTED INLINE STYLES
   ============================================================ */

/* Page centering wrapper for login/signup/forgot-password pages */
.fo-page-center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding-top: 20px;
  padding-bottom: 20px;
  overflow-y: auto;
}

/* "Back to Home" link styling. Colour consumed via --fo-link (PR
 * #12.e.4.21) — light #007bff / dark #6aa9ff (mirrors --fo-brand
 * under each theme). */
.fo-back-link {
  color: var(--fo-link);
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Centered button containers */
.fo-btn-center {
  text-align: center;
}

/* Centered button container with bottom margin (10px) */
.fo-btn-center-mb-10 {
  text-align: center;
  margin-bottom: 10px;
}

/* Centered button container with bottom margin (15px) */
.fo-btn-center-mb-15 {
  text-align: center;
  margin-bottom: 15px;
}

/* Red error messages. Colour consumed via --fo-danger (PR #12.e.4.21)
 * — theme-invariant #EF4444 (drift vs the pre-PR `red` literal
 * #FF0000 is intentional: --fo-danger is the palette-wide token used
 * by `.welcome-note-box` and any future error surfaces). */
.fo-error-msg {
  color: var(--fo-danger);
  font-weight: 600;
  padding-top: 5px;
  font-size: 16px;
}

/* Green success messages. Colour consumed via --fo-success (PR
 * #12.e.4.21) — light #008000 (byte-equivalent to the pre-PR `green`
 * literal) / dark #8ad6a6 (matches --fo-asset, the pastel green used
 * for positive deltas / asset rows on dark surfaces). */
.fo-success-msg {
  color: var(--fo-success);
  font-weight: 600;
  padding-top: 5px;
  font-size: 16px;
}

/* Secondary/gray text for additional information */
.fo-secondary-text {
  color: #666;
  padding-top: 5px;
  font-size: 14px;
}

/* Configuration error messages (darker red) */
.fo-config-error-msg {
  color: #d9534f;
  font-weight: 600;
  padding-top: 5px;
  font-size: 16px;
}

/* "Logged as: username" text shown on the right side of the footer */
.fo-logged-as {
  margin-right: 10px;
  color: inherit;
  font-weight: normal;
}

/* Flex row containers in expense/cash/ticker UIs */
.fo-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

/* Action button group container (add/remove buttons) */
.fo-action-btn-group {
  display: flex;
  align-items: flex-end;
  padding-bottom: 15px;
}

/* Gap styling for button groups */
.fo-btn-gap {
  display: flex;
  gap: 5px;
}

/* Small margin-right for buttons */
.fo-btn-mr-sm {
  margin-right: 5px;
}

/* Readonly display fields that look like form inputs */
.fo-input-like-display {
  margin-bottom: 15px;
  cursor: default;
}

/* Padding on selectize dropdown options */
.fo-selectize-option {
  padding-left: 10px;
}

/* Expense row styles (moved from inline <style> tags) */
.expense-row {
  border-bottom: none !important;
}

/* Cash row styles (moved from inline <style> tags) */
.cash-row {
  border-bottom: none !important;
}

/* Button sizing - small buttons (moved from inline <style> tags) */
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Readonly input styling for profile page */
.fo-profile-readonly[readonly] {
  background-color: inherit !important;
  cursor: not-allowed;
}

/* ============================================================
   PR #8 — bslib card overflow fix for selectize dropdowns
   ============================================================
   The Reporting Currency / Reporting Frequency / Tax Regime
   selectInputs on the User Profile card render their selectize
   dropdown popups *inside* the card. By default `bslib::card` and
   its `.card-body` clip overflowing content, which makes the
   dropdown list look truncated / hidden behind the card boundary.
   The legacy `bs4Dash::box` happened not to clip because AdminLTE's
   `.box-body` does not set `overflow: hidden`. Restore the same
   "dropdowns escape the box" UX by allowing overflow on the
   profile card and any of its inner card-body / fluidRow / column
   wrappers. We scope to the marker classes so the override does
   not bleed into any other bslib card on the page.

   PR #9.3 follow-up: the Extra-tab class/functionality selector
   (`.fo-extra-selector-card`) has the exact same problem — the
   selectize dropdown listing Annuity / Stocks / Cash / Personal
   Expenses / Property / Debt / Loan / CMHC was clipped by the
   selector card boundary. Same scoped overflow:visible treatment.
*/
.fo-profile-card,
.fo-profile-card .card-body,
.fo-profile-card .card-body > .row,
.fo-profile-card .card-body > .row > [class*="col-"],
.fo-extra-selector-card,
.fo-extra-selector-card .card-body,
.fo-extra-selector-card .card-body > .row,
.fo-extra-selector-card .card-body > .row > [class*="col-"] {
  overflow: visible !important;
}

/* ============================================================
   MARKDOWN CONTENT STYLES
   ============================================================ */

/* Consistent padding for markdown/HTML content inside bs4Dash boxes */
.markdown-content {
  padding-left: 15px;
  padding-right: 15px;
}

.markdown-content ul,
.markdown-content ol {
  padding-left: 30px;
}

.markdown-content li {
  margin-bottom: 4px;
}

/* Light mode text colors for markdown content */
body:not(.dark-mode) .markdown-content,
body:not(.dark-mode) .markdown-content p,
body:not(.dark-mode) .markdown-content li,
body:not(.dark-mode) .markdown-content span,
body:not(.dark-mode) .markdown-content div,
body:not(.dark-mode) .markdown-content a {
  color: var(--fo-text) !important;
}

/* Light mode text colors for box titles and headers - HIGH SPECIFICITY */
body:not(.dark-mode) .card .card-header .card-title,
body:not(.dark-mode) .box .card-header .card-title,
body:not(.dark-mode) .card .card-header h3.card-title,
body:not(.dark-mode) .box .card-header h3.card-title,
body:not(.dark-mode) .card-header .card-title,
body:not(.dark-mode) .card-header h3.card-title,
body:not(.dark-mode) .card-title,
body:not(.dark-mode) .box-title,
body:not(.dark-mode) .card-header,
body:not(.dark-mode) .box-header {
  color: var(--fo-text) !important;
}

/* Light mode text colors for general headings - HIGH SPECIFICITY */
body:not(.dark-mode) .card h1,
body:not(.dark-mode) .card h2,
body:not(.dark-mode) .card h3,
body:not(.dark-mode) .card h4,
body:not(.dark-mode) .card h5,
body:not(.dark-mode) .card h6,
body:not(.dark-mode) .box h1,
body:not(.dark-mode) .box h2,
body:not(.dark-mode) .box h3,
body:not(.dark-mode) .box h4,
body:not(.dark-mode) .box h5,
body:not(.dark-mode) .box h6,
body:not(.dark-mode) h1,
body:not(.dark-mode) h2,
body:not(.dark-mode) h3,
body:not(.dark-mode) h4,
body:not(.dark-mode) h5,
body:not(.dark-mode) h6 {
  color: var(--fo-text) !important;
}

/* Light mode text colors for form labels and controls */
body:not(.dark-mode) .card label,
body:not(.dark-mode) .box label,
body:not(.dark-mode) label,
body:not(.dark-mode) .control-label,
body:not(.dark-mode) .form-group label,
body:not(.dark-mode) .shiny-input-container label {
  color: #212529 !important;
}

/* Light mode text colors for general paragraphs and text */
body:not(.dark-mode) .card p,
body:not(.dark-mode) .box p,
body:not(.dark-mode) .card-body p,
body:not(.dark-mode) .box-body p,
body:not(.dark-mode) p {
  color: #212529 !important;
}

/* Light mode text colors for text emphasis and formatting */
body:not(.dark-mode) .card strong,
body:not(.dark-mode) .box strong,
body:not(.dark-mode) .card-body strong,
body:not(.dark-mode) .box-body strong,
body:not(.dark-mode) strong,
body:not(.dark-mode) .card em,
body:not(.dark-mode) .box em,
body:not(.dark-mode) .card-body em,
body:not(.dark-mode) .box-body em,
body:not(.dark-mode) em,
body:not(.dark-mode) .card b,
body:not(.dark-mode) .box b,
body:not(.dark-mode) b {
  color: #212529 !important;
}

/* Light mode text colors for card/box body text elements (specific element types only).
   The :not() exclusion list also skips the conditional-formatting helper
   classes (`.delta-pos`, `.delta-neg`, `.delta-zero`, `.holding-change`,
   `.text-success`, `.text-danger`, `.text-muted`) so that semantic
   red / green / muted colours rendered inside cards (e.g. Summary page
   KPIs, Top Shares and FX Rates returns) are not overwritten with the
   default near-black body colour. */
body:not(.dark-mode) .card-body > p,
body:not(.dark-mode) .card-body > div:not(.dataTables_wrapper):not(.selectize-control):not(.btn):not(.alert):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted),
body:not(.dark-mode) .card-body > span:not(.selectize-input):not(.selectize-dropdown):not(.badge):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted),
body:not(.dark-mode) .card-body > ul,
body:not(.dark-mode) .card-body > ol,
body:not(.dark-mode) .box-body > p,
body:not(.dark-mode) .box-body > div:not(.dataTables_wrapper):not(.selectize-control):not(.btn):not(.alert):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted),
body:not(.dark-mode) .box-body > span:not(.selectize-input):not(.selectize-dropdown):not(.badge):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted),
body:not(.dark-mode) .box-body > ul,
body:not(.dark-mode) .box-body > ol {
  color: #212529 !important;
}

/* Light mode text colors for nested divs and spans in card/box bodies (more exclusions).
   Same conditional-formatting helper classes are excluded here so that
   colour-coded numbers nested arbitrarily deep in a card body still
   keep their green / red / muted colour in light mode. */
body:not(.dark-mode) .card-body div:not(.dataTables_wrapper):not(.selectize-control):not(.btn):not(.alert):not(.badge):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted),
body:not(.dark-mode) .card-body span:not(.selectize-input):not(.selectize-dropdown):not(.badge):not(.btn):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted),
body:not(.dark-mode) .box-body div:not(.dataTables_wrapper):not(.selectize-control):not(.btn):not(.alert):not(.badge):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted),
body:not(.dark-mode) .box-body span:not(.selectize-input):not(.selectize-dropdown):not(.badge):not(.btn):not(.delta-pos):not(.delta-neg):not(.delta-zero):not(.holding-change):not(.text-success):not(.text-danger):not(.text-muted) {
  color: #212529 !important;
}


.main-header .nav-link {
  padding: 8px 12px !important;
  display: inline-flex !important;
  align-items: center !important;
}

/* Remove any extra spacing/dots in topbar */
.main-header .navbar-nav > li::before,
.main-header .navbar-nav > li::after {
  display: none !important;
}

/* ============================================================
   DATATABLE ROW STRIPING

   Matches the Holdings table's transparent alternation: odd rows
   render on the page background (effectively transparent), even
   rows use a barely-perceptible neutral tint. Same pattern in
   light and dark mode — so the Metrics, Financial Statement and
   Extra DataTables all read with the same understated chrome
   instead of the legacy saturated blue stripe.
   ============================================================ */

/* Light mode — odd row transparent, even row subtle off-white. */
body:not(.dark-mode) table.dataTable tbody tr:nth-child(odd) {
  background-color: transparent !important;
}

body:not(.dark-mode) table.dataTable tbody tr:nth-child(even) {
  background-color: #f8f9fa !important;
}

/* Hover effect for light mode — slightly stronger neutral tint. */
body:not(.dark-mode) table.dataTable tbody tr:hover {
  background-color: #eceff1 !important;
}

/* Dark mode — same alternating pattern, dark palette. Matches the
   Holdings table's rowCallback (`#333333` / `#444444`). */
body.dark-mode table.dataTable tbody tr:nth-child(odd) {
  background-color: transparent !important;
}

body.dark-mode table.dataTable tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

/* Hover effect for dark mode */
body.dark-mode table.dataTable tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

/* ============================================================
   HIDE CONTROLBAR ICON
   ============================================================
   Hide the controlbar (grid) icon on the right side of the topbar
   since controlbar functionality is not used in this app.
   Multiple selectors target both the button and its parent container.
*/
[data-widget="control-sidebar"],
a[data-widget="control-sidebar"],
.nav-link[data-widget="control-sidebar"],
li:has(> [data-widget="control-sidebar"]),
.nav-item:has(> [data-widget="control-sidebar"]),
.navbar-nav .nav-item:has(> [data-widget="control-sidebar"]) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ============================================================
   HIDE DASHBOARD CHROME ON LOGIN/SIGNUP/FORGOT PASSWORD SCREENS
   ============================================================ */

/* Hide topbar/header when not authenticated */
body:not([data-app-state="authenticated"]) .main-header {
  display: none !important;
}

/* Hide sidebar panel completely when not authenticated */
body:not([data-app-state="authenticated"]) .main-sidebar {
  display: none !important;
}

/* Hide footer when not authenticated */
body:not([data-app-state="authenticated"]) .main-footer {
  display: none !important;
}

/* Remove left margin and set full viewport height for content area when not authenticated */
body:not([data-app-state="authenticated"]) .content-wrapper {
  margin-left: 0 !important;
  min-height: 100vh !important;
}

/* Hide fullscreen widget when not authenticated */
body:not([data-app-state="authenticated"]) [data-widget="fullscreen"] {
  display: none !important;
}

/* Hide help widget when not authenticated */
body:not([data-app-state="authenticated"]) [data-widget="help"] {
  display: none !important;
}

/* Hide the 60px spacer div at bottom of body when not authenticated 
   Note: This selector targets the div immediately after #body_content (app_ui.R line 217).
   If the DOM structure changes, this selector may need updating. */
body:not([data-app-state="authenticated"]) #body_content + div {
  display: none !important;
}

/* Hide floating mobile sidebar toggle button when not authenticated */
body:not([data-app-state="authenticated"]) .mobile-sidebar-toggle {
  display: none !important;
}

/* Hide pushmenu (hamburger) button when not authenticated */
body:not([data-app-state="authenticated"]) [data-widget="pushmenu"],
body:not([data-app-state="authenticated"]) .nav-item:has(> [data-widget="pushmenu"]) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ============================================================
   bslib shell — pre-auth chrome hiding + light-mode topbar
   ------------------------------------------------------------
   Under the bslib shell (`fo_use_bslib_shell() == TRUE`,
   `R/fo_bslib_outer_shell.R`) the topbar is a `<nav class="navbar">`
   and the sidebar layout is `<div class="bslib-sidebar-layout">`
   with `display: grid; grid-template-columns: var(--_sidebar-width)
   1fr;`. None of the AdminLTE selectors above match, so the pre-auth
   chrome (topbar + sidebar) used to leak through on the login / signup
   / forgot-password / reset-password / landing screens. The rules
   below hide them and collapse the grid so the pre-login card uses
   the full viewport (fixes the "login screen is low" + "sidebar not
   needed when in the login screen" report). */
body:not([data-app-state="authenticated"]) .bslib-page-sidebar > nav.navbar,
body:not([data-app-state="authenticated"]) .bslib-sidebar-layout > .sidebar,
body:not([data-app-state="authenticated"]) .bslib-sidebar-layout > .collapse-toggle {
  display: none !important;
}

body:not([data-app-state="authenticated"]) .bslib-sidebar-layout {
  grid-template-columns: 0 1fr !important;
  grid-template-areas: "main main" !important;
}

body:not([data-app-state="authenticated"]) .bslib-sidebar-layout > .main {
  grid-column: 1 / -1 !important;
  padding: 0 !important;
}

/* Topbar nav icons + Contact link in LIGHT mode (bslib shell).
   The legacy AdminLTE rule above paints every `.main-header .nav-link`
   white because the bs4Dash topbar uses a dark `status="primary"`
   background. Under bslib the topbar is a plain Bootstrap 5 navbar
   whose background flips with `<html data-bs-theme>` — so white
   icons become invisible against the light navbar surface. Restore
   readable contrast in light mode by inheriting the theme's body
   colour for both the icon affordance and the wrapped bslib
   dark-mode custom element. */
/* PR #12.e.4.23 — the previous selector below only matched `nav.navbar`
   descendants. Depending on the bslib version, `bslib::page_sidebar()`
   wraps the topbar in `<header class="navbar">` rather than
   `<nav class="navbar">`, and our topbar items are actually rendered
   inside the `<div class="fo-bslib-title">` wrapper passed as `title=`
   in `R/fo_bslib_outer_shell.R`. Match all three so the override
   actually paints the icons regardless of which tag bslib chose. */
html[data-bs-theme="light"] body[data-app-state="authenticated"] .fo-bslib-title .nav-link,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .fo-bslib-title .nav-link i,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .fo-bslib-title .nav-link svg,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .fo-bslib-title .topbar-nav-icon,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > nav.navbar .nav-link,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > nav.navbar .nav-link i,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > nav.navbar .nav-link svg,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > nav.navbar .topbar-nav-icon,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > header.navbar .nav-link,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > header.navbar .nav-link i,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > header.navbar .nav-link svg,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > header.navbar .topbar-nav-icon {
  color: var(--bs-body-color, #212529) !important;
}

html[data-bs-theme="light"] body[data-app-state="authenticated"] .fo-bslib-title .fo-bslib-dark-mode,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > nav.navbar .fo-bslib-dark-mode,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > header.navbar .fo-bslib-dark-mode {
  color: var(--bs-body-color, #212529);
  --bs-emphasis-color: var(--bs-body-color, #212529);
  --bs-body-color: var(--bs-body-color, #212529);
}

/* PR follow-up — drop the `#007bff` blue override on the bslib
   dark-mode widget's sun/moon glyph. The widget now inherits
   `currentColor` from the surrounding `.fo-bslib-dark-mode` host
   (which itself inherits `var(--bs-body-color, #212529)` in light
   mode via the block immediately above), so the sun reads as the
   same dark text colour as the Contact / Help / Logout icons next
   to it. Same currentColor hand-off in dark mode keeps the moon
   white with the other topbar icons. */
html[data-bs-theme="light"] body[data-app-state="authenticated"] .fo-bslib-title .fo-bslib-dark-mode > bslib-input-dark-mode,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > nav.navbar .fo-bslib-dark-mode > bslib-input-dark-mode,
html[data-bs-theme="light"] body[data-app-state="authenticated"] .bslib-page-sidebar > header.navbar .fo-bslib-dark-mode > bslib-input-dark-mode {
  color: currentColor;
  --bs-emphasis-color: currentColor;
  --bs-body-color: currentColor;
}

/* Pre-login card (login / signup / forgot / reset) — stretch the
   inner form-group / input-container to the card body so the
   single-column inputs (Email on forgot-password, Username /
   Password / Email / Birthday / ... on signup) don't collapse to
   shiny's default 300px width and bunch left. Same hook as the
   `.fo-pre-login-card` marker class set in
   `R/failed_login_page.R` / `R/forgot_password_page.R`. */
.fo-pre-login-card .form-group.shiny-input-container,
.fo-pre-login-card .shiny-input-container:not(.shiny-input-container-inline) {
  width: 100% !important;
  max-width: 100% !important;
}

/* Pre-login card width: keep it readable / contained — bslib::card
   defaults to 100% width which on a wide viewport stretches the form
   across the screen. Cap it at ~640 px and centre it. */
.fo-pre-login-card {
  max-width: 640px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Push the pre-login centering wrapper closer to the top so the
   login card no longer sits halfway down a sidebar-less viewport
   (fixes "the login screen is low"). */
.fo-page-center {
  justify-content: flex-start;
  padding-top: 6vh;
}

/* Scenario page — stretch every selectize to fill its column so the
   chips don't bunch on the left of an oversized card. Shiny's
   default `.form-group.shiny-input-container` width is 300px. */
.fo-scenario-card .form-group.shiny-input-container,
.fo-scenario-card .shiny-input-container:not(.shiny-input-container-inline) {
  width: 100% !important;
  max-width: 100% !important;
}

/* CMHC property header: allow the flex title (with the Street View thumbnail
   on the right) to take the full width of the card-header, so the image is
   anchored cleanly to the right rather than appearing to float. */
.card-header .card-title:has(> .cmhc-property-title),
.card-header h3.card-title:has(> .cmhc-property-title) {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  margin: 0;
  line-height: 1.4;
}
.cmhc-property-title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
/* Vertically align the property title (name + address) with the box's
   collapse "-" button inside the card-header. bs4Dash renders the
   collapse trigger inside `.card-tools` to the right of the title; we
   force the card-header itself to be a centered flex row and align
   the tools strip to the same baseline, so the chevron and the title
   text sit on the same line instead of drifting up or down. */
.card-header:has(.cmhc-property-title) {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
}
.card-header:has(.cmhc-property-title) .card-tools {
  display: flex;
  align-items: center;
  margin: 0;
  float: none;
  position: static;
  flex: 0 0 auto;
}
.card-header:has(.cmhc-property-title) .card-tools .btn-tool,
.card-header:has(.cmhc-property-title) .card-tools [data-card-widget] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* CMHC pro-forma tables: text color and table border colors react to the
   active light/dark mode via descendant selectors, so toggling dark/light
   mode is handled by CSS alone and does not require an R-side re-render. */
.cmhc-tables {
  color: #212529;
}
.cmhc-tables table {
  color: inherit;
}
body.dark-mode .cmhc-tables {
  color: #ffffff;
}
body.dark-mode .cmhc-tables table th {
  border-bottom-color: #6c757d !important;
}
body.dark-mode .cmhc-tables table td {
  border-top-color: #6c757d !important;
}

/* ============================================================
   MODAL DIALOGS: ensure readable text in both themes
   ============================================================
   shiny::modalDialog renders the body's `message` argument as a
   bare text node directly inside `.modal-body`.  None of the
   light-mode text-color rules above (.card / .box / p / label /
   heading rules) target `.modal-body`, so when the body color is
   inherited from `<body>` (which bs4Dash leaves white-on-dark in
   light mode for unrelated reasons), the bare text becomes
   white-on-white and the user sees an empty modal box.  These
   explicit rules pin the color + background in each theme so
   every modal opened via showModal() (Unsaved Changes, Discard
   Confirmation, password-confirm modals, etc.) is readable. */
body:not(.dark-mode) .modal-content,
body:not(.dark-mode) .modal-header,
body:not(.dark-mode) .modal-body,
body:not(.dark-mode) .modal-footer {
  background-color: #ffffff !important;
  color: #212529 !important;
}
body:not(.dark-mode) .modal-title,
body:not(.dark-mode) .modal-body,
body:not(.dark-mode) .modal-body p,
body:not(.dark-mode) .modal-body span,
body:not(.dark-mode) .modal-body div,
body:not(.dark-mode) .modal-body label,
body:not(.dark-mode) .modal-body strong,
body:not(.dark-mode) .modal-body em,
body:not(.dark-mode) .modal-body b,
body:not(.dark-mode) .modal-body li,
body:not(.dark-mode) .modal-body a {
  color: #212529 !important;
}
body:not(.dark-mode) .modal-body a {
  text-decoration: underline;
}

body.dark-mode .modal-content,
body.dark-mode .modal-header,
body.dark-mode .modal-body,
body.dark-mode .modal-footer {
  background-color: #343a40 !important;
  color: #ffffff !important;
}
body.dark-mode .modal-title,
body.dark-mode .modal-body,
body.dark-mode .modal-body p,
body.dark-mode .modal-body span,
body.dark-mode .modal-body div,
body.dark-mode .modal-body label,
body.dark-mode .modal-body strong,
body.dark-mode .modal-body em,
body.dark-mode .modal-body b,
body.dark-mode .modal-body li {
  color: #ffffff !important;
}

/* ----------------------------------------------------------------
   Thin blue accent line at the top of every Shiny modal — this
   replicates the primary `bs4Dash::box(status = "primary")` top
   border that the Add / Edit forms used to display before they
   were moved into modals. Keeps the visual identity consistent
   between in-page primary cards and pop-up dialogs.
---------------------------------------------------------------- */
.modal-content {
  border-top: 3px solid #007bff !important;
}

/* ----------------------------------------------------------------
   Property Add/Edit form: large Street-View thumbnail occupying
   the third column of the Characteristic section, visually
   anchored above the Mortgage Holiday End Date field that sits
   directly below in the Financing section. The picture must
   span the exact same left/right edges as a Bootstrap form-group
   in the same col-sm-4 (so it lines up perfectly with the input
   below it).
---------------------------------------------------------------- */
.property-street-view-large {
  display: block;
  /* Same vertical rhythm as a Bootstrap form-group so the picture
     sits at the same baseline as the inputs in the row above. */
  margin-bottom: 1rem;
}
.property-street-view-large .shiny-html-output {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
}
.property-street-view-large img {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}

/* ----------------------------------------------------------------
   CMHC pro-forma alignment:
   - Revenue and Expenses share the same 5-column grid so the
     "Yearly" header lines up horizontally and the "Gross Revenue %"
     / "Expected Gross Revenue %" headers line up vertically.
   - Treasury / Return on Investment / Financing / Indicators are
     laid out in a 2x2 grid, clockwise from the top-left
     (Treasury, ROI, Indicators, Financing).
---------------------------------------------------------------- */
.cmhc-tables .cmhc-rev-exp-table {
  table-layout: fixed;
}
.cmhc-tables .cmhc-rev-exp-table col.cmhc-col-label   { width: 32%; }
.cmhc-tables .cmhc-rev-exp-table col.cmhc-col-basis   { width: 13%; }
.cmhc-tables .cmhc-rev-exp-table col.cmhc-col-yearly  { width: 17%; }
.cmhc-tables .cmhc-rev-exp-table col.cmhc-col-pct     { width: 19%; }
.cmhc-tables .cmhc-rev-exp-table col.cmhc-col-perunit { width: 19%; }
.cmhc-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  column-gap: 24px;
  row-gap: 8px;
  margin-top: 16px;
}
.cmhc-summary-grid > .cmhc-cell-treasury    { grid-column: 1; grid-row: 1; }
.cmhc-summary-grid > .cmhc-cell-roi         { grid-column: 2; grid-row: 1; }
.cmhc-summary-grid > .cmhc-cell-financing   { grid-column: 1; grid-row: 2; }
.cmhc-summary-grid > .cmhc-cell-indicators  { grid-column: 2; grid-row: 2; }
.cmhc-summary-grid table {
  margin-top: 0 !important;
}

/* ----------------------------------------------------------------
   Scenario page: chip styling on the per-class selectize controls.
   The chip body (`.scenario-chip-label`) opens the Edit modal;
   the small `.scenario-chip-x` opens the Confirm-Delete modal.
   Works in both light and dark mode (uses currentColor / opacity).
---------------------------------------------------------------- */
.scenario-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.scenario-chip .scenario-chip-label {
  cursor: pointer;
}
.scenario-chip .scenario-chip-label:hover {
  text-decoration: underline;
}
.scenario-chip .scenario-chip-x {
  cursor: pointer;
  color: var(--fo-liability); /* FO pastel pink \u2014 visible in both themes */
  font-weight: bold;
  font-size: 1.1em;
  line-height: 1;
  padding: 0 4px;
  border-radius: 3px;
  user-select: none;
}
.scenario-chip .scenario-chip-x:hover {
  background-color: rgba(214, 138, 186, 0.15);
}
body.dark-mode .scenario-chip .scenario-chip-x {
  color: var(--fo-liability);
}
body.dark-mode .scenario-chip .scenario-chip-x:hover {
  background-color: rgba(214, 138, 186, 0.2);
}

/* ============================================================
   Selectize match-highlight readability (dark + light mode)
   ------------------------------------------------------------
   Selectize wraps matched query substrings in <span class="highlight">
   inside both the dropdown options AND the rendered .item chip in the
   input. Its default style is a faint blue overlay with no explicit
   text colour, which renders as illegible white-on-white in dark mode.
   Force the app's primary blue (#007bff) with white text so the
   matched portion of the typed ticker matches the rest of the app's
   accent colour and stays readable in both themes.
   ============================================================ */
.selectize-dropdown .highlight,
.selectize-input .highlight {
  background-color: #007bff !important;
  color: #ffffff !important;
  border-radius: 2px;
  padding: 0 1px;
}

/* Keep the highlight legible when the option is currently active
   (hovered / keyboard-selected) in either theme. */
.selectize-dropdown .option.active .highlight,
body.dark-mode .selectize-dropdown .option.active .highlight {
  background-color: #0056b3 !important;
  color: #ffffff !important;
}

/* ============================================================
   Larger New / Edit pop-up modals
   ------------------------------------------------------------
   scenario_page_server.R::open_item_modal() uses `size = "xl"` for
   every New / Edit portfolio-item modal. Bootstrap 4's default
   `.modal-xl` caps at 1140 px which left the per-row ticker / currency
   modules feeling cramped on wide displays. Widen the xl modal to
   ~1600 px while still respecting smaller viewports via min().
   ============================================================ */
.modal-xl {
  max-width: min(1600px, 95vw) !important;
}

/* ============================================================
   bs4Dash → bslib migration: PR #5 (release 5.0.0.9005, "rc.5").

   Under the bslib outer shell (FO.bslib_shell = TRUE), the
   authenticated sidebar nav is rendered by
   `R/fo_bslib_sidebar_menu.R` as a `<ul class="fo-bslib-sidebar-nav
   nav nav-pills flex-column" id="sidebar">` of plain nav-link `<a>`
   elements. The bslib `sidebar()` chrome provides background / padding,
   so we only style the link affordance + active highlight here. These
   selectors do not match anything in the legacy bs4Dash shell (which
   renders `bs4Dash::sidebarMenu` with `.nav-sidebar` markup instead),
   so the legacy branch is unaffected.
   ============================================================ */
.fo-bslib-sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 2px;
}

.fo-bslib-sidebar-nav .fo-bslib-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 4px;
  /* Inherit the body colour so light / dark mode just work via the
     bslib theme; explicit white / dark overrides live in the
     theme-specific rules below. */
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.fo-bslib-sidebar-nav .fo-bslib-sidebar-link:hover {
  background-color: rgba(0, 123, 255, 0.12);
  text-decoration: none;
}

.fo-bslib-sidebar-nav .fo-bslib-sidebar-link.active {
  /* Active link uses the same accent blue as the bs4Dash sidebar
     `.nav-link.active` so the two shells feel visually equivalent. */
  background-color: #007bff;
  color: #ffffff !important;
}

.fo-bslib-sidebar-nav .fo-bslib-sidebar-link .fa,
.fo-bslib-sidebar-nav .fo-bslib-sidebar-link .fas,
.fo-bslib-sidebar-nav .fo-bslib-sidebar-link .far,
.fo-bslib-sidebar-nav .fo-bslib-sidebar-link .fab,
.fo-bslib-sidebar-nav .fo-bslib-sidebar-link svg {
  /* Pin the leading icon width so labels align in a column regardless
     of icon glyph width — mirrors the layout `bs4Dash::menuItem` gives
     under the legacy shell. */
  width: 1.2em;
  text-align: center;
  flex-shrink: 0;
}

/* ============================================================
   PR #9.3 — Content-sized bslib cards (proper API approach)
   ============================================================
   PR #9.2 tried to neutralise bslib's `html-fill-container` /
   `.bslib-card { overflow: auto }` rules with a heavy
   `body .bslib-card:not(...) { overflow: visible !important; ... }`
   sledgehammer. Two problems with that:
   
     1. `overflow: visible !important` on the card and its body let
        wide / tall DT tables escape the card boundary — in the
        worst case painting OVER the page footer. Users explicitly
        do not want content escaping its container.
     2. The flex-column behaviour of `bslib::card_body(fillable =
        TRUE)` (the default) still pushed children to stretch,
        which is what produced the "too big with lots of empty
        space" symptom for short DTs.
   
   PR #9.3 fixes the root cause at the CALL SITE instead: every FO
   content card now passes `fill = FALSE` to `bslib::card()` and
   `fillable = FALSE, fill = FALSE` to `bslib::card_body()`. That
   removes the `html-fill-item` / `html-fill-container` classes and
   the flex layout from the card, so the card is a plain block
   element that grows naturally to its content — no min-height
   floor, no flex stretch, no clipping. DT's own `scrollX` wrapper
   handles horizontal overflow inside the box without escaping.
   
   We keep a SMALL CSS safety net below to (a) neutralise the
   `html-fill-container` 576px floor in case any future card
   forgets to pass `fill = FALSE`, and (b) preserve the `.fo-profile-card`
   overflow override that lets selectize dropdowns escape the
   profile card boundary. The aggressive `overflow: visible
   !important` rules from PR #9.2 are DELIBERATELY DELETED so
   table content can never paint over the footer again.
*/

/* (1) Defensive: neutralise the 576px html-fill-container floor and
       the 12rem --bslib-card-min-height default. Cards that pass
       `fill = FALSE` don't hit this anyway (they lose the
       html-fill-container class), but the rule remains a safety
       net for any future card that forgets the API flags. Crucially
       we do NOT set `overflow: visible !important` here — that was
       what let content escape under PR #9.2. The card-body still
       uses its default `overflow: hidden` / `overflow: auto` which
       respects the DT widget's own internal scrolling. */
body .bslib-card:not(.kpi-card):not(.bslib-value-box):not(.bslib-page-fill):not(.bslib-page-sidebar) {
  --bslib-page-main-min-height: 0;
  --bslib-card-min-height: auto;
  --bslib-card-body-max-height: none;
  min-height: 0;
  height: auto;
}

/* (2) CMHC accordion: per-property accordion panels contain static
       compiled HTML (Revenue / Expenses / Financing tables plus a
       Street View `<img>`). Bootstrap's accordion-body defaults
       are fine; the legacy PR #9.1 helper is preserved. */
.fo-extra-cmhc-accordion .accordion-body {
  max-height: none !important;
}

/* ============================================================
   PR #9.1 — Profile page section headers + dividers
   ============================================================
   The User Profile card body groups the personal-info fields into
   four sections (Security / Personal Details / Reporting / Tax)
   separated by an `<hr>`. Style the section heading to be small,
   muted and consistent with the rest of the form, and tighten the
   `<hr>` so the sections don't feel airy.
*/
.fo-profile-card .fo-profile-section-header {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0.5rem 0 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  opacity: 0.85;
}
.fo-profile-card .fo-profile-section-header .fa,
.fo-profile-card .fo-profile-section-header svg {
  opacity: 0.7;
}
.fo-profile-card .fo-profile-section-divider {
  margin: 1rem 0 0.75rem 0;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}
body.dark-mode .fo-profile-card .fo-profile-section-divider {
  border-top-color: rgba(255, 255, 255, 0.12);
}

/* ============================================================
   Global button finish — match the landing page CTAs.
   ============================================================
   The landing page (inst/www/landing.css) uses a 135deg linear
   gradient and a subtle lift-on-hover with a soft coloured shadow
   for its primary CTA. Carry the same finish into the in-app
   Bootstrap themed buttons so every action button in the app feels
   visually consistent with the landing page.

   We override the four most-used Bootstrap themes (primary,
   success, danger, info). Each gets a 135deg gradient between the
   theme's base and a lighter tint, a coloured hover shadow and a
   small translate-Y to mirror the landing-page lift. Outline
   variants and disabled state are left untouched so dropdowns,
   close-buttons and disabled affordances keep their default look.

   Scoped exclusions:
   * `.btn-tool` — bslib full-screen / collapse icons inside card
     headers; these are minimal icon buttons that must stay flat.
   * `.dt-button` — DataTables export buttons keep their plain DT
     styling so they don't fight with the table chrome. */
.btn-primary:not(.btn-tool):not(.dt-button) {
  background: linear-gradient(135deg, #007bff 0%, #6aa9ff 100%);
  border: none;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-primary:not(.btn-tool):not(.dt-button):hover,
.btn-primary:not(.btn-tool):not(.dt-button):focus {
  background: linear-gradient(135deg, #007bff 0%, #6aa9ff 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(106, 169, 255, 0.3);
  filter: brightness(1.05);
}
.btn-primary:not(.btn-tool):not(.dt-button):disabled,
.btn-primary.disabled:not(.btn-tool):not(.dt-button) {
  transform: none;
  box-shadow: none;
  filter: none;
}

.btn-success:not(.btn-tool):not(.dt-button) {
  background: linear-gradient(135deg, #6dc28a 0%, #8ad6a6 100%);
  border: none;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-success:not(.btn-tool):not(.dt-button):hover,
.btn-success:not(.btn-tool):not(.dt-button):focus {
  background: linear-gradient(135deg, #6dc28a 0%, #8ad6a6 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(138, 214, 166, 0.3);
  filter: brightness(1.05);
}
.btn-success:not(.btn-tool):not(.dt-button):disabled,
.btn-success.disabled:not(.btn-tool):not(.dt-button) {
  transform: none;
  box-shadow: none;
  filter: none;
}

.btn-danger:not(.btn-tool):not(.dt-button) {
  background: linear-gradient(135deg, #c26d9a 0%, #d68aba 100%);
  border: none;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-danger:not(.btn-tool):not(.dt-button):hover,
.btn-danger:not(.btn-tool):not(.dt-button):focus {
  background: linear-gradient(135deg, #c26d9a 0%, #d68aba 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(214, 138, 186, 0.3);
  filter: brightness(1.05);
}
.btn-danger:not(.btn-tool):not(.dt-button):disabled,
.btn-danger.disabled:not(.btn-tool):not(.dt-button) {
  transform: none;
  box-shadow: none;
  filter: none;
}

.btn-info:not(.btn-tool):not(.dt-button) {
  background: linear-gradient(135deg, #6da2c2 0%, #8abad6 100%);
  border: none;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-info:not(.btn-tool):not(.dt-button):hover,
.btn-info:not(.btn-tool):not(.dt-button):focus {
  background: linear-gradient(135deg, #6da2c2 0%, #8abad6 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(138, 186, 214, 0.3);
  filter: brightness(1.05);
}
.btn-info:not(.btn-tool):not(.dt-button):disabled,
.btn-info.disabled:not(.btn-tool):not(.dt-button) {
  transform: none;
  box-shadow: none;
  filter: none;
}

/* Pastel amber `.btn-warning` \u2014 completes the palette unification
 * (release `5.0.0.9063`, Items 1 + 2). Mirrors the gradient / hover
 * rhythm of the other unified buttons (`btn-success`, `btn-danger`,
 * `btn-info`) so warning-themed actions read in the same pastel
 * register as the rest of the FO chrome. */
.btn-warning:not(.btn-tool):not(.dt-button) {
  background: linear-gradient(135deg, #d6b86d 0%, #e6c88a 100%);
  border: none;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-warning:not(.btn-tool):not(.dt-button):hover,
.btn-warning:not(.btn-tool):not(.dt-button):focus {
  background: linear-gradient(135deg, #d6b86d 0%, #e6c88a 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(230, 200, 138, 0.3);
  filter: brightness(1.05);
}
.btn-warning:not(.btn-tool):not(.dt-button):disabled,
.btn-warning.disabled:not(.btn-tool):not(.dt-button) {
  transform: none;
  box-shadow: none;
  filter: none;
}

/* ============================================================
   Foldable cards on every tab except the first two.
   ============================================================
   `inst/www/custom_script.js` injects a small chevron toggle into
   every `.card > .card-header` inside tab-panes other than the
   Welcome (`#shiny-tab-welcome_page`) and Dashboard
   (`#shiny-tab-summary`) tabs. Clicking the chevron flips the
   `.card-collapsed` class on the parent card; the rules below
   hide the body / footer and rotate the chevron so users get
   visual feedback. Affordance only — the underlying tab content
   and Shiny outputs stay in the DOM (so DT / plotly bindings keep
   their state when the user re-opens the card).

   value_box / accordion-panel cards are explicitly skipped by the
   JS so this never paints a toggle on the headline KPI tiles or
   on cards that already have their own collapse handle. */
.card > .card-header .fo-card-fold-toggle {
  margin-left: auto;
  background: transparent;
  border: 0;
  padding: 0 0.35rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.65;
  font-size: 0.9em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  transition: opacity 0.15s ease, transform 0.2s ease;
}
.card > .card-header .fo-card-fold-toggle:hover,
.card > .card-header .fo-card-fold-toggle:focus {
  opacity: 1;
  outline: none;
}
.card > .card-header .fo-card-fold-toggle .fa,
.card > .card-header .fo-card-fold-toggle svg {
  transition: transform 0.2s ease;
}
.card.card-collapsed > .card-header .fo-card-fold-toggle .fa,
.card.card-collapsed > .card-header .fo-card-fold-toggle svg {
  transform: rotate(-90deg);
}
.card.card-collapsed > .card-body,
.card.card-collapsed > .card-footer {
  display: none !important;
}
/* When the card is collapsed the header should look "self-contained",
   i.e. no bottom border to suggest a body underneath. */
.card.card-collapsed > .card-header {
  border-bottom: 0;
}
/* Allow the header to host the toggle button at its trailing edge
   without forcing the title to shrink. The bslib default header
   uses display:flex already; restate align-items so the chevron
   sits vertically centred next to multi-line titles. */
.card > .card-header {
  display: flex;
  align-items: center;
}

/* ============================================================
   DASHBOARD CHART CELL TITLES
   ------------------------------------------------------------
   `R/dashboard_page_ui.R` renders a 2x2 grid of plotly charts
   (Cash, Cash Flow, Equity, Savings) where each cell carries a
   `<div class="dashboard-chart-title">` heading above the plot.
   Without an explicit rule, that heading inherits the global
   text colour which under the dark theme is the near-white token
   (legible) but the actual rendered colour was effectively dim
   because the heading sits inside a `.card-body`-like container
   that the dark-mode chain forces to a muted grey. Pin the title
   to `--fo-text` so it tracks the active theme tokens directly
   and remains highly legible against both the dark surface and
   the light surface. */
.dashboard-chart-title {
  color: var(--fo-text);
  font-weight: 600;
  margin-bottom: 4px;
}
.dashboard-chart {
  margin-bottom: 12px;
}

/* ------------------------------------------------------------
 * PR #12.e.7a — Balance Sheet section-row left-border tokens
 * ------------------------------------------------------------
 * The Financial Statement page Balance Sheet card classifies
 * each row by accounting category and tags the row's <tr> with
 * one of `fo-fs-row-asset` / `fo-fs-row-liability` /
 * `fo-fs-row-networth` (see `R/financial_statement_page_server.R`
 * drawCallback). The rules below paint a 3px solid left strip on
 * the row's first cell, consuming the canonical `--fo-asset` /
 * `--fo-liability` / `--fo-networth` tokens shipped by PR #12.e.1
 * (`inst/www/fo-tokens.css`). Scope is restricted to the
 * `fo-financial-statement-card` so the marker classes can only
 * style the Balance Sheet rows even if the same class names are
 * reused elsewhere in the future. */
.fo-financial-statement-card tr.fo-fs-row-asset > td:first-child {
  border-left: 3px solid var(--fo-asset);
}
.fo-financial-statement-card tr.fo-fs-row-liability > td:first-child {
  border-left: 3px solid var(--fo-liability);
}
.fo-financial-statement-card tr.fo-fs-row-networth > td:first-child {
  border-left: 3px solid var(--fo-networth);
}

/* ------------------------------------------------------------
 * PR #12.e.7c -- Metrics page section-row left-border tokens
 * ------------------------------------------------------------
 * Sibling block to the PR #12.e.7a rules above. The Metrics page
 * lives in `create_box()` cards (not `.fo-financial-statement-card`),
 * so PR #12.e.7c tags each Metrics card with `fo-metrics-card`
 * (`R/metric_page_server.R`) and the row drawCallback stamps the
 * same `fo-fs-row-asset` / `fo-fs-row-liability` / `fo-fs-row-networth`
 * marker classes that the financial-statement drawCallback uses.
 * The rules below paint the same 3px solid left strip on the row's
 * first cell, consuming the canonical `--fo-asset` / `--fo-liability`
 * / `--fo-networth` tokens (`inst/www/fo-tokens.css`) -- no new
 * tokens, no new colours. The parallel scope (rather than widening
 * `.fo-financial-statement-card`) keeps the marker classes opt-in:
 * other `create_box()` callers (FIRE, Holdings, Property, etc.)
 * remain unaffected even if they reuse the marker class names. */
.fo-metrics-card tr.fo-fs-row-asset > td:first-child {
  border-left: 3px solid var(--fo-asset);
}
.fo-metrics-card tr.fo-fs-row-liability > td:first-child {
  border-left: 3px solid var(--fo-liability);
}
.fo-metrics-card tr.fo-fs-row-networth > td:first-child {
  border-left: 3px solid var(--fo-networth);
}
