/* IB Deal-Sourcing Platform — Enterprise Financial Theme */

/* Google Fonts — selectable UI fonts (see FONTS in app.py) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Roboto:wght@400;500;700&family=Lato:wght@400;700&family=Merriweather:wght@400;700&display=swap');

/* ---- PERFORMANCE ---- */
* {
  -webkit-tap-highlight-color: transparent;
}

/* ---- DESIGN TOKENS ---- */
:root {
  --bg-base:        #ffffff;
  --bg-page:        #ffffff;
  --bg-sidebar:     #000000;
  --bg-card:        #ffffff;
  --bg-input:       #ffffff;
  --bg-hover:       #f8f9fb;

  --border-subtle:  transparent;
  --border-medium:  transparent;

  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --text-inverse:   #ffffff;

  /* Black header */
  --navy-900:       #000000;
  --navy-800:       #1a1a1a;
  --navy-700:       #333333;
  --navy-600:       #4a4a4a;

  /* Accent colors */
  --accent-blue:    #2563eb;
  --accent-blue-light: #eff6ff;
  --accent-cyan:    #06b6d4;
  --color-green:    #10b981;
  --color-green-light: #d1fae5;
  --color-red:      #ef4444;
  --color-red-light: #fee2e2;
  --color-amber:    #f59e0b;
  --color-amber-light: #fef3c7;

  --shadow-sm:      none;
  --shadow-md:      none;
  --shadow-lg:      none;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ---- GLOBAL ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  margin: 0;
}
a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- HEADER ---- */
.app-header {
  background: var(--navy-900);
  color: var(--text-inverse);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.app-header .brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
}
.app-header nav {
  display: flex;
  align-items: center;
  margin-left: 48px;
  gap: 4px;
}
.app-header nav a {
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: color 0.1s, background 0.1s;
  text-decoration: none;
}
.app-header nav a:hover {
  color: white;
  background: rgba(255,255,255,0.1);
  text-decoration: none;
}
.app-header .user-area {
  display: flex;
  align-items: center;
  gap: 16px;
}
.app-header .user-tier {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: right;
}
.app-header .user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: white;
}
.app-header .user-avatar {
  width: 36px;
  height: 36px;
  background: var(--navy-700);
  border: 2px solid var(--navy-600);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: white;
}
.app-header .export-btn {
  background: #374151;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}
.app-header .export-btn:hover {
  background: #4b5563;
}

/* Legacy support */
.app-header h3 { display: none; }
.app-header .sub { display: none; }
.app-header .badge-stage { display: none; }

/* ---- CONTAINER ---- */
.container-fluid {
  padding: 24px 32px !important;
  max-width: 1600px;
  margin: 0 auto;
}

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- KPI BAR ---- */
.kpi-row {
  display: flex;
  gap: 48px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  padding: 24px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.stat-card {
  background: transparent;
  border: none;
  padding: 0;
  min-width: 120px;
}
.stat-card .stat-value {
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-bottom: 4px;
}
.stat-card .stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ---- FILTER PANEL ---- */
.filter-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.filter-panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.filter-group .form-control {
  height: 38px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-input);
}
.filter-group .form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ---- DATA TABLE ---- */
.data-table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.dash-table-container {
  background: var(--bg-card);
}
.dash-table-container .dash-spreadsheet-container {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
.dash-spreadsheet-inner table {
  background: var(--bg-card) !important;
}
.dash-header {
  background: var(--bg-page) !important;
  color: var(--text-secondary) !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  padding: 12px 16px !important;
}
.dash-table-container td.dash-cell,
.dash-table-container th.dash-header {
  border-left: none !important;
  border-right: none !important;
}
.dash-cell {
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  font-variant-numeric: tabular-nums;
  padding: 12px 16px !important;
  font-size: 0.875rem !important;
}
.dash-spreadsheet tr:hover td.dash-cell {
  background: #f9fafb !important;
}
.dash-spreadsheet-container {
  contain: layout style;
}
.dash-table-container {
  will-change: contents;
}

/* ---- DROPDOWNS ---- */
.Select-control {
  background-color: var(--bg-input) !important;
  border: 1px solid #d1d5db !important;
  border-radius: var(--radius-sm) !important;
  min-height: 38px !important;
}
.Select-control:hover {
  border-color: var(--border-medium) !important;
}
.is-focused:not(.is-open) > .Select-control {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1) !important;
}
.Select-menu-outer {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
  z-index: 1000;
}
.Select-option {
  padding: 10px 14px !important;
}
.Select-option.is-focused {
  background-color: var(--bg-hover) !important;
}
.Select-option.is-selected {
  background-color: var(--accent-blue-light) !important;
  color: var(--accent-blue) !important;
}
.Select-placeholder { color: var(--text-muted) !important; }
.Select-value-label { color: var(--text-primary) !important; }
.Select--multi .Select-value {
  background-color: var(--accent-blue-light) !important;
  border: none !important;
  border-radius: 4px !important;
}
.Select--multi .Select-value-label { color: var(--accent-blue) !important; }

/* ---- SLIDERS ---- */
.rc-slider-rail { background-color: var(--border-subtle) !important; height: 4px !important; }
.rc-slider-track { background-color: var(--accent-blue) !important; height: 4px !important; }
.rc-slider-handle {
  border: 2px solid var(--accent-blue) !important;
  background-color: var(--bg-card) !important;
  width: 16px !important;
  height: 16px !important;
  margin-top: -6px !important;
}
.rc-slider-mark-text { color: var(--text-muted) !important; font-size: 0.75rem !important; }

/* ---- BUTTONS ---- */
.btn {
  border-radius: var(--radius-sm) !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 10px 20px;
  transition: background 0.1s, transform 0.1s;
  border: none;
  will-change: background;
}
.btn-primary {
  background: var(--accent-blue) !important;
  color: white !important;
}
.btn-primary:hover {
  background: #1d4ed8 !important;
}
.btn:active {
  transform: scale(0.98);
}

/* ---- BADGES ---- */
.badge {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
}
.badge-success, .bg-success {
  background-color: var(--color-green-light) !important;
  color: #065f46 !important;
}
.badge-warning, .bg-warning {
  background-color: var(--color-amber-light) !important;
  color: #92400e !important;
}
.badge-danger, .bg-danger {
  background-color: var(--color-red-light) !important;
  color: #991b1b !important;
}

/* ---- RESULTS META ---- */
.results-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---- ALERTS ---- */
.alert {
  border-radius: var(--radius-md);
  border: none;
}
.alert-dark {
  background: var(--bg-page) !important;
  color: var(--text-secondary) !important;
}

/* ---- CART BAR ---- */
.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--navy-900);
  border-top: 1px solid var(--navy-700);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
