/* ==========================================================================
   PORTFOLIO STRATEGY ENGINE & RETIREMENT COCKPIT
   Pure CSS Design Tokens Architecture (No Tailwind or External Frameworks)
   ==========================================================================
   TABLE OF CONTENTS:
   01. DESIGN TOKENS & CSS VARIABLES (:root)
   02. BASE RESETS, TYPOGRAPHY & LAYOUT UTILITIES
   03. HEADER, NAVIGATION & USER PROFILE SWITCHER
   04. CARDS, KPI MATRICES & METRIC TILES
   05. CHARTS & DATA VISUALIZATION CONTAINERS
   06. DATA TABLES, BADGES & INVENTORY SYSTEM
   07. INTERACTIVE SLIDERS, INPUTS & FORM CONTROLS
   08. TAB-SPECIFIC MODULES & SPECIALIZED FLOWS
       08.1 Net Worth Overview & Spendable Cash Hero (Tab 1)
       08.2 Multi-Decade Wealth Trajectory & Compounding (Tab 2)
       08.3 Portfolio Holdings, Allocation & Dividend Stream (Tab 3)
       08.4 Dynamic Cash Flow Strategy & Pipeline (Tab 4)
       08.5 Unified Account Architecture & Table Badges (Inventory & Cash Flow)
       08.6 Market Breadth & Sector Internals (Tab 6)
       08.7 Live Market Heatmap & Advance/Decline Waterfall (Tab 7)
       08.8 Trader Desk v3 — Situational-Awareness Cockpit (Admin Specialized View)
   09. MODAL DIALOGS, OVERLAYS & TOOLTIPS
   10. CONSOLIDATED RESPONSIVE BREAKPOINTS (Desktop-First Cascade)
       (+ trailing prefers-reduced-motion accessibility query)
   ========================================================================== */

/* ==========================================================================
   01. DESIGN TOKENS & CSS VARIABLES (:root)
   ========================================================================== */
:root {
  /* Surface & Canvas Tokens (Graphite Obsidian Slate & Charcoal) */
  --bg-app: #0d0d0e;          /* Deep obsidian slate */
  --bg-surface: #141416;      /* Charcoal stone surface */
  --bg-card: var(--bg-surface);
  --bg-hover: #1c1c22;        /* Recessed hover well */
  --bg-card-hover: var(--bg-hover);
  --bg-elevated: #1a1a1e;     /* Dense graphite */
  --bg-input: #0a0a0c;        /* Recessed graphite well */
  --bg-input-focus: #141416;  /* Elevated graphite surface for active focused inputs */
  
  /* Hairline Drafting Boundaries */
  --border-subtle: #26262b;   /* 2H pencil boundary */
  --border-draft: var(--border-subtle);
  --border-muted: #33333a;    /* Distinct hairline */
  --border-medium: var(--border-muted);   /* Subtle boundary */
  --border-highlight: #3a3a42;/* Active hairline accent */
  --border-focus: #ededf0;    /* Crisp chalk white focus outline */

  /* Typographic Hierarchy */
  --text-chalk: #ededf0;      /* Stippled chalk */
  --text-main: var(--text-chalk);
  --text-silver: #9a9aa2;     /* Muted silver lead */
  --text-secondary: var(--text-silver);
  --text-muted: #6e6e78;      /* 4B pencil lead */
  --text-lead: #56565f;
  --text-dim: #3e3e46;

  /* Situational Alerts (Functional ONLY - zero decorative saturation) */
  --alert-surplus: #34d399;   /* Green: Target met, healthy cushion, dividend hike */
  --alert-warning: #fbbf24;   /* Amber: Cash in-flight, due < 24h, offline sync */
  --alert-deficit: #f87171;   /* Red: Deficit < 100%, dividend cut */

  /* Compatibility aliases (referenced by legacy rules; previously undefined) */
  --border-color: var(--border-subtle);
  --accent-crimson: var(--alert-deficit);
  --accent-amber: var(--alert-warning);

  /* Legacy semantic mappings safely routed to graphite & situational alert tokens */
  --accent-emerald: var(--alert-surplus);
  --accent-emerald-light: #6ee7b7;
  --accent-emerald-border: rgba(52, 211, 153, 0.25);
  --accent-red-border: rgba(248, 113, 113, 0.25);

  --accent-blue: #ededf0;
  --accent-blue-light: #ededf0;

  --accent-gold-light: #fcd34d;

  --accent-purple: #9a9aa2;
  --accent-purple-light: #ededf0;

  /* Fonts & Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
  
  /* Radii */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;

  /* Elevation Shadows (Soft Graphite Occlusion) */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.45);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   02. BASE RESETS, TYPOGRAPHY & LAYOUT UTILITIES
   ========================================================================== */

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: clip;
  max-width: 100vw;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

button, a, input, select, [role="button"] {
  touch-action: manipulation;
}

/* Tabular Monospace numbers */
.num-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.font-bold {
  font-weight: 700;
}

/* Universal Number Input Spin-Button Suppression (Keyboard ArrowUp/ArrowDown Preserved) */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Typographic Weight Utilities */
.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

/* ==========================================================================
   03. HEADER, NAVIGATION & USER PROFILE SWITCHER
   ========================================================================== */

/* App Update Notification Bar (Sticky Alert) */
.app-update-banner {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--alert-warning);
  position: sticky;
  top: 0;
  z-index: 1100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  animation: slideDown 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app-update-inner {
  max-width: 1720px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-chalk);
}

.app-update-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.update-pulse-icon {
  font-size: 0.95rem;
  color: var(--alert-warning);
  flex-shrink: 0;
}

.update-text {
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#app-update-commit {
  color: var(--alert-warning);
  font-weight: 700;
}

.update-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-update-refresh {
  background: var(--alert-warning);
  color: #0d0d0e;
  border: none;
  border-radius: var(--radius-xs);
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn-update-refresh:hover {
  opacity: 0.9;
}

.btn-update-dismiss {
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xs);
  color: var(--text-silver);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.btn-update-dismiss:hover {
  border-color: var(--border-focus);
  color: var(--text-chalk);
}

/* Top Sticky App Header (Permanent Institutional Command Header) */
.app-header {
  background: rgba(13, 13, 14, 0.95);
  border-top: 2px solid transparent;
  border-bottom: 1px solid var(--border-draft);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  padding-top: env(safe-area-inset-top, 0px);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

/* Ambient Yellow DEV Header (Active in local development mode) */
.app-header.is-dev {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.22) 0%, rgba(13, 13, 14, 0.98) 100%);
  border-top: 2px solid var(--alert-warning);
  border-bottom: 1px solid rgba(251, 191, 36, 0.25);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(251, 191, 36, 0.25);
}

.header-inner {
  max-width: 1720px;
  margin: 0 auto;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
}

.badge-app-env {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: rgba(251, 191, 36, 0.16);
  color: var(--alert-warning);
  border: 1px solid rgba(251, 191, 36, 0.35);
  text-transform: uppercase;
  user-select: none;
  line-height: 1.3;
  flex-shrink: 0;
}

.badge-app-env .dev-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--alert-warning);
  box-shadow: none; /* Explicitly NO glow per user instruction */
  animation: none; /* Explicitly NO pulse per user instruction */
  flex-shrink: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  width: 100%;
}

/* Consolidated Macro Parameters Strip (Replaces separate box capsules) */
.macro-params-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

.macro-params-strip .macro-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
}

.macro-params-strip .macro-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.macro-params-strip .macro-val {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-silver);
}

.macro-params-strip .macro-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.80rem;
  font-weight: 600;
  text-align: right;
  outline: none;
  padding: 1px 2px;
}

.macro-params-strip .macro-input:focus {
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
}

.macro-params-strip .macro-sep {
  color: var(--border-medium);
  font-size: 0.70rem;
  user-select: none;
  opacity: 0.6;
}

.macro-params-strip .badge {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.72rem;
}

/* Ambient Dev Mode surface blending */
.app-header.is-dev .header-market-sync,
.app-header.is-dev .macro-params-strip,
.app-header.is-dev .user-menu-btn {
  background: rgba(20, 20, 22, 0.85);
  border-color: rgba(251, 191, 36, 0.25);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-silver);
  border: 1px solid var(--border-subtle);
}

.badge-emerald {
  background: rgba(52, 211, 153, 0.08);
  color: var(--alert-surplus);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge-gold {
  background: rgba(251, 191, 36, 0.08);
  color: var(--alert-warning);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.badge-red {
  background: rgba(248, 113, 113, 0.08);
  color: var(--alert-deficit);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.input-compact-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
}

.input-compact-wrap label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.fx-yahoo-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.fx-yahoo-link:hover {
  color: var(--accent-blue-light);
}

.fx-yahoo-link .ext-icon {
  font-size: 0.65rem;
  opacity: 0.7;
  transition: transform var(--transition-fast);
}

.fx-yahoo-link:hover .ext-icon {
  opacity: 1;
  transform: translate(1px, -1px);
}
.input-compact {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.80rem;
  font-weight: 600;
  width: 52px;
  text-align: right;
  outline: none;
  -moz-appearance: textfield;
}

.input-compact::-webkit-inner-spin-button,
.input-compact::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#top-fx-input {
  width: 66px;
}

#top-age-input {
  width: 34px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-muted);
}

.btn-primary {
  background: #ededf0;
  color: #0d0d0e;
  font-weight: 700;
  border-color: #ededf0;
}

.btn-primary:hover {
  background: #ffffff;
  color: #000000;
  box-shadow: 0 0 12px rgba(237, 237, 240, 0.25);
}

/* Tier 2: Institutional Underline Navigation Bar (Merged Sticky Header) */
.header-nav-bar {
  background: rgba(13, 13, 14, 0.90);
  border-top: 1px solid var(--border-draft);
}

.header-nav-inner {
  max-width: 1720px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.header-nav-inner::-webkit-scrollbar {
  display: none;
}

/* Flat institutional nav items with glowing bottom underline — ZERO pills/capsules */
.nav-anchor-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text-silver);
  font-size: 0.80rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
  font-family: inherit;
  outline: none;
  box-shadow: none;
}

.nav-anchor-item:hover {
  color: var(--text-chalk);
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.nav-anchor-item .nav-item-icon {
  font-size: 0.9rem;
  transition: transform 0.15s ease;
  opacity: 0.8;
}

.nav-anchor-item:hover .nav-item-icon {
  transform: scale(1.1);
  opacity: 1;
}

.nav-text-full {
  display: none;
}

.nav-text-short {
  display: inline;
}

/* Sharp bottom underline accent indicator in Stippled Chalk */
.nav-anchor-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--text-chalk);
  border-radius: 1px 1px 0 0;
  opacity: 0;
  transform: scaleX(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 0 8px rgba(237, 237, 240, 0.6);
}

.nav-anchor-item.active {
  color: var(--text-chalk);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  box-shadow: none;
}

.nav-anchor-item.active::after {
  opacity: 1;
  transform: scaleX(1);
}

