/* ═══════════════════════════════════════════════════════════════════════════
   1erminal — Design System
   Financial Intelligence Platform
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-void:       #0b1120;
  --bg-primary:    #060a14;
  --bg-secondary:  #0c1220;
  --bg-tertiary:   #111827;
  --bg-elevated:   #1a2340;
  --bg-hover:      #1e293b;
  --bg-active:     #233154;

  /* Borders */
  --border:        #1e2a45;
  --border-subtle: #151d30;
  --border-active: #2d3f6b;
  --border-focus:  #3b82f6;

  /* Text */
  --text-primary:   #e2e8f0;
  --text-secondary: #8892a8;
  --text-tertiary:  #5a6478;
  --text-muted:     #3d4658;

  /* Accents */
  --accent-blue:    #3b82f6;
  --accent-cyan:    #22d3ee;
  --accent-green:   #10b981;
  --accent-red:     #ef4444;
  --accent-amber:   #f59e0b;
  --accent-purple:  #8b5cf6;
  --accent-silver:  #94a3b8;
  --accent-gold:    #d4a853;

  /* Semantic */
  --positive:       #10b981;
  --negative:       #ef4444;
  --neutral:        #8892a8;
  --warning:        #f59e0b;
  --info:           #3b82f6;

  /* Signals */
  --signal-strong-buy:  #10b981;
  --signal-buy:         #34d399;
  --signal-hold:        #f59e0b;
  --signal-sell:        #f87171;
  --signal-strong-sell: #ef4444;

  /* Fonts */
  --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Sizing */
  --header-height: 60px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --status-height: 34px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 350ms ease;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(59,130,246,0.15);
}


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

html {
  font-size: 17.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { color: var(--accent-cyan); }

::selection {
  background: rgba(59,130,246,0.3);
  color: var(--text-primary);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button { cursor: pointer; }

.hidden { display: none !important; }
.screen { display: flex; }


/* ── Loading Screen ───────────────────────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.loading-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  animation: loadingPulse 2s ease-in-out infinite;
}

.loading-bar {
  width: 200px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}

.loading-bar-fill {
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 1px;
  animation: loadingSlide 1.5s ease-in-out infinite;
}

.loading-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 2px;
  text-transform: uppercase;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes loadingSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}


/* ── Auth Screen ──────────────────────────────────────────────────────────── */
/* ── Landing Page ─────────────────────────────────────────────────────────── */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-void);
  overflow-y: auto;
  overflow-x: hidden;
}

.landing {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(59,130,246,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 70% 50% at 50% 30%, black 10%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 70% 50% at 50% 30%, black 10%, transparent 70%);
}

/* ── Landing Nav ── */
.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(11,17,32,0.8);
  border-bottom: 1px solid var(--border-subtle);
}
.landing-nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.landing-nav-logo {
  height: 32px;
  width: auto;
}
.landing-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}
.landing-nav-link {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.landing-nav-link:hover { color: var(--text-primary); }

.btn-signin-sm {
  padding: 8px 20px;
  background: transparent;
  color: var(--accent-blue);
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
}
.btn-signin-sm:hover {
  background: var(--accent-blue);
  color: white;
}

/* ── Hero ── */
.landing-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 160px 32px 80px;
  min-height: 85vh;
}

.auth-pulse-line {
  position: absolute;
  width: 60%;
  max-width: 800px;
  height: 60px;
  color: var(--border-active);
  opacity: 0.4;
}
.landing-hero .auth-pulse-line:first-of-type { top: 25%; }
.landing-hero .auth-pulse-bottom { bottom: 10%; }

.pulse-path {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: pulseDraw 4s ease-in-out infinite;
}
.auth-pulse-bottom .pulse-path { animation-delay: 2s; }

@keyframes pulseDraw {
  0% { stroke-dashoffset: 1200; opacity: 0; }
  20% { opacity: 1; }
  60% { stroke-dashoffset: 0; opacity: 1; }
  80% { opacity: 0; }
  100% { stroke-dashoffset: -1200; opacity: 0; }
}

.landing-hero-logo {
  width: min(480px, 70vw);
  height: auto;
  margin-bottom: 32px;
}