.cart-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: white;
}
.cart-info {
  font-size: 0.9rem;
}
.cart-tickers {
  color: #60a5fa;
  font-weight: 500;
}

/* ---- MODALS ---- */
.modal-content {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  border-bottom: 1px solid var(--border-subtle) !important;
  padding: 20px 24px !important;
}
.modal-title {
  font-weight: 600;
  font-size: 1.1rem;
}
.modal-body { padding: 24px !important; }
.modal-footer { border-top: 1px solid var(--border-subtle) !important; }

/* Side drawer */
.side-drawer.modal-dialog {
  position: fixed !important;
  right: 0 !important;
  top: 0 !important;
  margin: 0 !important;
  max-width: 800px !important;
  width: 100%;
  height: 100vh !important;
}
.side-drawer .modal-content {
  min-height: 100vh;
  border-radius: 0 !important;
  border-left: 1px solid var(--border-subtle) !important;
}

/* ---- FORM ELEMENTS ---- */
.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.875rem;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-check-input:checked {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* ---- PROGRESS ---- */
.progress {
  background-color: var(--border-subtle);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  background: var(--accent-blue);
  transition: width 0.3s ease-out;
  will-change: width;
}

/* ---- TEXT UTILITIES ---- */
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--color-green) !important; }
.text-danger { color: var(--color-red) !important; }
.text-primary { color: var(--accent-blue) !important; }