/* ==========================================================================
   04. CARDS, KPI MATRICES & METRIC TILES
   ========================================================================== */

/* Section Containers & Headers — Exclusive Single-Tab Viewport */
.cockpit-section {
  display: none;
  margin-bottom: 36px;
  scroll-margin-top: 84px;
}

.cockpit-section.active-tab {
  display: block;
  animation: tabFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.section-subtitle {
  font-size: 0.80rem;
  color: var(--text-muted);
  margin-top: 3px;
  margin-bottom: 0;
}

/* Time Horizon Quick Selector Pills Bar */
.horizon-pills-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 16px;
}

.horizon-pills-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.horizon-pills-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.horizon-pills {
  display: inline-flex;
  gap: 3px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-horizon-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-horizon-pill:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.btn-horizon-pill.active {
  background: var(--text-chalk);
  color: #0d0d0e;
  box-shadow: none;
}

/* Main Content Layout */
.main-content {
  max-width: 1480px;
  margin: 20px auto 0;
  padding: 0 24px;
}

/* Grid Systems */
.grid-5, .grid-4, .grid-3, .grid-2 {
  min-width: 0;
}

.grid-5 > *, .grid-4 > *, .grid-3 > *, .grid-2 > * {
  min-width: 0;
}

.grid-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* Dashboard Visualization Charts Grid (Streamlined 2-Column Row) */
.dashboard-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
  min-width: 0;
  align-items: stretch;
}

.dashboard-charts-grid > * {
  min-width: 0;
}

.dashboard-charts-grid > .card {
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  margin-bottom: 0;
}

.dashboard-charts-grid > .card .card-header {
  margin-bottom: 8px;
  flex-shrink: 0;
}

.dashboard-charts-grid > .card .card-title {
  font-size: 1.05rem;
}

/* Dynamic Tiered Cash Flow Pipeline Visualizer (Tab 2) */
.pipeline-topology-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 4px;
  margin: 6px 0;
}

.pipe-node-card {
  flex: 1;
  min-width: 190px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.pipe-node-card.highlight-net {
  border-color: var(--border-muted);
  background: var(--bg-surface);
}

.pipe-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pipe-step-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-silver);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

.pipe-step-badge.emerald {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-silver);
  border: 1px solid var(--border-subtle);
}

.pipe-node-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
}

.pipe-node-val {
  font-size: 1.30rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.pipe-unit {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 2px;
}

.pipe-node-sub {
  font-size: 0.74rem;
  color: var(--text-silver);
  margin: 2px 0 6px 0;
}

.pipe-node-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin: 0;
}

.pipe-flow-arrow {
  color: var(--text-dim);
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.pipe-split-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 210px;
}

.pipe-subnode-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.pipe-subnode-card.emerald {
  border-left: 2px solid var(--border-muted);
}

.pipe-subnode-card.blue {
  border-left: 2px solid var(--border-muted);
}

.pipe-subnode-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.pipe-subnode-val {
  font-size: 1.0rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 2px 0;
}

.pipe-subnode-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Segmented Toggle Control */
.segmented-control {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.seg-btn.active {
  background: #ededf0;
  color: #0d0d0e;
  font-weight: 700;
}

/* ==========================================================================
   05. CHARTS & DATA VISUALIZATION CONTAINERS
   ========================================================================== */

/* Dedicated High-Contrast Ticker & Account Legend */
.alloc-legend-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  min-height: 48px;
}

.alloc-legend-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.72rem;
}

.alloc-legend-title {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-right: 2px;
  white-space: nowrap;
}

.alloc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.2;
  transition: all var(--transition-fast);
}

.alloc-chip:hover {
  border-color: var(--border-muted);
  background: rgba(255, 255, 255, 0.08);
}

.alloc-chip .alloc-ticker {
  color: #ffffff;
  font-weight: 700;
  font-size: 0.74rem;
}

.alloc-chip .alloc-pct {
  color: var(--alert-surplus);
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 600;
}

.alloc-chip .alloc-pct.blue {
  color: #60a5fa;
}

.alloc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.chart-box {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* KPI Card Component */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 94px;
  contain: layout;
}

.kpi-card::before {
  display: none;
}

.kpi-card:hover {
  border-color: var(--border-muted);
  transform: translateY(-2px);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.kpi-value {
  font-size: 1.42rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
  margin-bottom: 4px;
  min-height: 26px;
  contain: layout style;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  min-height: 26px;
}

.kpi-value-row .kpi-value {
  margin-bottom: 0;
  min-height: auto;
  flex: 1;
  min-width: 0;
}

.kpi-value.is-masked {
  letter-spacing: 0.15em;
  cursor: pointer;
}

.btn-kpi-eye {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 5px;
  transition: all var(--transition-fast);
  line-height: 1;
  flex-shrink: 0;
}

.btn-kpi-eye:hover {
  color: var(--text-chalk);
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.btn-kpi-eye:focus-visible {
  outline: 1px solid var(--border-focus);
}

.kpi-subtext {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Containers */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   06. DATA TABLES, BADGES & INVENTORY SYSTEM
   ========================================================================== */

/* Data Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: #101012;
  color: var(--text-lead);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-draft);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.data-table tr:hover td {
  background: var(--bg-hover);
  color: var(--text-chalk);
}

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

/* Estate Horizon Table: Compact Fit Without Scrollbars */
#estate-table {
  width: 100%;
}

#estate-table th {
  padding: 8px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

#estate-table td {
  padding: 8px 8px;
  font-size: 0.82rem;
}

#estate-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#brackets-ref-card .table-container {
  overflow-y: visible;
}

.table-input {
  background: var(--bg-input);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-xs);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 6px;
  width: 72px;
  text-align: right;
  transition: all var(--transition-fast);
  -moz-appearance: textfield;
  appearance: textfield;
}

.table-input::-webkit-outer-spin-button,
.table-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.table-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  outline: none;
  box-shadow: 0 0 0 1px #ededf0;
}

/* ==========================================================================
   07. INTERACTIVE SLIDERS, INPUTS & FORM CONTROLS
   ========================================================================== */

/* Interactive Sliders & Form Controls */
.control-group {
  margin-bottom: 20px;
}

.control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.control-val-badge {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-emerald-light);
}

.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-muted);
  outline: none;
  transition: background var(--transition-fast);
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--accent-blue-light);
}


.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-muted);
  transition: var(--transition-fast);
  border-radius: 24px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-fast);
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: var(--accent-blue);
}

input:checked + .slider-round:before {
  transform: translateX(20px);
}

/* ==========================================================================
   08. TAB-SPECIFIC MODULES & SPECIALIZED FLOWS
   ========================================================================== */

/* --------------------------------------------------------------------------
   08.1 Net Worth Overview & Spendable Cash Hero (Tab 1)
   -------------------------------------------------------------------------- */

/* Waterfall Flow Architecture Cards */
.waterfall-step {
  display: flex;
  gap: 18px;
  padding: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  position: relative;
}

.waterfall-step.highlight {
  border-color: var(--border-muted);
  background: var(--bg-surface);
}

.waterfall-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-draft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-chalk);
  flex-shrink: 0;
}

.waterfall-body {
  flex-grow: 1;
}

.waterfall-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.waterfall-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Risk / Pros & Cons Component */
.pros-cons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.pro-card, .con-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 20px;
}

.pro-card {
  border: 1px solid var(--accent-emerald-border);
}

.con-card {
  border: 1px solid var(--accent-red-border);
}

.item-list {
  list-style: none;
  margin-top: 14px;
}

.item-list li {
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
}

.item-list li:last-child {
  margin-bottom: 0;
}

/* Toast Alert Notification */
.toast-notice {
  position: fixed;
  top: 20px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent-emerald);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 12px rgba(16, 185, 129, 0.2);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10002;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);
  transition: all var(--transition-normal);
}

.toast-notice.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ==========================================================================
   Spendable Cash Cockpit & Budget Breakdown Components
   ========================================================================== */
.spendable-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.spendable-hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: center;
}

.spend-amount-hero {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-chalk);
  line-height: 1.1;
  margin: 8px 0;
  letter-spacing: -0.02em;
}

.spend-freq-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.spend-freq-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.spend-freq-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}

.spend-freq-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.spend-freq-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.spend-freq-subtext {
  font-size: 0.70rem;
  line-height: 1.35;
}

.cockpit-sliders-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
}

.cockpit-slider-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.spend-bridge {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
}

.bridge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-subtle);
}

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

.bridge-row.highlight {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--accent-emerald-light);
  border-top: 2px solid var(--border-muted);
  border-bottom: 2px solid var(--border-muted);
  padding: 12px 0;
  margin: 6px 0;
}

.bridge-sub-group {
  margin: -2px 0 6px 0;
  padding: 4px 8px 6px 12px;
  background: rgba(255, 255, 255, 0.025);
  border-left: 2px solid var(--border-subtle);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.bridge-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding: 2.5px 0;
}

.bridge-sub-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.73rem;
  color: var(--text-secondary);
}

.bridge-sub-val {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-silver);
  display: inline-block;
  flex-shrink: 0;
}

/* Cushion Meter Bar */
.cushion-container {
  margin-top: 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  border: 1px solid var(--border-subtle);
}

.cushion-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}

.cushion-bar-fill {
  height: 100%;
  background: var(--text-chalk);
  border-radius: 2px;
  transition: width var(--transition-normal);
}

.cushion-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.cushion-metric-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cmc-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cmc-value {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.cmc-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cmc-annual {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
  margin-bottom: 6px;
}

.cmc-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin: 0;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 6px;
  margin-top: auto;
}

/* Top Header Market Sync & Live Status */
.header-market-sync {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

.header-market-sync .macro-sep {
  color: var(--border-medium);
  font-size: 0.70rem;
  user-select: none;
  opacity: 0.6;
}

.header-market-sync .market-sync-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.header-market-sync .status-label {
  color: var(--text-muted);
  font-weight: 600;
}

.header-market-sync .btn-sync-refresh {
  padding: 2px 7px;
  font-size: 0.72rem;
  gap: 4px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-blue-light);
  border-radius: var(--radius-xs);
}

.header-market-sync .btn-sync-refresh:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.25);
  border-color: var(--accent-blue);
  color: #ffffff;
}

.market-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border-radius: 0;
  font-size: 0.72rem;
  font-weight: 700;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  transition: color var(--transition-fast);
}

.market-status-badge.open {
  background: transparent;
  color: var(--accent-emerald-light);
  border: none;
}

.market-status-badge.closed {
  background: transparent;
  color: var(--alert-warning);
  border: none;
}

.market-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  flex-shrink: 0;
}

.market-status-badge.open .market-pulse-dot {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulse-dot 1.8s infinite;
}

.market-status-badge.closed .market-pulse-dot {
  background: #f59e0b;
}

@keyframes pulse-dot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.market-status-badge.yf-throttled {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  cursor: help;
  font-size: 0.70rem;
}