.landing-headline {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.landing-subline {
  font-size: clamp(0.9rem, 2vw, 1.125rem);
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin-bottom: 40px;
}

.landing-hero-cta {
  display: flex;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.btn-signin-lg {
  padding: 14px 40px;
  background: linear-gradient(135deg, var(--accent-blue), #2563eb);
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 0 24px rgba(59,130,246,0.25);
}
.btn-signin-lg:hover {
  background: linear-gradient(135deg, #4f91f7, #3b82f6);
  box-shadow: 0 0 40px rgba(59,130,246,0.4);
  transform: translateY(-2px);
}

.landing-link-cta {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-active);
  padding-bottom: 2px;
  transition: color var(--transition-fast);
}
.landing-link-cta:hover { color: var(--text-primary); }

/* ── Section Shared ── */
.landing-section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 12px;
}
.landing-section-sub {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  text-align: center;
  margin-bottom: 40px;
}

/* ── Feature Grid ── */
.landing-features {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 80px 32px;
}
.landing-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.landing-feature-card {
  background: rgba(12,18,32,0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  transition: all var(--transition-base);
}
.landing-feature-card:hover {
  border-color: var(--border-active);
  background: rgba(26,35,64,0.5);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.landing-feature-icon {
  color: var(--accent-blue);
  margin-bottom: 16px;
}
.landing-feature-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.landing-feature-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Market Coverage ── */
.landing-coverage {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 60px 32px 40px;
}
.landing-market-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}
.landing-market {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: rgba(12,18,32,0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}
.landing-market:hover { border-color: var(--border-active); }
.landing-flag {
  font-size: 0.6875rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-blue);
  background: rgba(59,130,246,0.1);
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}
.landing-market-name {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ── Stats Bar ── */
.landing-stats {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 60px 32px;
  display: flex;
  justify-content: center;
  gap: 64px;
}
.landing-stat { text-align: center; }
.landing-stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.landing-stat-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* ── Bottom CTA ── */
.landing-bottom-cta {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 60px 32px 80px;
}
.landing-bottom-cta .landing-section-title { margin-bottom: 24px; }

/* ── Footer ── */
.landing-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border-subtle);
  padding: 24px 32px;
  margin-top: auto;
}
.landing-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.landing-footer-brand {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.landing-footer-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Landing Responsive ── */
@media (max-width: 768px) {
  .landing-feature-grid {
    grid-template-columns: 1fr;
  }
  .landing-stats {
    flex-wrap: wrap;
    gap: 32px;
  }
  .landing-stat { flex: 0 0 40%; }
  .landing-hero { padding-top: 120px; min-height: auto; }
  .landing-footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}
@media (max-width: 480px) {
  .landing-hero-cta { flex-direction: column; }
  .landing-nav-links .landing-nav-link { display: none; }
}


/* ── Header ───────────────────────────────────────────────────────────────── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

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

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-logo-img {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.header-center {
  flex: 1;
  max-width: 560px;
  margin: 0 16px;
}

.command-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 34px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.command-bar:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

.command-icon { color: var(--text-tertiary); flex-shrink: 0; }

.command-input {
  flex: 1;
  height: 100%;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

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

.command-shortcut {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 2px 6px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-user {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.header-user:hover { background: var(--bg-hover); }

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}


/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: var(--status-height);
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition-base);
  z-index: 40;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-item span,
.sidebar.collapsed .sidebar-footer { display: none; }

.sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 10px 0;
}

.sidebar-section {
  padding: 12px 8px 4px;
}

.sidebar-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 8px 6px;
  text-transform: uppercase;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 450;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  box-shadow: inset 3px 0 0 var(--accent-blue);
}

.sidebar-item.active svg { color: var(--accent-blue); }

.sidebar-item svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-version {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
}


/* ── Main Content ─────────────────────────────────────────────────────────── */
#main-content {
  position: fixed;
  top: var(--header-height);
  left: var(--sidebar-width);
  right: 0;
  bottom: var(--status-height);
  overflow-y: auto;
  overflow-x: hidden;
  transition: left var(--transition-base);
}

.sidebar.collapsed ~ #main-content {
  left: var(--sidebar-collapsed);
}

#page-content {
  padding: 20px;
  min-height: 100%;
}

#page-content.page-enter {
  animation: page-fade-in 0.18s ease-out;
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ── Status Bar ───────────────────────────────────────────────────────────── */
#status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--status-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 50;
}

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

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-indicator.connected { background: var(--accent-green); }
.status-indicator.error { background: var(--accent-red); }