/* ---- FOOTER ---- */
.app-footer {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 24px 0 48px;
  text-align: center;
}
.page-footer {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 32px;
  padding: 16px 0;
  text-align: center;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 999px; }

/* ---- PANELS (legacy) ---- */
.panel, .card {
  background: var(--bg-card) !important;
  border: 1px solid #e5e7eb !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
}
.panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ---- PLOTLY ---- */
.js-plotly-plot .plotly text { fill: var(--text-secondary) !important; }
.js-plotly-plot {
  contain: layout style;
}

/* ---- PERFORMANCE OPTIMIZATIONS ---- */
html {
  scroll-behavior: smooth;
}
.container-fluid {
  contain: layout;
}
.app-header {
  will-change: transform;
  backface-visibility: hidden;
}
/* Reduce paint on scroll */
.panel, .card, .filter-panel, .data-table-container {
  contain: layout style;
}
/* Faster loading spinner */
.dash-spinner {
  animation-duration: 0.6s !important;
}
/* Instant interactions */
input, select, button, a {
  touch-action: manipulation;
}
/* Optimize dropdown menus */
.Select-menu-outer {
  will-change: opacity, transform;
  contain: layout style;
}

/* ---- SMOOTH TRANSITIONS ---- */
.btn, a.btn {
  transition: all 0.15s ease-out !important;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn-outline-secondary {
  border: 1px solid #d1d5db !important;
  background: transparent !important;
  color: #374151 !important;
}
.btn-outline-secondary:hover {
  background: #f3f4f6 !important;
  border-color: #9ca3af !important;
}

/* Smooth table row hover */
.dash-spreadsheet tr td.dash-cell {
  transition: background 0.1s ease;
}

/* Smooth input focus */
input, .Select-control, textarea {
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

/* Smooth dropdown open */
.Select-menu-outer {
  animation: fadeSlideIn 0.15s ease-out;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Loading bar smooth animation */
.progress-bar {
  transition: width 0.4s ease-out !important;
}

/* Page transitions */
#_pages_content {
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

/* Fix dropdown z-index in tables */
.pipeline-row .Select-menu-outer,
.data-table-container .Select-menu-outer {
  z-index: 1000 !important;
}

/* Smoother chart rendering */
.js-plotly-plot {
  will-change: contents;
}
.js-plotly-plot .main-svg {
  contain: strict;
}

/* Watchlist sidebar styles */
#sidebar-groups > div:hover {
  background-color: #f3f4f6 !important;
}

#select-all-companies:hover {
  background-color: #dbeafe !important;
}

/* Delete button visibility */
.delete-watchlist-btn {
  opacity: 1;
  transition: opacity 0.15s ease;
}

/* Logo styling */
.app-header img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
}

/* Notes cell hover */
[id*="open-notes"]:hover {
  background-color: #f3f4f6 !important;
  border-color: #9ca3af !important;
}

/* User dropdown menu styles */
.user-dropdown .dropdown-toggle {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.user-dropdown .dropdown-toggle::after {
  display: none;
}

.user-dropdown .dropdown-toggle:hover,
.user-dropdown .dropdown-toggle:focus,
.user-dropdown .dropdown-toggle:active {
  background: transparent !important;
  box-shadow: none !important;
}

.user-dropdown .dropdown-menu {
  min-width: 220px;
  padding: 8px 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  margin-top: 8px;
}

.user-dropdown .dropdown-header {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 16px 4px;
}

.user-dropdown .dropdown-item {
  padding: 10px 16px;
  font-size: 0.875rem;
  color: #374151;
  display: flex;
  align-items: center;
}

.user-dropdown .dropdown-item:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.user-dropdown .dropdown-item.active {
  background-color: #eff6ff;
  color: #2563eb;
}

.user-dropdown .dropdown-item i {
  font-size: 0.95rem;
  color: #6b7280;
}

.user-dropdown .dropdown-item:hover i {
  color: #374151;
}

.user-dropdown .dropdown-divider {
  margin: 8px 0;
  border-color: #e5e7eb;
}

/* ============================================
   THEME: Dark Mode
   ============================================ */
body.theme-dark,
body.theme-dark #app-container {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
}