.market-status-badge.yf-throttled .alarm-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
  display: inline-block;
  flex-shrink: 0;
  animation: pulse-alarm-dot 1.4s infinite;
}

@keyframes pulse-alarm-dot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.market-sync-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-sync-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.btn-sync-refresh:hover:not(:disabled) {
  border-color: var(--accent-blue);
  color: #fff;
  background: rgba(59, 130, 246, 0.15);
}

.btn-sync-refresh.spinning .sync-icon {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   08.2 Multi-Decade Wealth Trajectory & Compounding (Tab 2)
   -------------------------------------------------------------------------- */

/* Trajectory Milestone Table */
.traj-table-container {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.traj-table-row {
  cursor: default;
  transition: background 0.15s ease;
}

.traj-table-row:hover {
  background: rgba(59, 130, 246, 0.12) !important;
}

.traj-table-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Ticker Yahoo Finance External Links */
.ticker-yahoo-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--accent-blue-light);
  border-bottom: 1px dashed rgba(59, 130, 246, 0.4);
  transition: all var(--transition-fast);
}

.ticker-yahoo-link:hover {
  border-bottom-color: var(--accent-blue-light);
  color: #fff;
  filter: brightness(1.2);
}

.ticker-yahoo-link .yf-arrow {
  font-size: 0.72rem;
  color: var(--accent-blue);
  opacity: 0.8;
  transition: transform var(--transition-fast);
}

.ticker-yahoo-link:hover .yf-arrow {
  transform: translate(1px, -1px);
  color: #fff;
  opacity: 1;
}

/* =========================================================================
   Sleek Compact DRIP Control (No Pills, Crisp Modern Design)
   ========================================================================= */
.drip-control-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drip-control-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
}

.drip-mode-tabs {
  display: inline-flex;
  background: #090f1d;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 2px;
  gap: 2px;
}

.drip-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.69rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 2px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drip-mode-btn.active {
  background: #1e2e4a;
  color: #f8fafc;
  font-weight: 700;
}

.btn-automatch {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--alert-surplus);
  font-size: 0.69rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.btn-automatch:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--alert-surplus);
  color: #ffffff;
}

.drip-acct-row {
  display: grid;
  grid-template-columns: 82px 1fr 52px 145px;
  align-items: center;
  gap: 8px;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  font-size: 0.73rem;
}

.drip-acct-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.drip-acct-row .range-slider {
  margin: 0;
  height: 4px;
}

.drip-input-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 3px;
  gap: 1px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.drip-input-wrap:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.drip-input-wrap:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.drip-num-input {
  width: 30px;
  background: transparent;
  border: none;
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0;
  text-align: right;
  -moz-appearance: textfield;
  outline: none;
}

.drip-num-input::-webkit-outer-spin-button,
.drip-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.drip-pct-symbol {
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  padding-left: 1px;
}

.drip-acct-metric {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.drip-summary-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: #090f1d;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  font-size: 0.71rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   08.3 Portfolio Holdings, Allocation & Dividend Stream (Tab 3)
   -------------------------------------------------------------------------- */

/* Inventory Table DRIP Strip */
.inv-drip-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #090f1d;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 3px 8px;
}

.inv-drip-title {
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--text-main);
}

.inv-drip-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.70rem;
  color: var(--text-secondary);
}

.inv-drip-input {
  width: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 700;
  padding: 1px 3px;
  text-align: center;
}

.inv-drip-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

/* --------------------------------------------------------------------------
   08.4 Dynamic Cash Flow Strategy & Pipeline (Tab 4)
   -------------------------------------------------------------------------- */

/* Cockpit Spendable Lifestyle Editable Input */
.spend-input-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 6px;
  gap: 2px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.spend-input-wrap:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.spend-input-wrap:focus-within {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 1px var(--accent-purple);
}

.spend-prefix {
  font-family: var(--font-mono);
  font-size: 0.80rem;
  font-weight: 700;
  color: var(--accent-purple-light);
  user-select: none;
}

.spend-num-input {
  width: 72px;
  background: transparent;
  border: none;
  color: var(--accent-purple-light);
  font-family: var(--font-mono);
  font-size: 0.80rem;
  font-weight: 700;
  text-align: right;
  padding: 0;
  outline: none;
}

/* --------------------------------------------------------------------------
   08.5 Unified Account Architecture & Table Badges (Inventory & Cash Flow)
   -------------------------------------------------------------------------- */

/* Plain Monospace Table Label Architecture & Unified Account Badge */
.col-acct-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.2;
  vertical-align: middle;
}

.col-acct-badge .acct-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}

.col-acct-badge .acct-glyph {
  font-size: 0.80rem;
  line-height: 1;
  display: inline-block;
}

.col-acct-badge .acct-name {
  color: var(--text-chalk);
}

.col-category-text {
  font-size: 0.76rem;
  color: var(--text-lead);
  font-weight: 500;
  display: inline-block;
}

.col-cash-text {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-chalk);
  letter-spacing: 0.03em;
  display: inline-block;
}

/* Add Position Header Button High-Contrast Styling */
#btn-add-position {
  background: #ededf0;
  color: #0d0d0e;
  border: 1px solid #ededf0;
  font-weight: 700;
}

#btn-add-position:hover {
  background: #ffffff;
  color: #000000;
  box-shadow: 0 0 12px rgba(237, 237, 240, 0.25);
}

/* Table Holding Action Buttons (Subtle Graphite, Illuminate on Hover) */
.btn-action-edit,
.btn-action-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0 2px;
  padding: 0;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all var(--transition-fast);
  color: var(--text-lead);
}

.btn-action-edit:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
  color: var(--text-chalk);
}

.btn-action-delete:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--alert-deficit);
}

/* --------------------------------------------------------------------------
   08.6 Market Breadth & Sector Internals (Tab 6)
   -------------------------------------------------------------------------- */
/* Breadth Controls Bar */
.breadth-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.breadth-controls-left,
.breadth-controls-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Segmented Button Groups */
.segmented-btn-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.btn-segment {
  background: transparent;
  border: none;
  color: var(--text-silver);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-segment:hover {
  color: var(--text-chalk);
  background: rgba(255, 255, 255, 0.04);
}

.btn-segment.active {
  background: var(--bg-elevated);
  color: var(--text-chalk);
  border: 1px solid var(--border-highlight);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.select-breadth-cadence {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-chalk);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.select-breadth-cadence:focus {
  border-color: var(--border-highlight);
}

/* Breadth Macro Pulse 5-Card Grid */
.breadth-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.breadth-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: all var(--transition-fast);
}

.breadth-kpi-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}

.breadth-kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.breadth-kpi-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-silver);
}

.breadth-kpi-icon {
  font-size: 0.92rem;
  opacity: 0.85;
}

.breadth-kpi-val {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-chalk);
  margin-bottom: 6px;
}

.breadth-kpi-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Regime Badge */
.badge-regime {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-regime.emerald {
  background: rgba(52, 211, 153, 0.12);
  color: var(--alert-surplus);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-regime.amber {
  background: rgba(251, 191, 36, 0.12);
  color: var(--alert-warning);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-regime.crimson {
  background: rgba(248, 113, 113, 0.12);
  color: var(--alert-deficit);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.badge-regime.blue {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-regime.silver {
  background: rgba(154, 154, 162, 0.12);
  color: var(--text-silver);
  border: 1px solid var(--border-medium);
}

/* Divergence Radar Section */
.divergence-radar-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

.divergence-radar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.divergence-radar-title {
  font-size: 0.90rem;
  font-weight: 700;
  color: var(--text-chalk);
  display: flex;
  align-items: center;
  gap: 8px;
}

.divergence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.divergence-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border-left: 3px solid var(--border-highlight);
  transition: all var(--transition-fast);
}

.divergence-card.warning {
  border-left-color: var(--alert-warning);
  background: rgba(251, 191, 36, 0.03);
}

.divergence-card.danger {
  border-left-color: var(--alert-deficit);
  background: rgba(248, 113, 113, 0.03);
}

.divergence-card.bullish {
  border-left-color: var(--alert-surplus);
  background: rgba(52, 211, 153, 0.03);
}

.divergence-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.divergence-title {
  font-size: 0.80rem;
  font-weight: 700;
  color: var(--text-chalk);
}

.divergence-metric-pill {
  font-size: 0.70rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-silver);
  white-space: nowrap;
}

.divergence-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.35;
  margin: 0;
}

/* Sector Breadth Matrix Table */
.breadth-matrix-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.breadth-matrix-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.breadth-table-wrap {
  overflow-x: auto;
}

.breadth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.80rem;
  text-align: left;
}

.breadth-table th {
  background: var(--bg-surface);
  color: var(--text-silver);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
  user-select: none;
}

.breadth-table th.th-sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

.breadth-table th.th-sortable:hover {
  color: var(--text-chalk);
}

.breadth-table th.sorted {
  color: var(--text-chalk);
}

.breadth-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-chalk);
  white-space: nowrap;
}

.breadth-table tr:hover td {
  background: var(--bg-hover);
}

.badge-etf {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-silver);
  margin-left: 6px;
}

/* Breadth Progress Bar Cell */
.breadth-cell-sma {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}

.breadth-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.breadth-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.breadth-bar-fill.emerald {
  background: var(--alert-surplus);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

.breadth-bar-fill.amber {
  background: var(--alert-warning);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
}

.breadth-bar-fill.crimson {
  background: var(--alert-deficit);
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.4);
}

.breadth-bar-pct {
  font-size: 0.74rem;
  font-weight: 700;
  width: 42px;
  text-align: right;
}

/* --- Executive Macro Breadth Ribbon (Option A: Borderless Typographic Flow) --- */
.header-breadth-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  padding: 1px 4px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}

.header-breadth-ribbon:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: transparent;
  transform: none;
}

.ribbon-index-tag {
  font-weight: 700;
  color: var(--text-chalk);
  font-size: 0.72rem;
  padding-right: 0;
  border-right: none;
}

.ribbon-sma-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ribbon-sma-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

.ribbon-sma-val {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-chalk);
}

.ribbon-divider {
  color: var(--border-medium);
  font-size: 0.70rem;
  opacity: 0.6;
  user-select: none;
}

.ribbon-regime-pill {
  font-size: 0.70rem;
  font-weight: 700;
  padding: 0;
  border-radius: 0;
  margin-left: 2px;
  background: transparent !important;
  border: none !important;
}

.ribbon-regime-pill.emerald {
  background: transparent !important;
  color: var(--alert-surplus);
  border: none !important;
}

.ribbon-regime-pill.amber {
  background: transparent !important;
  color: var(--alert-warning);
  border: none !important;
}

.ribbon-regime-pill.crimson {
  background: transparent !important;
  color: var(--alert-deficit);
  border: none !important;
}

.ribbon-regime-pill.silver {
  background: transparent !important;
  color: var(--text-silver);
  border: none !important;
}

/* --- Historical Multi-SMA Trend Chart --- */
.breadth-trend-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 24px;
}