.status-text {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.status-divider {
  color: var(--border);
  font-size: 0.6875rem;
}


/* ── Dropdown Menu ────────────────────────────────────────────────────────── */
.dropdown-menu {
  position: fixed;
  top: calc(var(--header-height) + 4px);
  right: 12px;
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 60;
}

.dropdown-header {
  padding: 10px 12px;
}

.dropdown-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dropdown-user-email {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.dropdown-item {
  display: block;
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition-fast);
}

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

.dropdown-item.danger { color: var(--accent-red); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }


/* ── Command Palette ──────────────────────────────────────────────────────── */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

#command-palette {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.command-palette-box {
  position: relative;
  width: 580px;
  max-height: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.command-palette-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-tertiary);
}

.palette-input {
  flex: 1;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

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

.command-palette-results {
  overflow-y: auto;
  padding: 8px;
}

.palette-section { margin-bottom: 8px; }

.palette-section-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 4px 8px 6px;
  text-transform: uppercase;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.palette-item:hover, .palette-item.active {
  background: var(--bg-hover);
}

.palette-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.palette-item-text {
  flex: 1;
  min-width: 0;
}

.palette-item-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-item-meta {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.palette-empty {
  padding: 12px 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}


/* ══════════════════════════════════════════════════════════════════════════
   PAGE COMPONENTS
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}


/* ── Cards / Panels ───────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.panel-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.panel-body {
  padding: 16px;
}

.panel-body.flush { padding: 0; }

.panel-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}


/* ── Grid Layouts ─────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

.grid-sidebar {
  grid-template-columns: 320px 1fr;
}

.grid-main-aside {
  grid-template-columns: 1fr 340px;
}

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
}


/* ── Stat Cards ───────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-active);
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 4px;
}

.stat-change.positive { color: var(--positive); }
.stat-change.negative { color: var(--negative); }

.stat-meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 4px;
}


/* ── Data Tables ──────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-tertiary);
  padding: 8px 12px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}

.data-table thead th.num { text-align: right; }

.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table thead th.sortable:hover { color: var(--text-secondary); }
.data-table thead th.sorted { color: var(--accent-blue); }

/* ── Filter Components ────────────────────────────────────────────────── */
.filter-label {
  display: block;
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 2px;
}

.filter-input {
  font-size: 0.75rem !important;
  padding: 3px 6px !important;
  height: 28px;
}

.filter-group {
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-group:hover { color: var(--text-primary); }

.filter-group .filter-chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform 0.15s;
}

.filter-group.collapsed .filter-chevron { transform: rotate(-90deg); }
.filter-group.collapsed + .filter-row { display: none !important; }

/* News item hover */
.news-item:hover { background: var(--bg-hover); }

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.row-selected { background: rgba(59,130,246,0.08); outline: 1px solid rgba(59,130,246,0.25); outline-offset: -1px; }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td {
  padding: 8px 12px;
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table td.num {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table td.positive { color: var(--positive); }
.data-table td.negative { color: var(--negative); }
.data-table td.muted { color: var(--text-tertiary); }

.ticker,
.data-table td.ticker {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-cyan);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.ticker:hover,
.data-table td.ticker:hover { color: var(--accent-blue); }

.data-table td.company-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact variant for dense overview panels */
.data-table.compact td {
  padding: 4px 10px;
  font-size: 0.75rem;
}
.data-table.compact td.muted {
  font-size: 0.6875rem;
  white-space: nowrap;
}
.data-table.compact td.num {
  font-variant-numeric: tabular-nums;
}
.data-table.compact tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.data-table.compact tbody tr:hover {
  background: var(--bg-hover);
}

/* ── Financial Statement Table ───────────────────────────────────────── */
.fin-table { border-collapse: collapse; width: 100%; }
.fin-table td, .fin-table th { font-variant-numeric: tabular-nums; }
.fin-table tbody tr:hover { background: var(--bg-hover); }
.fin-table tbody tr.fin-section-header:hover { background: var(--bg-primary); }
.fin-table td.num { text-align: right; font-family: var(--font-mono); font-size: 0.8rem; }


/* ── Signal Badges ────────────────────────────────────────────────────────── */
.signal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.signal-badge.strong-buy  { background: rgba(16,185,129,0.15); color: var(--signal-strong-buy); }
.signal-badge.buy         { background: rgba(52,211,153,0.12); color: var(--signal-buy); }
.signal-badge.hold        { background: rgba(245,158,11,0.12); color: var(--signal-hold); }
.signal-badge.sell        { background: rgba(248,113,113,0.12); color: var(--signal-sell); }
.signal-badge.strong-sell { background: rgba(239,68,68,0.15); color: var(--signal-strong-sell); }


/* ── Sector / Exchange Tags ───────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.tag.exchange {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-amber);
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.2);
}

.tag.sector {
  color: var(--accent-purple);
  background: rgba(139,92,246,0.08);
  border-color: rgba(139,92,246,0.2);
}


/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background: #4f91f7;
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

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

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}


/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}

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

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-blue);
}


/* ── Form Controls ────────────────────────────────────────────────────────── */
.input {
  padding: 7px 12px;
  font-size: 0.8125rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

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

.select {
  padding: 7px 12px;
  padding-right: 32px;
  font-size: 0.8125rem;
  color: var(--text-primary);
  background: var(--bg-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") right 10px center no-repeat;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  appearance: none;
  cursor: pointer;
  transition: all var(--transition-base);
}

.select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

/* Custom checkbox */
input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  transition: all var(--transition-fast);
}
input[type="checkbox"]:checked {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus {
  box-shadow: var(--shadow-glow);
}


/* ── Company Header (on company page) ─────────────────────────────────────── */
.company-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.company-info { flex: 1; }

.company-ticker {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.company-name-full {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.company-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.company-price-block {
  text-align: right;
}

.company-price {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.company-price-change {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 4px;
}


/* ── Chart Container ──────────────────────────────────────────────────────── */
.chart-container {
  width: 100%;
  height: 300px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chart-container.tall { height: 400px; }
.chart-container.short { height: 200px; }


/* ── Skeleton Loaders ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; width: 80%; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 40%; margin-bottom: 12px; }
.skeleton-stat { height: 32px; width: 60%; }
.skeleton-chart { height: 300px; width: 100%; border-radius: var(--radius-md); }

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


/* ── Valuation Specific ───────────────────────────────────────────────────── */
.football-field {
  position: relative;
  padding: 16px 0;
}

.football-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.football-label {
  width: 140px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.football-bar-container {
  flex: 1;
  position: relative;
  height: 20px;
}

.football-bar {
  position: absolute;
  height: 100%;
  border-radius: 3px;
  opacity: 0.7;
  transition: all var(--transition-base);
}

.football-bar:hover { opacity: 1; }

.football-bar.dcf { background: var(--accent-blue); }
.football-bar.comps { background: var(--accent-cyan); }
.football-bar.ddm { background: var(--accent-green); }
.football-bar.holt { background: var(--accent-purple); }
.football-bar.monte-carlo { background: var(--accent-amber); }

.football-current {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-red);
  z-index: 5;
}

.football-current::after {
  content: 'Current';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  color: var(--accent-red);
  white-space: nowrap;
}


/* ── Editable Cells ───────────────────────────────────────────────────────── */
.editable-cell {
  cursor: text;
  padding: 4px 8px;
  border-radius: 3px;
  transition: background var(--transition-fast);
}

.editable-cell:hover {
  background: var(--bg-hover);
}

.editable-cell.editing {
  background: var(--bg-primary);
  outline: 1px solid var(--border-focus);
}

.editable-cell input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: inherit;
  color: var(--text-primary);
  background: transparent;
  text-align: inherit;
}


/* ── Scenario Tabs ────────────────────────────────────────────────────────── */
.scenario-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.scenario-tab {
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.scenario-tab:hover { border-color: var(--border-active); color: var(--text-secondary); }
.scenario-tab.active.bull { background: rgba(16,185,129,0.1); border-color: var(--positive); color: var(--positive); }
.scenario-tab.active.base { background: rgba(59,130,246,0.1); border-color: var(--accent-blue); color: var(--accent-blue); }
.scenario-tab.active.bear { background: rgba(239,68,68,0.1); border-color: var(--negative); color: var(--negative); }


/* ── Signal Meter ─────────────────────────────────────────────────────────── */
.signal-meter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.signal-meter-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.signal-meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-slow);
}

.signal-meter-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}


/* ── Empty States ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state svg { color: var(--text-muted); margin-bottom: 16px; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state-text { font-size: 0.8125rem; color: var(--text-tertiary); max-width: 320px; }


/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .sidebar-label, .sidebar .sidebar-item span, .sidebar .sidebar-footer { display: none; }
  .sidebar .sidebar-item { justify-content: center; padding: 10px 0; }
  #main-content { left: var(--sidebar-collapsed); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); width: var(--sidebar-width); }
  #main-content { left: 0; }
  .header-center { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .company-header { flex-direction: column; gap: 12px; padding: 14px; }
  .company-ticker { font-size: 1.25rem; }
  .company-name-full { font-size: 0.875rem; }
  .company-meta { flex-wrap: wrap; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
  .stat-card { padding: 10px 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-actions { width: 100%; }
  .filter-row { flex-direction: column; }
}

/* ── Toast Notifications ─────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 16px; right: 16px; z-index: 10000;
  display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px; border-radius: var(--radius); font-size: 0.8125rem;
  color: var(--text-primary); background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toast-in 0.2s ease-out;
  max-width: 400px;
}
.toast.toast-success { border-left: 3px solid var(--positive); }
.toast.toast-error   { border-left: 3px solid var(--negative); }
.toast.toast-warning { border-left: 3px solid var(--accent-amber, #fbbf24); }
.toast.toast-info    { border-left: 3px solid var(--accent-cyan); }
.toast.toast-out     { animation: toast-out 0.15s ease-in forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(12px); } }

/* ── Modal / Dialog ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: modal-fade-in 0.15s ease-out;
}
.modal-backdrop.modal-out { animation: modal-fade-out 0.12s ease-in forwards; }
.modal {
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 8px); box-shadow: var(--shadow-lg);
  min-width: 360px; max-width: 520px; width: 100%;
  animation: modal-scale-in 0.15s ease-out;
}
.modal-backdrop.modal-out .modal { animation: modal-scale-out 0.12s ease-in forwards; }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.modal-close {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  font-size: 1.25rem; line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border-subtle);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal .form-group { margin-bottom: 14px; }
.modal .form-group:last-child { margin-bottom: 0; }
.modal .form-label {
  display: block; font-size: 0.75rem; font-weight: 500; color: var(--text-secondary);
  margin-bottom: 4px;
}
.modal .form-hint { font-size: 0.6875rem; color: var(--text-tertiary); margin-top: 2px; }
@keyframes modal-fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-fade-out  { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-scale-in  { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes modal-scale-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.95); } }

/* ═══════════════════════════════════════════════════════════════════════════
   VALUATION WORKSHEETS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Worksheet tables */
.ws-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; font-family: var(--font-mono); }
.ws-table th, .ws-table td { padding: 5px 10px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.ws-table th { text-align: right; font-weight: 500; color: var(--text-muted); font-size: 0.75rem; position: sticky; top: 0; background: var(--bg-secondary); z-index: 2; }
.ws-table th:first-child { text-align: left; min-width: 180px; }
.ws-table td { text-align: right; }
.ws-table td:first-child { text-align: left; color: var(--text-secondary); font-weight: 500; padding-left: 12px; }
.ws-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* Historical columns (gray) */
.ws-hist { background: rgba(255,255,255,0.015); color: var(--text-muted); }

/* Projection columns */
.ws-proj { background: transparent; color: var(--text-primary); }

/* Editable cells */
.ws-edit {
  background: rgba(0, 212, 255, 0.03);
  border: 1px solid rgba(0, 212, 255, 0.12);
  border-radius: 3px;
  padding: 3px 8px;
  cursor: text;
  color: var(--accent-cyan);
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.ws-edit:hover { border-color: rgba(0, 212, 255, 0.3); }
.ws-edit:focus {
  outline: none;
  border-color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}
.ws-edit-input {
  background: transparent; border: none; color: inherit;
  font: inherit; text-align: right; width: 80px; padding: 0;
  outline: none;
}

/* Computed rows (bold) */
.ws-computed { font-weight: 600; color: var(--text-primary); }
.ws-computed td:first-child { font-weight: 700; }

/* Separator rows */
.ws-separator td { border-bottom: 2px solid var(--border-subtle); padding: 0; height: 2px; }

/* Section header rows */
.ws-section-header td {
  font-size: 0.6875rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 14px 10px 4px; font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-primary);
}

/* Section title above worksheet */
.ws-section-title {
  font-size: 0.75rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 16px 0 8px; font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

/* Positive / negative values */
.ws-positive { color: var(--positive); }
.ws-negative { color: var(--negative); }

/* Summary / output rows (highlighted) */
.ws-output td {
  background: rgba(0, 212, 255, 0.04);
  font-weight: 700; color: var(--accent-cyan);
  border-top: 2px solid var(--border-subtle);
  border-bottom: 2px solid var(--border-subtle);
}

/* Valuation tab bar */
.val-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border-subtle);
  margin-bottom: 16px; overflow-x: auto; flex-wrap: nowrap;
}
.val-tab {
  padding: 8px 16px; font-size: 0.8125rem; color: var(--text-muted);
  cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: color 0.15s, border-color 0.15s;
  user-select: none;
}
.val-tab:hover { color: var(--text-primary); }
.val-tab.active {
  color: var(--accent-cyan); border-bottom-color: var(--accent-cyan);
  font-weight: 600;
}

/* Chart containers */
.ws-chart { position: relative; width: 100%; min-height: 280px; margin: 12px 0; }
.ws-chart canvas { display: block; border-radius: var(--radius); }
.ws-chart-sm { min-height: 200px; }
.ws-chart-lg { min-height: 400px; }

/* Chart tooltip */
.ws-chart-tooltip {
  position: absolute; background: var(--bg-primary);
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  padding: 8px 12px; font-size: 0.75rem; color: var(--text-primary);
  pointer-events: none; z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-width: 240px;
}

/* Chart legend */
.ws-chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.75rem; color: var(--text-secondary); margin-top: 8px; justify-content: center; }
.ws-chart-legend-item { display: flex; align-items: center; gap: 5px; }
.ws-chart-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Gauge chart */
.ws-gauge { width: 220px; height: 130px; margin: 0 auto; }
.ws-gauge-label { text-align: center; font-size: 1.75rem; font-weight: 700; margin-top: -24px; }
.ws-gauge-sublabel { text-align: center; font-size: 0.75rem; color: var(--text-muted); }

/* Summary stat cards (for key outputs) */
.ws-stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.ws-stat-card {
  flex: 1; min-width: 140px; padding: 12px 16px;
  background: var(--bg-tertiary); border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}
.ws-stat-card-label { font-size: 0.6875rem; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.ws-stat-card-value { font-size: 1.125rem; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.ws-stat-card-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Two-column worksheet layout */
.ws-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1200px) { .ws-layout { grid-template-columns: 1fr; } }

/* Toggle switches (for TV method) */
.ws-toggle { display: inline-flex; border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; }
.ws-toggle-btn {
  padding: 4px 12px; font-size: 0.75rem; cursor: pointer; color: var(--text-muted);
  background: transparent; border: none; transition: all 0.15s;
}
.ws-toggle-btn.active {
  background: var(--accent-cyan); color: var(--bg-primary); font-weight: 600;
}

/* Distribution bar (for Monte Carlo) */
.ws-dist-bar { height: 100%; transition: height 0.2s; border-radius: 2px 2px 0 0; }

/* Probability indicator */
.ws-prob { font-size: 2rem; font-weight: 800; font-family: var(--font-mono); }
.ws-prob-label { font-size: 0.75rem; color: var(--text-muted); }

/* Heatmap cell */
.ws-heat-cell {
  text-align: center; font-size: 0.75rem; font-family: var(--font-mono);
  padding: 4px 6px; border: 1px solid rgba(255,255,255,0.05);
  transition: transform 0.1s;
}
.ws-heat-cell:hover { transform: scale(1.05); z-index: 1; position: relative; }
.ws-heat-cell.ws-heat-base { outline: 2px solid var(--accent-cyan); outline-offset: -2px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Research — Source badges, rating badges, report cards
   ═══════════════════════════════════════════════════════════════════════════ */

/* Source badges */
.source-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 3px;
  font-size: 0.5625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  line-height: 1.4; white-space: nowrap;
}
.source-badge.ubs { color: #e60000; background: rgba(230,0,0,0.1); }
.source-badge.barclays { color: #00aeef; background: rgba(0,174,239,0.1); }
.source-badge.gs { color: #6eb5ff; background: rgba(110,181,255,0.1); }
.source-badge.nomura { color: #cc0000; background: rgba(204,0,0,0.1); }
.source-badge.dbs { color: #e30613; background: rgba(227,6,19,0.1); }
.source-badge.cicc { color: #0055a5; background: rgba(0,85,165,0.1); }
.source-badge.cibc { color: #8b0000; background: rgba(139,0,0,0.1); }
.source-badge.capital_profile { color: #4a90d9; background: rgba(74,144,217,0.1); }
.source-badge.citic { color: #003d79; background: rgba(0,61,121,0.1); }
.source-badge.afr { color: #2e7d32; background: rgba(46,125,50,0.1); }

/* Rating badges */
.rating-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 3px;
  font-size: 0.625rem; font-weight: 600; white-space: nowrap;
}
.rating-badge.buy { color: var(--positive); background: rgba(16,185,129,0.12); }
.rating-badge.overweight { color: var(--positive); background: rgba(16,185,129,0.12); }
.rating-badge.neutral { color: var(--accent-amber); background: rgba(245,158,11,0.1); }
.rating-badge.hold { color: var(--accent-amber); background: rgba(245,158,11,0.1); }
.rating-badge.sell { color: var(--negative); background: rgba(239,68,68,0.12); }
.rating-badge.underweight { color: var(--negative); background: rgba(239,68,68,0.12); }
.rating-badge.not-rated { color: var(--text-muted); background: rgba(255,255,255,0.05); }

/* Research report card */
.research-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.research-item:hover { background: var(--bg-hover); }
.research-item:last-child { border-bottom: none; }

.research-item-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
  font-size: 0.6875rem; color: var(--text-tertiary);
}
.research-item-title {
  font-size: 0.8125rem; font-weight: 600; color: var(--text-primary);
  line-height: 1.4; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.research-item-title:hover { color: var(--accent-cyan); }
.research-item-summary {
  font-size: 0.75rem; color: var(--text-secondary); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 6px;
}
.research-item-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 0.6875rem; color: var(--text-muted);
}
.research-item-meta a { color: var(--accent-cyan); text-decoration: none; }
.research-item-meta a:hover { text-decoration: underline; }

/* Research actions bar — prominent downloads at top */
.research-actions-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 12px 16px; margin-bottom: 12px; border-radius: 6px;
  background: var(--bg-secondary); border: 1px solid var(--border);
}
.research-actions-left {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.research-actions-right {
  display: flex; align-items: center; gap: 10px;
}
.research-dl-btn {
  font-weight: 600; gap: 6px; display: inline-flex; align-items: center;
}
.research-dl-btn svg { flex-shrink: 0; }
.research-actions-meta {
  display: flex; align-items: center; gap: 8px;
}
.research-pt {
  font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600;
  color: var(--text-primary);
}
.research-analyst {
  font-size: 0.75rem; color: var(--text-secondary);
}
.research-count-badge {
  font-size: 0.6875rem; color: var(--text-muted);
  padding: 2px 8px; background: var(--bg-tertiary); border-radius: 10px;
}

/* Enrichment card */
.enrichment-card {
  padding: 16px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-secondary); margin-bottom: 16px;
}
.enrichment-card .enrichment-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.enrichment-card .enrichment-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 12px;
}
.enrichment-card .enrichment-field label {
  display: block; font-size: 0.625rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px;
}
.enrichment-card .enrichment-field .value {
  font-size: 0.875rem; font-weight: 600; color: var(--text-primary);
  font-family: var(--font-mono);
}
.enrichment-card .enrichment-desc {
  font-size: 0.75rem; color: var(--text-secondary); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.enrichment-card .enrichment-desc.expanded {
  -webkit-line-clamp: unset;
}

/* Research filter bar */
.research-filters {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.research-filters .input, .research-filters .select {
  font-size: 0.8125rem;
}

/* PDF viewer modal */
.pdf-viewer-frame {
  width: 100%; height: calc(90vh - 120px); border: none; border-radius: 4px;
  background: var(--bg-primary);
}