/* Fill the viewport so the themed (dark) background covers short pages — otherwise the
   white <html> background shows beneath, e.g. the pipeline page in dark mode. */
#app-container { min-height: 100vh; }
html:has(body.theme-dark) { background-color: #1e1e1e; }

body.theme-dark .container-fluid {
  background-color: #1e1e1e !important;
}

body.theme-dark .app-header {
  background: linear-gradient(135deg, #000000 0%, #1e1e1e 100%) !important;
  border-bottom: 1px solid #2f2f2f !important;
}

body.theme-dark .filter-panel {
  background-color: #1e1e1e !important;
  border: 1px solid #2f2f2f !important;
}

body.theme-dark .filter-panel-title,
body.theme-dark .page-title {
  color: #ffffff !important;
}

body.theme-dark .filter-panel-header {
  border-bottom-color: #2f2f2f !important;
}

body.theme-dark .form-label,
body.theme-dark label {
  color: #ffffff !important;
}

body.theme-dark .form-control,
body.theme-dark input[type="number"],
body.theme-dark input[type="text"] {
  background-color: #2f2f2f !important;
  border-color: #333333 !important;
  color: #ffffff !important;
}

body.theme-dark .form-control::placeholder {
  color: #ffffff !important;
}

/* Dropdown selects in dark mode */
body.theme-dark .Select-control {
  background-color: #2f2f2f !important;
  border-color: #333333 !important;
}

body.theme-dark .Select-value-label,
body.theme-dark .Select-placeholder {
  color: #ffffff !important;
}

body.theme-dark .Select-menu-outer {
  background-color: #1e1e1e !important;
  border-color: #333333 !important;
}

body.theme-dark .Select-option {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
}

body.theme-dark .Select-option:hover,
body.theme-dark .Select-option.is-focused {
  background-color: #2f2f2f !important;
}

/* Data table in dark mode */
body.theme-dark .data-table-container,
body.theme-dark .dash-table-container,
body.theme-dark .dash-spreadsheet-container {
  background-color: #1e1e1e !important;
}

body.theme-dark .dash-header,
body.theme-dark th {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
  border-color: #2f2f2f !important;
}

body.theme-dark td.dash-cell,
body.theme-dark td {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
  border-bottom-color: #2f2f2f !important;
}

body.theme-dark tr:hover td {
  background-color: #2f2f2f !important;
}

/* KPI cards in dark mode */
body.theme-dark .stat-card,
body.theme-dark .kpi-row > div {
  background-color: #1e1e1e !important;
  border-color: #2f2f2f !important;
}

body.theme-dark .stat-value {
  color: #ffffff !important;
}

body.theme-dark .stat-label {
  color: #ffffff !important;
}

body.theme-dark .page-subtitle {
  color: #ffffff !important;
}

/* Cart bar in dark mode */
body.theme-dark .cart-bar {
  background-color: #1e1e1e !important;
  border-top-color: #2f2f2f !important;
}

body.theme-dark .cart-bar .cart-inner {
  background-color: #000000 !important;
  color: #ffffff !important;
}

/* Modals in dark mode */
body.theme-dark .modal-content {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
  border-color: #333333 !important;
}

body.theme-dark .modal-header {
  border-bottom-color: #2f2f2f !important;
  color: #ffffff !important;
}

body.theme-dark .modal-footer {
  border-top-color: #2f2f2f !important;
}

body.theme-dark .modal-title {
  color: #ffffff !important;
}

/* Dropdown menu in dark mode */
body.theme-dark .dropdown-menu {
  background-color: #1e1e1e !important;
  border-color: #333333 !important;
}

body.theme-dark .dropdown-item {
  color: #ffffff !important;
}

body.theme-dark .dropdown-item:hover {
  background-color: #2f2f2f !important;
}

body.theme-dark .dropdown-header {
  color: #ffffff !important;
}

body.theme-dark .dropdown-divider {
  border-color: #2f2f2f !important;
}

body.theme-dark .page-footer {
  color: #ffffff !important;
}

/* Slider in dark mode */
body.theme-dark .rc-slider-track {
  background-color: #3b82f6 !important;
}

body.theme-dark .rc-slider-rail {
  background-color: #333333 !important;
}

body.theme-dark .rc-slider-dot {
  border-color: #333333 !important;
  background-color: #1e1e1e !important;
}

body.theme-dark .rc-slider-mark-text {
  color: #ffffff !important;
}

.theme-dark .Select-option {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
}

.theme-dark .Select-option:hover,
.theme-dark .Select-option.is-focused {
  background-color: #2f2f2f !important;
}

/* Cards / list-groups / accordions / popovers were never dark-themed, so in dark mode
   they stayed white while the body text went light — i.e. white text on a white box.
   Give every surface container a dark background + readable text. */
body.theme-dark .card,
body.theme-dark .card-body,
body.theme-dark .list-group,
body.theme-dark .list-group-item,
body.theme-dark .accordion,
body.theme-dark .accordion-item,
body.theme-dark .accordion-body,
body.theme-dark .popover,
body.theme-dark .popover-body,
body.theme-dark .toast,
body.theme-dark .toast-body {
  background-color: #1e1e1e !important;
  color: #ffffff !important;
  border-color: #2f2f2f !important;
}

body.theme-dark .card-header,
body.theme-dark .card-footer,
body.theme-dark .accordion-button,
body.theme-dark .list-group-item-action {
  background-color: #181818 !important;
  color: #ffffff !important;
  border-color: #2f2f2f !important;
}

body.theme-dark .accordion-button:not(.collapsed) {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

/* ---- Multi-select chips (Exchange, Priority Bucket, Sector …) ----
   Selected values render as chips with a light background; in dark mode that left
   light text on a light chip. Give the chips a dark surface. */
body.theme-dark .Select--multi .Select-value {
  background-color: #2f2f2f !important;
  border-color: #3a3a3a !important;
  color: #ffffff !important;
}
body.theme-dark .Select--multi .Select-value-label { color: #ffffff !important; }
body.theme-dark .Select--multi .Select-value-icon { border-right-color: #3a3a3a !important; }
body.theme-dark .Select--multi .Select-value-icon:hover {
  background-color: #3a1c1c !important;
  color: #ef4444 !important;
}

/* ---- Theme-aware content tokens ----
   The watchlist, pipeline and deep-dive pages set colors inline. Browsers normalize
   inline hex to rgb(), so matching the inline string in CSS is unreliable — instead the
   pages reference these variables (e.g. style={"color": "var(--c-strong)"}). Light values
   below match the original design; dark mode makes all text white and backgrounds dark. */
:root {
  --c-strong: #111827;   /* headings / primary text */
  --c-body:   #374151;   /* body text */
  --c-muted:  #6b7280;   /* secondary text */
  --c-faint:  #9ca3af;   /* captions / hints */
  --bg-surface:   #ffffff;   /* cards / white panels */
  --bg-soft:      #f5f7fa;   /* subtle grey panels */
  --bg-info:      #eff6ff;   /* blue callout */
  --bg-danger:    #fef2f2;   /* red callout */
  --bg-highlight: #fef08a;   /* yellow highlight */
  --bg-hover:     #ebedf0;   /* row/cell hover + active */
}
body.theme-dark {
  --c-strong: #ffffff;
  --c-body:   #ffffff;
  --c-muted:  #ffffff;
  --c-faint:  #ffffff;
  --bg-surface:   #232323;
  --bg-soft:      #292929;
  --bg-info:      #15233a;
  --bg-danger:    #3a1c1c;
  --bg-highlight: #4a431a;
  --bg-hover:     #2e2e2e;
  /* design tokens used by headings (h1–h6), page titles, panel/filter labels and
     plotly text — were never overridden, so the company name (an <h5>) stayed black. */
  --text-primary:   #ffffff;
  --text-secondary: #ffffff;
  --text-muted:     #ffffff;
}

/* bootstrap muted text → white in dark (no grey, per design) */
body.theme-dark .text-muted { color: #ffffff !important; }

/* Loading screen panel (and any .panel) — was a white box with a light border in dark. */
body.theme-dark .panel {
  background: #1e1e1e !important;
  border-color: #2f2f2f !important;
}

/* Cash/liquidity chart: identical in light & dark — fixed white card + fixed dark text,
   immune to the theme-driven plotly text color. */
.static-chart {
  background: #ffffff;
  border-radius: 8px;
  padding: 8px 6px;
}
.static-chart .js-plotly-plot .plotly text { fill: #4a4a4a !important; }

/* ============================================
   FONTS
   ============================================ */
.font-inter {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

.font-inter * {
  font-family: inherit;
}

.font-system {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

.font-system * {
  font-family: inherit;
}

.font-roboto {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.font-roboto * { font-family: inherit; }

.font-lato {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.font-lato * { font-family: inherit; }

.font-georgia {
  font-family: Georgia, 'Times New Roman', Times, serif !important;
}

.font-georgia * { font-family: inherit; }

.font-merriweather {
  font-family: 'Merriweather', Georgia, 'Times New Roman', serif !important;
}

.font-merriweather * { font-family: inherit; }

/* Analysis page section navigation */
.nav-link-item:hover {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

html {
  scroll-behavior: smooth;
}

/* Offset for sticky header when jumping to sections */
[id^="section-"] {
  scroll-margin-top: 120px;
}

/* ───────────────────────── Deep-dive page ───────────────────────── */
/* Sticky toolbar: sits just under the global app header (56px). */
.dd-toolbar {
  position: sticky;
  top: 56px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid #e5e7eb;
}
.dd-back { white-space: nowrap; }

/* Company switcher: prev · dropdown · next · counter */
.dd-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}
.dd-company-select { width: 320px; max-width: 42vw; font-size: 0.9rem; }
.dd-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 700;
  color: #374151;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.15s ease;
}
.dd-arrow:hover {
  background: #f3f4f6;
  color: #111827;
  border-color: #d1d5db;
}
.dd-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: #9ca3af;
  white-space: nowrap;
  min-width: 48px;
}

/* Body: constrain width so long content doesn't sprawl edge-to-edge. */
.dd-body {
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Smoothness: snappy, GPU-friendly interactions ──────────────────────── */
a, button, .dd-nav-link, .nav-link-item, .al-row, .alerts-nav-btn, .stat-card,
.app-header nav a, .dd-arrow {
  transition: background-color 0.12s ease, color 0.12s ease,
              border-color 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}
.al-row { cursor: default; }
.al-row:hover { background-color: var(--bg-soft); }     /* Gmail-style row hover */
html { scroll-behavior: smooth; }
body { text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
/* keep the sticky bars on their own compositor layer for jank-free scrolling */
.app-header, .dd-toolbar, .comps-overlay-bar { will-change: transform; transform: translateZ(0); }

/* Live Feed pulsing dot (so it reads as "live") */
.live-dot {
  color: #10b981;
  display: inline-block;
  animation: live-pulse 1.5s ease-in-out infinite;
}
@keyframes live-pulse {
  0%   { opacity: 1;    text-shadow: 0 0 0 rgba(16,185,129,0); }
  50%  { opacity: 0.45; text-shadow: 0 0 7px rgba(16,185,129,0.95); }
  100% { opacity: 1;    text-shadow: 0 0 0 rgba(16,185,129,0); }
}

/* Alerts row: dismiss revealed only on hover (harder to delete by accident) */
.al-dismiss-btn {
  cursor: pointer;
  color: var(--c-faint);
  font-size: 0.74rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.al-row:hover .al-dismiss-btn { opacity: 1; }
.al-dismiss-btn:hover { color: #ef4444; }

/* ── Alerts bell in the header (with notification badge) ─────────────────── */
.alerts-nav-btn {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.12s ease;
}
.alerts-nav-btn:hover { color: #ffffff; text-decoration: none; }
.alerts-badge {
  display: none;
  position: absolute;
  top: -7px;
  right: -10px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: #ef4444;
  color: #ffffff;
  border-radius: 9px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--navy-900);
}
.alerts-badge.show { display: inline-block; }

/* ── Deep-dive section nav (sticky sidebar, scroll-spy) ───────────────────── */
.dd-nav-sidebar {
  position: sticky;
  top: 120px;
  width: 152px;
  flex-shrink: 0;
  padding-right: 16px;
  align-self: flex-start;
}
.dd-nav-title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--c-faint);
  margin: 0 0 10px 12px;
}
.dd-nav { display: flex; flex-direction: column; gap: 2px; }
.dd-nav-link {
  display: block;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-muted);
  text-decoration: none;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.dd-nav-link:hover { color: var(--c-strong); background: var(--bg-soft); text-decoration: none; }
.dd-nav-link.active {
  color: #2563eb;
  background: var(--bg-info);
  border-left-color: #2563eb;
  font-weight: 600;
}

/* Comps company-name hover rationale — box visuals are inline on the element; this single
   rule reveals it on hover (and overrides the inline display:none). */
.comp-tip { position: relative; }
.comp-tip:hover .comp-tip-box { display: block !important; }

/* ── Comps full-screen overlay (Pull Comps) ──────────────────────────────── */
.comps-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg-page);
  overflow-y: auto;
}
.comps-overlay-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-soft);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.comps-overlay-body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
body.theme-dark .comps-overlay { background: #1e1e1e; }
body.theme-dark .comps-overlay-bar { background: #232323; border-bottom-color: #2f2f2f; }

/* Company logo tile next to the name in the overview header.
   The tile (white + bordered) is always shown; the image sits inside it.
   If a company has no logo, the tile stays as clean white space. */
.company-logo {
  width: 46px;
  height: 46px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  flex-shrink: 0;
  overflow: hidden;
}
.company-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* crisp downscaling of the high-res source logo */
  image-rendering: -webkit-optimize-contrast;
}
body.theme-dark .company-logo {
  background: #fff;            /* keep a light pad so dark logos stay visible */
  border-color: #2f2f2f;
}

/* Mandate page: accent blue matches the "Catalyst" logo color (#60a5fa). Scoped to
   this page only via .mandate-page so the rest of the app's blue is unchanged. */
.mandate-page { --accent-blue: #60a5fa; }
.mandate-page .btn-primary {
  background-color: #60a5fa;
  border-color: #60a5fa;
  color: #ffffff;
}
.mandate-page .btn-primary:hover,
.mandate-page .btn-primary:focus,
.mandate-page .btn-primary:active {
  background-color: #4f93e8;   /* a touch darker for hover/active */
  border-color: #4f93e8;
  color: #ffffff;
}

/* Dark mode */
body.theme-dark .dd-toolbar {
  background: rgba(0, 0, 0, 0.92);
  border-bottom-color: #2f2f2f;
}
body.theme-dark .dd-arrow {
  background: #1e1e1e;
  color: #e2e8f0;
  border-color: #2f2f2f;
}
body.theme-dark .dd-arrow:hover { background: #2f2f2f; color: #fff; }