.breadth-trend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 10px;
}

.breadth-trend-title {
  font-size: 0.90rem;
  font-weight: 700;
  color: var(--text-chalk);
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadth-trend-header-left {
  flex: 1;
  min-width: 260px;
}

.breadth-trend-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.breadth-chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.breadth-chart-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 0.72rem;
  color: var(--text-silver);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  line-height: 1.2;
}

.breadth-chart-legend .legend-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-chalk);
  border-color: var(--border-draft);
}

.breadth-chart-legend .legend-item.disabled {
  opacity: 0.38;
}

.breadth-chart-legend .legend-item.disabled .legend-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.breadth-chart-legend .legend-item.disabled .legend-dot {
  background: transparent !important;
  box-shadow: 0 0 0 1.5px currentColor inset;
}

.breadth-chart-legend .legend-item.disabled .legend-dash,
.breadth-chart-legend .legend-item.disabled .legend-line {
  opacity: 0.35;
}

.breadth-chart-legend .legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.breadth-chart-legend .legend-dash,
.breadth-chart-legend .legend-line {
  width: 14px;
  height: 1.5px;
  background: rgba(237, 237, 240, 0.82);
  border-radius: 1px;
  display: inline-block;
  flex-shrink: 0;
}

.breadth-chart-canvas-wrap {
  position: relative;
  height: 320px;
  width: 100%;
}

/* Breadth Dynamic Institutional Crosshair HUD Bar (Option 1) */
.breadth-chart-hud {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(20, 20, 22, 0.70);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 10px;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  flex-wrap: wrap;
  min-height: 32px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.breadth-chart-hud.hud-active {
  border-color: var(--border-highlight);
  background: rgba(26, 26, 30, 0.95);
}

.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s ease;
}

.hud-item.disabled {
  display: none;
}

.hud-item.hud-date {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--text-chalk);
  font-weight: 600;
  font-size: 0.72rem;
  gap: 5px;
}

.hud-icon {
  font-size: 0.70rem;
  line-height: 1;
}

.hud-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.hud-dash {
  width: 12px;
  height: 1.5px;
  border-radius: 1px;
  display: inline-block;
  flex-shrink: 0;
}

.hud-label {
  color: var(--text-silver);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
}

.hud-val {
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--text-chalk);
}

#chart-breadth-trend {
  cursor: crosshair;
}

/* ==========================================================================
   08.7 Live Market Heatmap & Advance/Decline Waterfall (Tab 7)
   ========================================================================== */

/* Top Controls Bar */
.heatmap-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.heatmap-controls-left {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.heatmap-controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.heatmap-control-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heatmap-control-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-silver);
  white-space: nowrap;
}

.heatmap-index-quote-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.heatmap-index-quote-badge:hover {
  border-color: var(--border-highlight);
  background: var(--bg-hover);
}

.heatmap-index-quote-badge .pos {
  color: var(--alert-surplus);
}

.heatmap-index-quote-badge .neg {
  color: var(--alert-deficit);
}

.heatmap-index-mini-spark {
  display: inline-flex;
  align-items: center;
  width: 48px;
  height: 18px;
}

.heatmap-index-mini-spark svg {
  width: 48px;
  height: 18px;
  display: block;
}

.select-heatmap-sector {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-chalk);
  font-size: 0.78rem;
  padding: 4px 10px;
  height: 32px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.select-heatmap-sector:focus {
  border-color: var(--accent-blue);
}

/* Heatmap Top N Stocks Filter */
.heatmap-top-n-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  height: 32px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.heatmap-top-n-filter.active {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.08);
}

.heatmap-top-n-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-silver);
  user-select: none;
}

.select-heatmap-top-n {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-chalk);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  height: 24px;
  padding: 0 4px;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.select-heatmap-top-n:focus,
.select-heatmap-top-n:hover {
  border-color: var(--accent-blue);
}

.heatmap-weight-badge {
  font-size: 0.70rem;
  font-weight: 700;
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.heatmap-group-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-silver);
}

.heatmap-group-checkbox input[type="checkbox"] {
  accent-color: var(--accent-blue);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Heatmap Grid Container */
.heatmap-grid-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 18px;
  overflow: hidden;
}

.heatmap-tiles-wrap {
  width: 100%;
}

.heatmap-loading-notice {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

/* Flat Grid Layout */
.heatmap-flat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 4px;
}

/* Heatmap Tile */
.heatmap-tile {
  height: 42px;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: #ededf0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  transition: background-color 0.6s ease, color 0.4s ease, transform 0.10s ease, box-shadow 0.10s ease, outline 0.10s ease;
  user-select: none;
  position: relative;
  overflow: hidden;
}

#section-heatmap .pulse-dot,
#section-heatmap .market-pulse-dot {
  animation: none !important;
  display: none !important;
}

.heatmap-tile-sym {
  font-size: 0.74rem;
  line-height: 1.1;
  letter-spacing: -0.2px;
}

.heatmap-tile-pct {
  font-size: 0.62rem;
  opacity: 0.90;
  line-height: 1;
  margin-top: 1px;
}

.heatmap-tile:hover {
  transform: scale(1.22);
  z-index: 30;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.9);
  outline: 2px solid #ffffff;
}

.heatmap-tile.highlighted {
  outline: 2px solid var(--accent-blue);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.9);
  transform: scale(1.15);
  z-index: 25;
}

/* Color Ramp Classes */
.tile-up-extreme {
  background: #16a34a !important; /* +4.0%+ */
}
.tile-up-high {
  background: #15803d !important; /* +2.0% to +4.0% */
}
.tile-up-mid {
  background: #166534 !important; /* +1.0% to +2.0% */
}
.tile-up-low {
  background: #14532d !important; /* +0.2% to +1.0% */
}
.tile-flat {
  background: #26262b !important; /* -0.2% to +0.2% */
  color: #9a9aa2 !important;
}
.tile-down-low {
  background: #451a1a !important; /* -1.0% to -0.2% */
}
.tile-down-mid {
  background: #7f1d1d !important; /* -2.0% to -1.0% */
}
.tile-down-high {
  background: #991b1b !important; /* -4.0% to -2.0% */
}
.tile-down-extreme {
  background: #dc2626 !important; /* -4.0%- */
}

/* Sector Grouping Layout */
.heatmap-sector-block {
  margin-bottom: 14px;
}

.heatmap-sector-block:last-child {
  margin-bottom: 0;
}

.heatmap-sector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent-blue);
  border-radius: 2px;
  margin-bottom: 6px;
}

.heatmap-sector-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-chalk);
}

.heatmap-sector-count {
  font-size: 0.70rem;
  color: var(--text-silver);
  font-family: var(--font-mono);
}

.heatmap-sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 4px;
}

/* Advance / Decline & Volume Waterfall Card */
.heatmap-waterfall-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 24px;
}

.heatmap-waterfall-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 12px;
}

.heatmap-breadth-counters {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  font-weight: 700;
  background: rgba(20, 20, 22, 0.7);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  line-height: 1.2;
}

.count-pill.count-up {
  color: var(--alert-surplus);
}

.count-pill.count-down {
  color: var(--alert-deficit);
}

.count-pill.count-flat {
  color: var(--text-silver);
}

.count-divider {
  color: var(--text-muted);
  opacity: 0.4;
}

/* =========================================================================
   Mode A: High-Density Institutional Holding Cards (My Holdings)
   ========================================================================= */
.heatmap-holdings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  width: 100%;
  padding: 4px 0 8px 0;
}

.heatmap-holding-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
}

.heatmap-holding-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.heatmap-holding-card.highlighted {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 16px rgba(237, 237, 240, 0.25) !important;
  transform: translateY(-2px);
}

/* Card top performance indicator strip */
.heatmap-holding-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-medium);
}

.heatmap-holding-card.pos::before {
  background: var(--alert-surplus);
}

.heatmap-holding-card.neg::before {
  background: var(--alert-deficit);
}

.heatmap-holding-card.flat::before {
  background: var(--text-silver);
}

.holding-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.holding-card-sym-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.holding-card-ticker {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-chalk);
  letter-spacing: 0.02em;
  line-height: 1.1;
  font-family: var(--font-mono);
}

.holding-card-name {
  font-size: 0.70rem;
  color: var(--text-silver);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 175px;
}

.holding-card-pct-badge {
  font-size: 1.10rem;
  font-weight: 800;
  line-height: 1.1;
}

.holding-card-pct-badge.pos {
  color: var(--alert-surplus);
}

.holding-card-pct-badge.neg {
  color: var(--alert-deficit);
}

.holding-card-pct-badge.flat {
  color: var(--text-silver);
}

.holding-card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.holding-card-accounts {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.holding-acct-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-silver);
  white-space: nowrap;
}

.holding-acct-pill .pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.holding-acct-pill.pill-tfsa {
  border-color: rgba(20, 184, 166, 0.4);
  color: #5eead4;
  background: rgba(20, 184, 166, 0.08);
}
.holding-acct-pill.pill-tfsa .pill-dot {
  background: #14b8a6;
}

.holding-acct-pill.pill-rrsp-cad {
  border-color: rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.08);
}
.holding-acct-pill.pill-rrsp-cad .pill-dot {
  background: #6366f1;
}

.holding-acct-pill.pill-rrsp-usd {
  border-color: rgba(168, 85, 247, 0.4);
  color: #d8b4fe;
  background: rgba(168, 85, 247, 0.08);
}
.holding-acct-pill.pill-rrsp-usd .pill-dot {
  background: #a855f7;
}

.holding-acct-pill.pill-nonreg {
  border-color: rgba(236, 72, 153, 0.4);
  color: #f472b6;
  background: rgba(236, 72, 153, 0.08);
}
.holding-acct-pill.pill-nonreg .pill-dot {
  background: #ec4899;
}

.holding-acct-pill.pill-all {
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.08);
}
.holding-acct-pill.pill-all .pill-dot {
  background: #3b82f6;
}

.holding-card-weight-pill {
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-silver);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 1px 6px;
}

.holding-card-financials {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.holding-card-val-label {
  font-size: 0.64rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.holding-card-val-num {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-chalk);
}

.holding-card-pnl-col {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.holding-card-pnl-amt {
  font-size: 0.82rem;
  font-weight: 700;
}

.holding-card-pnl-amt.pos {
  color: var(--alert-surplus);
}

.holding-card-pnl-amt.neg {
  color: var(--alert-deficit);
}

.holding-card-pnl-amt.flat {
  color: var(--text-silver);
}

.holding-card-units-price {
  font-size: 0.66rem;
  color: var(--text-silver);
}

.heatmap-waterfall-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-chalk);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}

.heatmap-hud-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  background: rgba(20, 20, 22, 0.75);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  min-height: 28px;
}

.hud-item-ticker {
  font-weight: 700;
  color: var(--accent-blue);
}

.hud-item-name {
  color: var(--text-silver);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-item-price {
  color: var(--text-chalk);
  font-weight: 600;
}

.hud-item-change.pos {
  color: var(--alert-surplus);
  font-weight: 700;
}

.hud-item-change.neg {
  color: var(--alert-deficit);
  font-weight: 700;
}

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

.heatmap-canvas-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}

#chart-heatmap-waterfall {
  width: 100%;
  height: 100%;
  display: block;
}

/* Floating Tooltip */
.heatmap-floating-tooltip {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  background: #141416;
  border: 1px solid var(--border-highlight);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.74rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  min-width: 240px;
  max-width: 285px;
}

.heatmap-tooltip-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-chalk);
  margin-bottom: 2px;
}

.heatmap-tooltip-name {
  color: var(--text-silver);
  font-size: 0.70rem;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heatmap-tooltip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  gap: 8px;
}

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

.heatmap-tooltip-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-chalk);
}

/* 1-Year Sparkline in Tooltip */
.heatmap-sparkline-box {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.sparkline-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  margin-bottom: 5px;
  line-height: 1.2;
  gap: 8px;
  white-space: nowrap;
}

.sparkline-lbl {
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
}

.sparkline-pct {
  font-weight: 700;
  font-size: 0.70rem;
}

.sparkline-pct.pos {
  color: var(--alert-surplus);
}

.sparkline-pct.neg {
  color: var(--alert-deficit);
}

.sparkline-range {
  color: var(--text-silver);
  font-size: 0.64rem;
}

.sparkline-svg-wrap {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sparkline-svg {
  width: 100%;
  height: 44px;
  overflow: visible;
  display: block;
}

.sparkline-skeleton {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

/* ==========================================================================
   08.8 TRADER DESK v3 — Situational-Awareness Cockpit (#section-trader, Admin)
   3-column no-scroll grid tuned for a single 1080p monitor:
   [Custom Indexes | Breadth]  [SPX chart + levels | Index contribution]  [Level ladder | Alert tape]
   [──────────────────── Weight-sized S&P 500 treemap ────────────────────]
   Monochrome chrome (ISA-101); color reserved for data direction and alerts.
   ========================================================================== */
.td-desk {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 700px;
  font-size: 0.72rem;
  color: var(--text-chalk);
}
/* Desk mode (desktop): full-bleed width + no trailing page padding; pairs with fitDeskHeight() in trader_desk.js */
@media (min-width: 1201px) {
  .main-content:has(> #section-trader.active-tab) { max-width: none; }
  #section-trader.active-tab { margin-bottom: 0; }
  body:has(#section-trader.active-tab) { padding-bottom: 0; }
}
.td-desk .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.td-desk .up { color: var(--alert-surplus); }
.td-desk .down { color: var(--alert-deficit); }
.td-desk .flat { color: var(--text-silver); }
.td-desk .warn { color: var(--alert-warning); }
.td-muted { color: var(--text-muted); }

/* --- Regime strip --- */
.td-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  min-height: 38px;
  flex-wrap: wrap;
}
.td-strip-left, .td-strip-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.td-strip-right { margin-left: auto; }
.td-brand { font-weight: 700; font-size: 0.86rem; margin-right: 2px; white-space: nowrap; }
.td-tags { display: inline-flex; gap: 4px; }
.td-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-muted);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--text-silver);
  background: rgba(255, 255, 255, 0.03);
}
.td-pill:empty { display: none; }
.td-pill-muted { color: var(--text-silver); }
.td-pill-live { color: var(--alert-surplus); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.td-pill-phase-on { color: var(--text-chalk); border-color: var(--border-highlight); background: rgba(255, 255, 255, 0.06); }
.td-pill-up { color: var(--alert-surplus); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.td-pill-down { color: var(--alert-deficit); border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }
.td-pill-warn { color: var(--alert-warning); border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.td-tickers { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.td-tick {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  white-space: nowrap;
}
.td-tick b { color: var(--text-silver); font-weight: 600; }
.td-tick-px { color: var(--text-chalk); }
.td-tick.up .td-tick-pct { color: var(--alert-surplus); }
.td-tick.down .td-tick-pct { color: var(--alert-deficit); }
.td-tick.flat .td-tick-pct { color: var(--text-silver); }
.td-tick.warn { border-color: rgba(251, 191, 36, 0.45); }
.td-tick.warn .td-tick-px, .td-tick.warn .td-tick-pct { color: var(--alert-warning); }
.td-tick.alarm { border-color: rgba(248, 113, 113, 0.55); background: rgba(248, 113, 113, 0.08); }
.td-tick.alarm .td-tick-px, .td-tick.alarm .td-tick-pct { color: var(--alert-deficit); }
.td-sr { font-size: 0.66rem; display: inline-flex; gap: 6px; white-space: nowrap; }
.td-sep { color: var(--text-dim); }

/* --- Grid --- */
.td-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 280px;
  grid-template-rows: minmax(0, 1fr) clamp(170px, 27%, 260px);
  grid-template-areas:
    "left center right"
    "map  map    map";
  gap: 6px;
}
.td-col { display: flex; flex-direction: column; gap: 6px; min-height: 0; min-width: 0; }
.td-col-left { grid-area: left; }
.td-col-center { grid-area: center; }
.td-col-right { grid-area: right; }
.td-panel-map { grid-area: map; }

.td-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  overflow: hidden;
}
.td-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  margin-bottom: 4px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}
.td-title { font-weight: 700; font-size: 0.74rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-chalk); }
.td-hint { font-size: 0.62rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.td-head-spacer { flex: 1; }
.td-seg .btn-segment { font-size: 0.62rem; padding: 2px 7px; }
.td-btn-xs { font-size: 0.62rem; padding: 2px 7px; }
.td-empty { color: var(--text-muted); font-size: 0.66rem; padding: 10px 4px; text-align: center; list-style: none; }
.td-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* Left column */
.td-panel-indexes { flex: 1.15 1 0; }
.td-panel-breadth { flex: 1 1 0; }
.td-canvas-box { position: relative; flex: 1 1 auto; min-height: 70px; }
.td-canvas-box canvas { position: absolute; inset: 0; display: block; }
.td-idx-table { width: 100%; border-collapse: collapse; margin-top: 4px; font-size: 0.66rem; }
.td-idx-table th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 0.58rem; text-transform: uppercase; padding: 1px 3px; border-bottom: 1px solid var(--border-subtle); }
.td-idx-table td { padding: 2px 3px; border-bottom: 1px solid rgba(255, 255, 255, 0.03); white-space: nowrap; }
.td-idx-table .num { text-align: right; }
.td-spread {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.64rem;
}
.td-spread.warn { border-color: rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.07); }
.td-spread.warn b { color: var(--alert-warning); }

.td-gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 4px; }
.td-gauge { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-xs); padding: 3px 6px; }
.td-g-lbl { font-size: 0.56rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.04em; }
.td-g-val { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; }
.td-g-sub { font-family: var(--font-mono); font-size: 0.58rem; color: var(--text-muted); }
.td-split { display: flex; height: 4px; border-radius: 2px; overflow: hidden; margin-top: 2px; background: rgba(255, 255, 255, 0.06); }
.td-split i.up { background: var(--alert-surplus); }
.td-split i.down { background: var(--alert-deficit); }
.td-sma-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; margin-top: 4px; }
.td-panel-breadth .td-ad-box { min-height: 44px; }
.td-sma { display: grid; grid-template-columns: 38px 1fr 34px; align-items: center; gap: 6px; font-size: 0.6rem; }
.td-sma-lbl { color: var(--text-muted); font-family: var(--font-mono); }
.td-sma-track { position: relative; height: 5px; background: rgba(255, 255, 255, 0.06); border-radius: 3px; overflow: hidden; }
.td-sma-track i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--text-silver); }
.td-sma-track i.up { background: var(--alert-surplus); }
.td-sma-track i.down { background: var(--alert-deficit); }
.td-sma-track em { position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: rgba(255, 255, 255, 0.25); }
.td-sma-val { font-family: var(--font-mono); text-align: right; }
.td-sma-val.mid { color: var(--text-silver); }

/* Center column */
.td-panel-chart { flex: 1.75 1 0; }
.td-panel-movers { flex: 1 1 0; }
.td-chart-price { font-size: 0.86rem; font-weight: 700; }
.td-chart-chg { font-size: 0.7rem; }
.td-chart-hud { font-size: 0.6rem; }
.td-chart-hud b { color: var(--text-silver); font-weight: 600; }
.td-chart-wrap { position: relative; flex: 1 1 auto; min-height: 160px; }
.td-chart { position: absolute; inset: 0; overflow: hidden; }
.td-profile-canvas { position: absolute; inset: 0; pointer-events: none; }

.td-movers { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; overflow: hidden; }
.td-mv-col { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.td-mv-head { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 2px; }
.td-mv-row { display: grid; grid-template-columns: 58px 1fr 50px 52px; align-items: center; gap: 6px; height: 15px; font-size: 0.64rem; border-radius: 2px; cursor: default; }
.td-mv-row:hover { background: var(--bg-hover); }
.td-mv-sym { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-mv-sym sup { font-size: 0.5rem; color: #60a5fa; margin-left: 2px; font-weight: 600; }
.td-mv-bar { height: 7px; background: rgba(255, 255, 255, 0.04); border-radius: 2px; overflow: hidden; }
.td-mv-bar i { display: block; height: 100%; border-radius: 2px; }
.td-mv-bar i.up { background: rgba(52, 211, 153, 0.75); }
.td-mv-bar i.down { background: rgba(248, 113, 113, 0.75); margin-left: auto; }
.td-mv-pts, .td-mv-pct { text-align: right; }
.td-sec-list { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; }
.td-sec-row { display: grid; grid-template-columns: 150px 1fr 54px 58px; align-items: center; gap: 8px; font-size: 0.64rem; height: 14px; }
.td-sec-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-silver); }
.td-sec-bar { position: relative; height: 8px; background: rgba(255, 255, 255, 0.04); border-radius: 2px; }
.td-sec-bar::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255, 255, 255, 0.2); }
.td-sec-bar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.td-sec-bar i.up { background: rgba(52, 211, 153, 0.75); }
.td-sec-bar i.down { background: rgba(248, 113, 113, 0.75); }
.td-sec-row .num { text-align: right; }
.td-group-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border-subtle); font-size: 0.64rem; color: var(--text-silver); }
.td-gb-item b { margin-left: 3px; }

/* Right column */
.td-panel-ladder { flex: 1.25 1 0; }
.td-panel-alerts { flex: 1 1 0; }
.td-ladder-cols, .td-lad-row { display: grid; grid-template-columns: 66px minmax(0, 1fr) 44px 50px; gap: 6px; align-items: center; }
.td-ladder-cols { font-size: 0.56rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; padding: 0 4px 2px; border-bottom: 1px solid var(--border-subtle); }
.td-ladder-cols .num { text-align: right; }
.td-ladder { flex: 1 1 auto; overflow-y: auto; scrollbar-width: thin; display: flex; flex-direction: column; justify-content: center; }
.td-lad-row { font-size: 0.64rem; padding: 1px 4px; height: 17px; border-left: 2px solid transparent; }
.td-lad-row .num { text-align: right; }
.td-lad-row .td-lad-px { text-align: left; color: var(--text-chalk); }
.td-lad-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-silver); }
.td-lad-row.res .td-lad-d, .td-lad-row.res .td-lad-dp { color: rgba(248, 113, 113, 0.85); }
.td-lad-row.sup .td-lad-d, .td-lad-row.sup .td-lad-dp { color: rgba(52, 211, 153, 0.85); }
.td-lad-row.strong .td-lad-lbl, .td-lad-row.strong .td-lad-px { font-weight: 700; color: var(--text-chalk); }
.td-lad-row.nearest.res { border-left-color: var(--alert-deficit); background: rgba(248, 113, 113, 0.06); }
.td-lad-row.nearest.sup { border-left-color: var(--alert-surplus); background: rgba(52, 211, 153, 0.06); }
.td-lad-row.now { background: var(--bg-elevated); border: 1px solid var(--border-highlight); border-left-width: 2px; border-left-color: var(--text-chalk); height: 20px; margin: 2px 0; font-weight: 700; }
.td-lad-row.now .td-lad-lbl { color: var(--text-chalk); }
.td-lad-row[data-zkey] { cursor: pointer; border-radius: 2px; }
.td-lad-row[data-zkey]:hover, .td-lad-row.hl { background: var(--bg-hover); }
.td-lad-row[data-zkey]:focus-visible { outline: 1px solid var(--text-silver); outline-offset: -1px; }
.td-lad-row.pinned { border-left-color: var(--text-chalk); }
.td-lad-row.pinned .td-lad-lbl::before { content: '◆ '; color: var(--text-chalk); }
.td-tt-levels { margin: 4px 0 3px; font-size: 0.64rem; }
.td-tt-levels > div { display: contents; }
.td-tt-foot { font-size: 0.66rem; }
.td-tt-hint { margin-top: 3px; font-size: 0.56rem; color: var(--text-muted); }
.td-alerts { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; scrollbar-width: thin; }
.td-alert { display: grid; grid-template-columns: 36px 12px 1fr; gap: 5px; align-items: baseline; padding: 2px 3px; font-size: 0.64rem; border-bottom: 1px solid rgba(255, 255, 255, 0.03); }
.td-alert:first-child { background: rgba(255, 255, 255, 0.03); }
.td-al-t { color: var(--text-muted); }
.td-al-txt { color: var(--text-chalk); }
.td-alert.up .td-al-i { color: var(--alert-surplus); }
.td-alert.down .td-al-i { color: var(--alert-deficit); }
.td-alert.warn .td-al-i, .td-alert.warn .td-al-txt { color: var(--alert-warning); }
.td-count { padding: 0 6px; }

/* Treemap */
.td-treemap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.td-tm-sector { position: absolute; box-sizing: border-box; border: 1px solid var(--bg-app); }
.td-tm-sector-lbl {
  position: absolute; left: 3px; top: 0; right: 3px; height: 13px; line-height: 13px;
  font-size: 0.56rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-silver); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.td-tm-sector-lbl.up { color: var(--alert-surplus); }
.td-tm-sector-lbl.down { color: var(--alert-deficit); }
.td-tm-tile {
  position: absolute; box-sizing: border-box; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 1px; transition: background-color 600ms ease; cursor: default;
}
.td-tm-tile:hover { outline: 1px solid var(--text-chalk); z-index: 2; }
.td-tm-tile b { font-size: 0.6rem; font-weight: 700; color: #fff; line-height: 1.05; }
.td-tm-tile b.lg { font-size: 0.78rem; }
.td-tm-tile span { font-family: var(--font-mono); font-size: 0.56rem; color: rgba(255, 255, 255, 0.85); line-height: 1.1; }

/* Tooltip */
.td-tooltip {
  position: fixed; z-index: 4000; width: 230px; padding: 7px 9px; pointer-events: none;
  background: rgba(20, 20, 22, 0.97); border: 1px solid var(--border-highlight); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); font-size: 0.66rem;
}
.td-tooltip[hidden] { display: none; }
.td-tt-head { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-mono); }
.td-tt-head b { font-size: 0.86rem; font-family: var(--font-sans); }
.td-tt-sub { color: var(--text-muted); font-size: 0.6rem; margin: 1px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-tt-grid { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; }
.td-tt-grid span { color: var(--text-muted); }
.td-tt-grid b { text-align: right; font-weight: 600; }
.td-tt-spark { margin-top: 5px; min-height: 34px; display: flex; align-items: center; justify-content: center; }

/* ==========================================================================
   Admin Cockpit & Systems Health (Section 8 Tab)
   ========================================================================== */
.admin-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.admin-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 12px;
}

.admin-subsystem-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: border-color var(--transition-fast);
}

.admin-subsystem-box:hover {
  border-color: var(--border-highlight);
}

.admin-subsystem-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.admin-subsystem-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.74rem;
  color: var(--text-silver);
}

.admin-subsystem-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.btn-compact {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-chalk);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-compact:hover {
  background: var(--bg-card);
  border-color: var(--border-highlight);
  color: #ffffff;
}

.btn-compact:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
}

.status-pill-active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--accent-emerald);
}

/* Card 4: Security, Active Sessions & Password Management */
.admin-sessions-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.admin-sessions-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-sessions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-sessions-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-chalk);
}

.admin-sessions-table-wrap {
  width: 100%;
  max-height: 280px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#admin-sessions-table {
  width: 100%;
  min-width: 480px;
}

#admin-sessions-table th,
#admin-sessions-table td {
  white-space: nowrap;
  padding: 8px 10px;
}

#admin-sessions-table .col-sess-user {
  min-width: 80px;
}

#admin-sessions-table .col-sess-ip {
  min-width: 100px;
}

#admin-sessions-table .col-sess-created {
  min-width: 130px;
}

#admin-sessions-table .col-sess-token {
  min-width: 85px;
}

#admin-sessions-table .col-sess-action {
  min-width: 75px;
  text-align: center;
}

.admin-password-box {
  background: var(--bg-hover);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ==========================================================================
   09. MODAL DIALOGS, OVERLAYS & TOOLTIPS
   ========================================================================== */

/* Modal Dialog Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modalFadeIn 0.15s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Mobile bottom-sheet entrance (consumed by the 600px breakpoint in Section 10) */
@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-modal-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.modal-form {
  padding: 14px 18px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}


.form-grid-identity {
  display: grid;
  grid-template-columns: 1.1fr 2.4fr 1.3fr;
  gap: 10px;
}

.form-grid-account {
  display: grid;
  grid-template-columns: 1.8fr 0.8fr 1.6fr;
  gap: 10px;
}

.form-grid-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.form-grid-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.holding-info-icon {
  font-size: 0.76rem;
  cursor: help;
  opacity: 0.85;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.holding-info-icon:hover {
  opacity: 1;
  transform: scale(1.18);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.form-group label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.form-input,
.form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.84rem;
  padding: 6px 9px;
  height: 33px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select {
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

/* Modal Cash Position Toggle Card */
.form-cash-toggle-card {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.form-cash-toggle-card:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.cash-toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  width: 100%;
}

.cash-toggle-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #10b981;
}

.cash-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cash-toggle-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Cash Balance Input Section */
.form-cash-balance-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.cash-balance-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cash-balance-prefix {
  position: absolute;
  left: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-emerald-light);
  pointer-events: none;
}

.cash-balance-input {
  padding-left: 28px !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  height: 42px !important;
  color: var(--alert-surplus) !important;
}

/* Disabled styling in modal */
.form-input:disabled,
.form-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   Awaiting & Upcoming Dividend Payments Tracker
   ========================================================================== */
.awaiting-card {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  position: relative;
}

.awaiting-kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 0.75rem;
}

.awaiting-kpi-label {
  color: var(--text-muted);
  font-weight: 500;
}

.awaiting-kpi-val {
  color: var(--text-chalk);
  font-weight: 700;
  font-size: 0.85rem;
}

.awaiting-kpi-sub {
  color: var(--text-silver);
  font-size: 0.75rem;
  font-weight: 600;
}

/* In-flight glowing status badge (Functional Amber Alert) */
.badge-inflight {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
}

.badge-upcoming {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-silver);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
}

/* Rate Change Trend Badges */
.rate-trend-up {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(52, 211, 153, 0.10);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: var(--alert-surplus);
  font-size: 0.70rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}

.rate-trend-down {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(248, 113, 113, 0.10);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--alert-deficit);
  font-size: 0.70rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}

.rate-trend-same {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-lead);
  font-size: 0.70rem;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 3px;
}

.countdown-pill {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.countdown-pill.due-tomorrow {
  color: #fbbf24;
  font-weight: 700;
}

.countdown-pill.due-soon {
  color: var(--text-chalk);
}

.btn-apply-rate {
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  color: var(--text-chalk);
  padding: 2px 8px;
  font-size: 0.70rem;
  font-weight: 700;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-apply-rate:hover {
  background: #ededf0;
  color: #0d0d0e;
  border-color: #ededf0;
}

.inv-div-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   Table Sorting & Column Filtering System
   ========================================================================== */
.data-table th.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.data-table th.sortable-th:hover {
  background: var(--bg-hover);
  color: var(--text-chalk);
}

.data-table th.sortable-th:focus-visible {
  outline: 1.5px solid #ededf0;
  outline-offset: -2px;
}

.th-sort-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-icon {
  display: inline-block;
  font-size: 0.65rem;
  color: var(--text-dim);
  transition: color var(--transition-fast);
  line-height: 1;
}

.sortable-th:hover .sort-icon {
  color: var(--text-secondary);
}

.sortable-th[aria-sort="ascending"] .sort-icon,
.sortable-th[aria-sort="descending"] .sort-icon {
  color: #ededf0;
  font-weight: 900;
}

.sortable-th[aria-sort="ascending"],
.sortable-th[aria-sort="descending"] {
  color: #ededf0;
  background: rgba(255, 255, 255, 0.05);
}

.table-filter-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-draft);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.75rem;
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.filter-label {
  color: var(--text-secondary);
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.table-filter-input,
.table-filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-main);
  font-size: 0.74rem;
  padding: 3px 8px;
  height: 26px;
  transition: border-color var(--transition-fast);
}

.table-filter-input:focus,
.table-filter-select:focus {
  border-color: var(--border-focus);
  outline: none;
}

.table-filter-input::placeholder {
  color: var(--text-dim);
}

.btn-filter-reset {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.70rem;
  font-weight: 600;
  padding: 3px 8px;
  height: 26px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
  margin-left: auto;
}

.btn-filter-reset:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--alert-deficit);
}

.filter-count-badge {
  font-size: 0.70rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 2px 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  white-space: nowrap;
}

/* ==========================================================================
   Unified Institutional User Menu & Avatar Dropdown
   ========================================================================== */
.user-session-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 3px 8px 3px 4px;
  height: 28px;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  color: var(--text-chalk);
  font-family: var(--font-sans);
  outline: none;
}

.user-menu-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.user-menu-btn.open {
  background: var(--bg-hover);
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

.user-avatar-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
  position: relative;
}

.user-avatar-circle.large {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
}

.user-avatar-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  border: 1px solid var(--bg-surface);
}

.user-menu-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-chalk);
  white-space: nowrap;
}

.user-role-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.user-role-badge.user-role-standard {
  background: rgba(154, 154, 162, 0.12);
  color: var(--text-silver);
  border: none;
}

.user-menu-chevron {
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  line-height: 1;
}

.user-menu-btn.open .user-menu-chevron {
  transform: rotate(180deg);
  color: var(--text-chalk);
}

/* Dropdown Popover Card */
.user-dropdown-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 248px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 1000;
  overflow: hidden;
  animation: userMenuPopIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes userMenuPopIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.user-dropdown-header {
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-dropdown-identity {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-dropdown-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-dropdown-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-chalk);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-subtext {
  font-size: 0.65rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-section {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.user-dropdown-section-title {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 4px 14px 4px 14px;
  text-transform: uppercase;
}

.user-dropdown-profiles-list {
  display: flex;
  flex-direction: column;
}

.user-dropdown-profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  font-size: 0.78rem;
  color: var(--text-silver);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.user-dropdown-profile-item:hover {
  background: var(--bg-hover);
  color: var(--text-chalk);
}

.user-dropdown-profile-item.active {
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent-emerald);
  font-weight: 700;
}

.user-dropdown-locked-note {
  padding: 8px 14px;
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: transparent;
  border: none;
  font-size: 0.76rem;
  color: var(--text-silver);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  font-family: var(--font-sans);
}

.user-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-chalk);
}

.dropdown-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dropdown-item-icon,
.dropdown-logout-icon {
  font-size: 0.85rem;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dropdown-item-label {
  white-space: nowrap;
}

.dropdown-item-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: 12px;
  flex-shrink: 0;
}

.user-dropdown-footer {
  padding: 4px 0;
}

.user-dropdown-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-silver);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  font-family: var(--font-sans);
}

.user-dropdown-logout-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--alert-deficit);
}

/* ==========================================================================
   Fullscreen Institutional Login Portal (ISA-101 Monochromatic)
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg-app);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

html.not-authenticated .login-overlay {
  display: flex !important;
}

html.not-authenticated .app-header,
html.not-authenticated .main-content {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 30px 24px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.login-brand-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.login-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-chalk);
  margin: 0;
}

.login-alert {
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--alert-deficit);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.login-input {
  width: 100%;
  height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xs);
  color: var(--text-chalk);
  font-size: 0.86rem;
  padding: 0 10px;
  transition: border-color var(--transition-fast);
}

.login-input:focus {
  border-color: var(--border-focus);
  outline: none;
}

.btn-login-submit {
  width: 100%;
  height: 38px;
  background: var(--text-chalk);
  color: var(--bg-app);
  border: none;
  border-radius: var(--radius-xs);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.btn-login-submit:hover {
  opacity: 0.92;
}

.btn-login-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-text-toggle {
  background: transparent;
  border: none;
  color: var(--text-silver);
  font-size: 0.70rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-text-toggle:hover {
  color: var(--text-chalk);
}

.login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.70rem;
  color: var(--text-lead);
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

/* ==========================================================================
   10. CONSOLIDATED RESPONSIVE BREAKPOINTS (Desktop-First Cascade)
   ========================================================================== */

/* --- Breakpoint: max-width 1400px (Large Desktops / High-DPI Displays) --- */
@media (max-width: 1400px) {
  .header-inner {
    justify-content: center;
  }
  .header-controls {
    margin: 0;
    justify-content: center;
  }
  .td-grid {
    grid-template-columns: 260px minmax(0, 1fr) 240px;
  }
}

/* --- Breakpoint: max-width 1200px (Standard Desktops & Laptops down to Mobile) --- */
@media (max-width: 1200px) {
  /* Hide Divs, Poller, SPX Breadth Ribbon & their separators as requested */
  .market-divs-meta,
  .sync-divs-sep,
  .market-poll-meta,
  .sync-poll-sep,
  .header-breadth-ribbon,
  .sync-breadth-sep,
  #market-poll-desc {
    display: none;
  }

  /* Hide Tax & DB status in macro strip & their separators as requested */
  .macro-item-tax,
  .macro-tax-sep,
  .macro-item-db,
  .macro-db-sep {
    display: none;
  }

  .header-market-sync .status-label {
    display: none;
  }

  /* Trader Desk: natural-height 2-column flow (panels re-ordered, chart first) */
  .td-desk { height: auto; min-height: 0; }
  .td-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: none;
  }
  .td-col { display: contents; }
  .td-panel-chart { grid-column: 1 / -1; order: 1; height: 420px; }
  .td-panel-ladder { order: 2; height: 360px; }
  .td-panel-movers { order: 3; height: 360px; }
  .td-panel-indexes { order: 4; height: 340px; }
  .td-panel-breadth { order: 5; height: 340px; }
  .td-panel-alerts { grid-column: 1 / -1; order: 6; height: 220px; }
  .td-panel-map { grid-column: 1 / -1; order: 7; height: 320px; }
}

/* --- Breakpoint: max-width 1100px (Landscape Tablets & Compact Desktops) --- */
@media (max-width: 1100px) {
  .grid-5,
  .breadth-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* --- Breakpoint: max-width 1024px (Tablets & Netbooks) --- */
@media (max-width: 1024px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: center;
    padding: 6px 12px;
  }
  .header-controls {
    justify-content: center;
    gap: 6px;
  }
  .dashboard-charts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* --- Breakpoint: max-width 900px (Portrait Tablets & Large Phablets) --- */
@media (max-width: 900px) {
  .header-nav-inner {
    justify-content: flex-start;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .spendable-hero-grid {
    grid-template-columns: 1fr;
  }
  .cushion-metrics-grid {
    grid-template-columns: 1fr;
  }
  .admin-sessions-grid {
    grid-template-columns: 1fr;
  }
  /* Trader Desk single column: levels → movers → breadth → chart → indexes → alerts → map */
  .td-grid { grid-template-columns: minmax(0, 1fr); }
  .td-panel-chart, .td-panel-alerts, .td-panel-map { grid-column: auto; }
  .td-panel-ladder { order: 1; height: 340px; }
  .td-panel-movers { order: 2; height: auto; min-height: 240px; }
  .td-panel-breadth { order: 3; }
  .td-panel-chart { order: 4; height: 360px; }
  .td-panel-indexes { order: 5; }
  .td-panel-alerts { order: 6; }
  .td-panel-map { order: 7; height: 300px; }
  .td-strip-right { margin-left: 0; }
}

/* --- Breakpoint: max-width 860px --- */
@media (max-width: 860px) {
  .grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .td-movers { grid-template-columns: 1fr; gap: 6px; overflow: visible; }
  .td-sec-row { grid-template-columns: 110px 1fr 48px 52px; }
  .td-panel-head { flex-wrap: wrap; white-space: normal; }
}

/* --- Breakpoint: max-width 800px --- */
@media (max-width: 800px) {
  .pros-cons-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Breakpoint: max-width 768px (Mobile & Small Tablets) --- */
@media (max-width: 768px) {
  /* Streamlined Single-Row Navigation Matrix (All 7 tabs on 1 row) */
  .header-nav-bar {
    padding: 2px 0 3px;
  }
  .header-nav-inner {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 1px;
    padding: 2px 4px;
    overflow-x: hidden;
    white-space: nowrap;
    mask-image: none;
    -webkit-mask-image: none;
    width: 100%;
  }
  .nav-anchor-item {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 1px;
    font-size: 0.74rem;
    min-height: 42px;
    text-align: center;
    white-space: nowrap;
    border-radius: var(--radius-xs);
  }
  .nav-anchor-item .nav-item-icon {
    font-size: 0.90rem;
    margin: 0;
    opacity: 0.95;
  }
  .nav-anchor-item .nav-text-full {
    display: none;
  }
  .nav-anchor-item .nav-text-short {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    color: #B0B0B8;
  }
  .nav-anchor-item.active .nav-text-short {
    color: #EDEDF0;
    font-weight: 700;
  }
  .nav-anchor-item::after {
    bottom: 0;
    left: 8%;
    right: 8%;
    width: auto;
    height: 2px;
  }

  .main-content {
    padding: 0 16px;
    margin: 14px auto 0;
  }
  .cockpit-sliders-panel {
    grid-template-columns: 1fr;
  }
  .breadth-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .breadth-controls-bar,
  .heatmap-controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .breadth-controls-left,
  .breadth-controls-right {
    max-width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
  }
  .breadth-controls-left .segmented-btn-group {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .breadth-controls-left .segmented-btn-group::-webkit-scrollbar {
    display: none;
  }
  .heatmap-controls-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .heatmap-control-item {
    max-width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
  }
  #heatmap-index-toggle {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #heatmap-index-toggle::-webkit-scrollbar {
    display: none;
  }
  .heatmap-controls-right {
    justify-content: flex-end;
    max-width: 100%;
    box-sizing: border-box;
  }
  .heatmap-waterfall-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .heatmap-hud-bar {
    width: 100%;
    flex-wrap: wrap;
  }
  .heatmap-canvas-wrap {
    height: 200px;
  }
  .breadth-trend-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .breadth-trend-header-right {
    width: 100%;
    justify-content: space-between;
  }

  /* Heatmap constituent well to prevent endless document scrolling */
  .heatmap-grid-container {
    max-height: 360px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 4px;
  }

  /* Sticky Table Columns: Keep primary key columns frozen while scrolling horizontally */
  #estate-table th:first-child,
  #estate-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.45);
  }
  #estate-table th:first-child {
    z-index: 4;
    background: #101012;
  }
  #estate-table tr:hover td:first-child {
    background: var(--bg-hover);
  }

  #inventory-table th:first-child,
  #inventory-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
    width: 74px;
    min-width: 74px;
    max-width: 74px;
    padding: 6px 4px;
  }
  #inventory-table th:nth-child(2),
  #inventory-table td:nth-child(2) {
    position: sticky;
    left: 74px;
    z-index: 3;
    background: var(--bg-surface);
    width: 106px;
    min-width: 106px;
    max-width: 106px;
    padding: 6px 6px;
    box-shadow: 3px 0 8px rgba(0, 0, 0, 0.5);
  }
  #inventory-table th:first-child,
  #inventory-table th:nth-child(2) {
    z-index: 4;
    background: #101012;
  }
  #inventory-table tr:hover td:first-child,
  #inventory-table tr:hover td:nth-child(2) {
    background: var(--bg-hover);
  }
  #inventory-table .col-acct-badge {
    font-size: 0.68rem;
    gap: 3px;
    white-space: normal;
  }
  #inventory-table .col-acct-badge .acct-glyph {
    font-size: 0.70rem;
  }
  #inventory-table .col-acct-badge .acct-name {
    font-size: 0.66rem;
    line-height: 1.15;
    word-break: break-word;
  }
  #inventory-table td:nth-child(2) .ticker-yahoo-link span {
    font-size: 0.86rem;
  }
  #inventory-table td:nth-child(2) .col-category-text {
    font-size: 0.64rem;
    padding: 1px 3px;
  }
  #inventory-table td:nth-child(2) > div:nth-child(2) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 96px;
    font-size: 0.68rem;
  }
  #inventory-table .inv-div-pill {
    font-size: 0.64rem;
    padding: 1px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 96px;
    margin-top: 2px;
  }

  #awaiting-payments-table th:first-child,
  #awaiting-payments-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
    min-width: 80px;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.45);
  }
  #awaiting-payments-table th:first-child {
    z-index: 4;
    background: #101012;
  }
  #awaiting-payments-table tr:hover td:first-child {
    background: var(--bg-hover);
  }

  .breadth-table th:first-child,
  .breadth-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
    min-width: 120px;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.45);
  }
  .breadth-table th:first-child {
    z-index: 4;
    background: var(--bg-surface);
  }
  .breadth-table tr:hover td:first-child {
    background: var(--bg-hover);
  }

  #sim-milestone-table th:first-child,
  #sim-milestone-table td:first-child,
  #sim-units-milestone-table th:first-child,
  #sim-units-milestone-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
    min-width: 75px;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.45);
  }
  #sim-milestone-table th:first-child,
  #sim-units-milestone-table th:first-child {
    z-index: 4;
    background: #101012;
  }
  #sim-milestone-table tr:hover td:first-child,
  #sim-units-milestone-table tr:hover td:first-child {
    background: var(--bg-hover);
  }

  /* Responsive Active Sessions Cards (Eliminates horizontal scrolling on mobile) */
  .admin-sessions-table-wrap {
    overflow-x: hidden;
    max-height: 340px;
    overflow-y: auto;
  }
  #admin-sessions-table {
    min-width: 0;
    width: 100%;
    display: block;
    border-collapse: separate;
  }
  #admin-sessions-table thead {
    display: none;
  }
  #admin-sessions-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  #admin-sessions-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "user action"
      "ip ip"
      "created token";
    gap: 4px 8px;
    padding: 10px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    width: 100%;
    transition: background var(--transition-fast), border-color var(--transition-fast);
  }
  #admin-sessions-table tbody tr:has(td[colspan]) {
    display: block;
    padding: 0;
    background: transparent;
    border: none;
  }
  #admin-sessions-table tbody td[colspan] {
    grid-column: 1 / -1;
    display: block;
    width: 100%;
    text-align: center;
    padding: 16px;
    border: none;
    box-sizing: border-box;
  }
  #admin-sessions-table tbody tr:hover:not(:has(td[colspan])) {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
  }
  #admin-sessions-table td {
    padding: 0;
    border: none;
    white-space: normal;
  }
  #admin-sessions-table .col-sess-user {
    grid-area: user;
    min-width: 0;
    position: static;
    box-shadow: none;
    background: transparent;
    font-size: 0.85rem;
    align-self: center;
  }
  #admin-sessions-table .col-sess-action {
    grid-area: action;
    min-width: 0;
    align-self: center;
    text-align: right;
    justify-self: end;
  }
  #admin-sessions-table .col-sess-ip {
    grid-area: ip;
    min-width: 0;
    font-size: 0.72rem;
    color: var(--text-silver);
    word-break: break-all;
    line-height: 1.35;
    padding: 2px 0;
  }
  #admin-sessions-table .col-sess-created {
    grid-area: created;
    min-width: 0;
    font-size: 0.68rem;
    color: var(--text-muted);
    align-self: center;
  }
  #admin-sessions-table .col-sess-token {
    grid-area: token;
    min-width: 0;
    font-size: 0.68rem;
    color: var(--text-muted);
    align-self: center;
    text-align: right;
    justify-self: end;
  }
  #admin-sessions-table .col-sess-token::before {
    content: "Token: ";
    color: var(--text-muted);
  }
}

/* --- Breakpoint: max-width 680px (Modal Dialogs on Narrow Screens) --- */
@media (max-width: 680px) {
  .form-grid-identity,
  .form-grid-account,
  .form-grid-metrics,
  .form-grid-info {
    grid-template-columns: 1fr;
  }
}

/* --- Breakpoint: max-width 600px (Mobile Header, Nav Bar & Bottom-Sheet Modals) --- */
@media (max-width: 600px) {
  .main-content {
    padding: 0 10px;
    margin: 10px auto 0;
  }
  .grid-4 {
    grid-template-columns: 1fr;
  }
  #section-admin .card {
    padding: 14px 12px;
  }
  .admin-health-grid {
    grid-template-columns: 1fr;
  }

  /* Streamlined mobile header (eliminates left/right clipping & height bloat) */
  .header-inner {
    padding: 4px 8px;
    justify-content: center;
  }
  .header-controls {
    justify-content: center;
    gap: 4px;
    width: 100%;
    margin: 0;
  }
  .header-market-sync {
    padding: 2px 6px;
    gap: 6px;
  }
  .header-breadth-ribbon {
    display: none;
  }
  .macro-params-strip {
    order: 4;
    padding: 2px 6px;
    gap: 6px;
    width: 100%;
    justify-content: center;
  }
  .macro-params-strip .macro-item {
    gap: 3px;
    font-size: 0.70rem;
  }
  .btn-sync-refresh {
    padding: 3px 6px;
    font-size: 0.70rem;
    min-height: 28px;
  }
  .user-session-wrap {
    order: 3;
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    display: inline-flex;
  }
  .user-menu-btn {
    padding: 2px 7px 2px 3px;
    height: 26px;
    gap: 5px;
  }
  .user-menu-btn .user-role-badge {
    display: none;
  }
  .user-menu-name {
    font-size: 0.72rem;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .user-dropdown-popover {
    left: auto;
    right: 0;
    max-width: min(280px, calc(100vw - 20px));
  }

  /* Mobile Streamlined Single-Row Navigation (All 7 tabs on 1 row) */
  .header-nav-inner {
    padding: 2px 2px;
    gap: 1px;
    flex-wrap: nowrap;
    overflow-x: hidden;
    width: 100%;
  }
  .nav-anchor-item {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    padding: 3px 1px;
    min-height: 40px;
  }
  .nav-anchor-item .nav-item-icon {
    font-size: 0.88rem;
  }
  .nav-anchor-item .nav-text-short {
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* Mobile Bottom-Sheet Modal Drawer */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    animation: slideUpModal 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-surface);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-medium);
  }
  .btn-modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
  }
  .modal-form {
    padding: 14px 16px 20px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }
  .modal-actions {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(20, 20, 22, 0.98);
    backdrop-filter: blur(8px);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-medium);
    z-index: 10;
    display: flex;
    gap: 10px;
    margin-top: 0;
  }
  .modal-actions .btn {
    flex: 1;
    height: 42px;
    font-size: 0.88rem;
    justify-content: center;
  }
  .form-input,
  .form-select {
    font-size: 16px; /* Prevents auto-zooming in mobile browsers */
    height: 38px;
  }

  /* Range sliders: Larger thumb for fingertip precision */
  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }
  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }

  .spend-freq-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .app-update-inner {
    flex-wrap: wrap;
    gap: 8px;
  }
  .app-update-msg {
    width: 100%;
  }
  .update-text {
    white-space: normal;
  }
  .btn-update-refresh {
    flex: 1;
  }
}

/* --- Breakpoint: max-width 520px (Compact Mobile: 2-Column KPI Architecture) --- */
@media (max-width: 520px) {
  /* 2-Column KPI Grid with Consolidated Value Hero */
  .grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }
  #kpi-card-consolidated {
    grid-column: 1 / -1;
    padding: 12px 14px;
  }
  .grid-5 > .kpi-card {
    padding: 10px 10px;
    min-height: auto;
  }
  .grid-5 .kpi-header {
    margin-bottom: 2px;
  }
  .grid-5 .kpi-label {
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .grid-5 .kpi-value {
    font-size: 1.15rem;
  }
  .grid-5 .kpi-subtext {
    font-size: 0.68rem;
    margin-top: 2px;
  }
  #kpi-card-consolidated .kpi-value {
    font-size: 1.45rem;
  }

  /* Compact Spendable Cash Cockpit Hero */
  .spendable-hero-card {
    padding: 14px;
  }
  #spend-amount-monthly {
    font-size: 1.6rem;
  }
  #spend-amount-annual {
    font-size: 1.0rem;
  }

  .awaiting-card .card-header > div {
    max-width: 100%;
    min-width: 0;
  }
  #awaiting-filter-seg {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #awaiting-filter-seg::-webkit-scrollbar {
    display: none;
  }

  .table-filter-strip {
    padding: 6px 8px;
    gap: 6px;
  }
  .filter-group {
    gap: 4px;
  }
  .table-filter-input,
  .table-filter-select {
    font-size: 0.72rem;
    height: 26px;
  }

  .breadth-kpi-grid {
    grid-template-columns: 1fr;
  }
  .divergence-grid {
    grid-template-columns: 1fr;
  }
  .heatmap-flat-grid {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 3px;
  }
  .heatmap-tile {
    height: 36px;
  }
  .heatmap-tile-sym {
    font-size: 0.64rem;
  }
  .heatmap-tile-pct {
    font-size: 0.54rem;
  }
  .toast-notice {
    top: 14px;
    right: 14px;
    left: 14px;
    justify-content: center;
  }
  .td-tick { font-size: 0.6rem; padding: 2px 6px; }
  .td-tick-px { display: none; }
}

/* --- Breakpoint: max-width 380px (Standard Narrow Android Phones) --- */
@media (max-width: 380px) {
  .market-quotes-meta,
  .sync-quotes-sep {
    display: none;
  }
  .grid-5 .kpi-value {
    font-size: 1.02rem;
  }
  #kpi-card-consolidated .kpi-value {
    font-size: 1.30rem;
  }
  .header-controls {
    gap: 3px;
  }
  .btn-sync-refresh {
    padding: 2px 4px;
    font-size: 0.66rem;
  }
  .badge {
    padding: 2px 4px;
    font-size: 0.68rem;
  }
  .input-compact-wrap {
    padding: 1px 4px;
  }
  #top-fx-input {
    width: 52px;
    font-size: 0.74rem;
  }
  .nav-anchor-item {
    padding: 3px 0;
    min-height: 38px;
  }
  .nav-anchor-item .nav-item-icon {
    font-size: 0.82rem;
  }
  .nav-anchor-item .nav-text-short {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: -0.025em;
  }
}

/* --- Accessibility: prefers-reduced-motion (exempt from width ordering) ---
   Neutralizes infinite pulse/spin loops and transitions for users who request
   reduced motion at the OS level. --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
