/* ============================================================
   BLOOMBERG TERMINAL CLONE — COMPLETE STYLESHEET
   ============================================================ */

/* ----- RESET & BASE ----- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Background */
  --bg-main: #0A0E17;
  --bg-panel: #0F1318;
  --bg-panel-header: #141820;
  --bg-input: #0C1020;
  --bg-hover: #1A1E2E;

  /* Borders */
  --border: #1C2030;

  /* Brand */
  --orange: #FF8C00;
  --orange-bright: #FFA500;

  /* Text */
  --text-primary: #D1D4DC;
  --text-secondary: #787B86;
  --text-dim: #4A4E5A;
  --white: #FFFFFF;

  /* Semantic */
  --positive: #00C853;
  --negative: #FF1744;

  /* Accents */
  --blue: #2196F3;
  --cyan: #00BCD4;
  --amber: #FFB300;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'Roboto Mono', 'Consolas', monospace;
  --fs-xs: 9px;
  --fs-sm: 10px;
  --fs-base: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 16px;
  --fs-2xl: 20px;
  --fs-3xl: 28px;
  --ls: 0.5px;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  color: var(--text-primary);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

a {
  color: var(--orange);
  text-decoration: none;
}

a:hover {
  color: var(--orange-bright);
}

/* ============================================================
   MAIN CONTAINER
   ============================================================ */
.terminal {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
}

/* ----- Scanline CRT overlay ----- */
.scanline-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.06) 0px,
    rgba(0, 0, 0, 0.06) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.35;
  animation: scanline-drift 8s linear infinite;
}

@keyframes scanline-drift {
  0%   { background-position: 0 0; }
  100% { background-position: 0 6px; }
}

/* ============================================================
   LOADING SCREEN
   ============================================================ */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

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

.loading-logo {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 12px;
  color: var(--orange);
  text-transform: uppercase;
  text-shadow: 0 0 30px rgba(255, 140, 0, 0.4), 0 0 60px rgba(255, 140, 0, 0.15);
  animation: logo-glow 2s ease-in-out infinite alternate;
}

@keyframes logo-glow {
  0%   { text-shadow: 0 0 20px rgba(255, 140, 0, 0.3), 0 0 40px rgba(255, 140, 0, 0.1); }
  100% { text-shadow: 0 0 40px rgba(255, 140, 0, 0.6), 0 0 80px rgba(255, 140, 0, 0.25); }
}

.loading-sub {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  letter-spacing: 8px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.loading-bar-container {
  width: 320px;
  height: 3px;
  background: var(--border);
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  background: var(--orange);
  animation: loading-progress 2.4s ease-in-out forwards;
}

@keyframes loading-progress {
  0%   { width: 0%; }
  20%  { width: 18%; }
  45%  { width: 42%; }
  65%  { width: 68%; }
  80%  { width: 85%; }
  100% { width: 100%; }
}

.loading-text {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ============================================================
   HEADER
   ============================================================ */
.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  min-height: 38px;
  padding: 0 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
}

/* --- Header Left --- */
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.bloomberg-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
}

.logo-text {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--orange);
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(255, 140, 0, 0.25);
}

.logo-separator {
  width: 1px;
  height: 16px;
  background: var(--text-dim);
  margin: 0 2px;
}

.logo-sub {
  font-size: var(--fs-sm);
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.header-session {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: var(--ls);
  text-transform: uppercase;
}

/* --- Header Center (Command Input) --- */
.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 20px;
  max-width: 560px;
}

.command-input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  height: 26px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 0 8px;
  gap: 6px;
  transition: border-color 0.15s ease;
}

.command-input-wrapper:focus-within {
  border-color: var(--orange);
}

.command-prompt {
  font-size: var(--fs-base);
  color: var(--orange);
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

.command-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  color: var(--white);
  caret-color: var(--orange);
  letter-spacing: var(--ls);
}

.command-input::placeholder {
  color: var(--text-dim);
  font-style: normal;
}

.command-cursor {
  width: 7px;
  height: 14px;
  background: var(--orange);
  animation: cursor-blink 1s step-end infinite;
  flex-shrink: 0;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* --- Header Right --- */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-datetime {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
  letter-spacing: var(--ls);
}

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

.header-time {
  color: var(--orange);
  font-weight: 700;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--text-dim);
}

.status-dot.online {
  background: var(--positive);
  box-shadow: 0 0 6px rgba(0, 200, 83, 0.6);
  animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(0, 200, 83, 0.4); }
  50%      { box-shadow: 0 0 10px rgba(0, 200, 83, 0.8); }
}

.status-text {
  font-size: var(--fs-xs);
  color: var(--positive);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ============================================================
   TICKER BAR
   ============================================================ */
.ticker-bar {
  height: 26px;
  min-height: 26px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.ticker-content {
  display: flex;
  align-items: center;
  height: 100%;
  white-space: nowrap;
  animation: ticker-scroll 40s linear infinite;
  will-change: transform;
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
  height: 100%;
  flex-shrink: 0;
}

.ticker-symbol {
  color: var(--white);
  font-weight: 700;
  letter-spacing: var(--ls);
}

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

.ticker-change {
  font-size: var(--fs-xs);
}

.ticker-item.positive .ticker-change {
  color: var(--positive);
}

.ticker-item.negative .ticker-change {
  color: var(--negative);
}

.ticker-item.positive .ticker-price {
  color: var(--positive);
}

.ticker-item.negative .ticker-price {
  color: var(--negative);
}

/* ============================================================
   MAIN GRID
   ============================================================ */
.terminal-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  padding: 2px;
  overflow: hidden;
  min-height: 0;
}

/* ----- Base Panel ----- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  transition: border-color 0.15s ease;
}

.panel:focus-within,
.panel:hover {
  border-color: #252A3A;
}

.panel:focus-within {
  border-color: #2E3348;
}

/* ----- Panel Header ----- */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  min-height: 28px;
  padding: 0 8px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border);
  border-left: 2px solid var(--orange);
  flex-shrink: 0;
  gap: 6px;
}

.panel-icon {
  font-size: var(--fs-sm);
  color: var(--orange);
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.panel-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: var(--ls);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.panel-badge {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--bg-main);
  background: var(--orange);
  padding: 1px 5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  flex-shrink: 0;
  line-height: 1.4;
}

/* ----- Panel Tabs ----- */
.panel-tabs {
  display: flex;
  align-items: stretch;
  height: 24px;
  min-height: 24px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.panel-tabs::-webkit-scrollbar {
  display: none;
}

.panel-tab {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: var(--ls);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease;
  user-select: none;
}

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

.panel-tab.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 14px;
  padding: 0 3px;
  font-size: 8px;
  font-weight: 700;
  color: var(--white);
  background: var(--text-dim);
  margin-left: 4px;
  letter-spacing: 0;
}

.panel-tab.active .panel-count {
  background: var(--orange);
  color: var(--bg-main);
}

/* ----- Panel Content ----- */
.panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 0;
}

/* ============================================================
   PANEL GRID POSITIONS
   ============================================================ */
.panel-indices {
  grid-column: 1 / 5;
  grid-row: 1 / 3;
}

.panel-movers {
  grid-column: 5 / 9;
  grid-row: 1 / 3;
}

.panel-chart {
  grid-column: 9 / 13;
  grid-row: 1 / 5;
}

.panel-currencies {
  grid-column: 1 / 5;
  grid-row: 3 / 5;
}

.panel-commodities {
  grid-column: 5 / 9;
  grid-row: 3 / 5;
}

.panel-bonds {
  grid-column: 1 / 5;
  grid-row: 5 / 7;
}

.panel-news {
  grid-column: 5 / 13;
  grid-row: 5 / 8;
}

.panel-watchlist {
  grid-column: 1 / 5;
  grid-row: 7 / 9;
}

.panel-calendar {
  grid-column: 5 / 9;
  grid-row: 8 / 9;
}

.panel-crypto {
  grid-column: 9 / 13;
  grid-row: 8 / 9;
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-panel-header);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: var(--ls);
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.data-table tbody tr {
  transition: background-color 0.1s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody td {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  padding: 4px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid rgba(28, 32, 48, 0.3);
}

.data-table tbody td:first-child {
  color: var(--white);
  font-weight: 600;
}

.data-table tbody td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Compact variant */
.data-table.compact {
  font-size: var(--fs-xs);
}

.data-table.compact thead th {
  font-size: 8px;
  padding: 3px 6px;
}

.data-table.compact tbody td {
  font-size: var(--fs-xs);
  padding: 3px 6px;
}

/* Sparkline column */
.sparkline-col {
  width: 60px;
  max-width: 60px;
  text-align: center !important;
  padding: 2px 4px !important;
}

.sparkline-col canvas {
  display: block;
  margin: 0 auto;
}

/* Cell colors */
.cell-positive {
  color: var(--positive) !important;
}

.cell-negative {
  color: var(--negative) !important;
}

/* Cell flash (generic) */
.cell-flash {
  animation: cell-flash-yellow 0.6s ease-out;
}

@keyframes cell-flash-yellow {
  0%   { background-color: rgba(255, 179, 0, 0.3); }
  100% { background-color: transparent; }
}

@keyframes flash-green {
  0%   { background-color: rgba(0, 200, 83, 0.3); }
  100% { background-color: transparent; }
}

@keyframes flash-red {
  0%   { background-color: rgba(255, 23, 68, 0.3); }
  100% { background-color: transparent; }
}

.cell-flash-positive {
  animation: flash-green 0.6s ease-out;
}

.cell-flash-negative {
  animation: flash-red 0.6s ease-out;
}

/* ============================================================
   CHART
   ============================================================ */
.chart-container {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#price-chart,
#equity-detail-chart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.chart-crosshair-info {
  position: absolute;
  padding: 4px 8px;
  background: rgba(15, 19, 24, 0.92);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  z-index: 6;
  backdrop-filter: blur(4px);
}

.chart-info {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 8px;
  background: var(--bg-panel-header);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  min-height: 24px;
  flex-shrink: 0;
}

.chart-last-price {
  color: var(--white);
  font-weight: 700;
  font-size: var(--fs-sm);
}

.chart-change {
  font-size: var(--fs-xs);
  font-weight: 600;
}

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

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

.chart-volume {
  color: var(--text-dim);
  font-size: var(--fs-xs);
  margin-left: auto;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  background: var(--bg-panel-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chart-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  padding: 2px 8px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: var(--ls);
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  user-select: none;
}

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

.chart-btn.active {
  color: var(--orange);
  border-color: var(--orange);
  background: rgba(255, 140, 0, 0.08);
}

/* ============================================================
   NEWS FEED
   ============================================================ */
.news-feed {
  overflow-y: auto;
  padding: 0;
  flex: 1;
  min-height: 0;
}

.news-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-left: 3px solid var(--orange);
  border-bottom: 1px solid rgba(28, 32, 48, 0.4);
  cursor: pointer;
  transition: background 0.12s ease;
}

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

.news-item.urgent {
  border-left-color: var(--negative);
}

.news-item.urgent .news-headline {
  color: var(--white);
}

.news-time {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: var(--ls);
  flex-shrink: 0;
}

.news-tag {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  color: var(--bg-main);
  background: var(--orange);
  padding: 1px 4px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-left: 6px;
  vertical-align: middle;
}

.news-headline {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-source {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: var(--ls);
}

/* ============================================================
   CALENDAR FEED
   ============================================================ */
.calendar-feed {
  overflow-y: auto;
  padding: 0;
  flex: 1;
  min-height: 0;
}

.calendar-item {
  display: grid;
  grid-template-columns: 50px 1fr auto auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(28, 32, 48, 0.4);
  font-size: var(--fs-xs);
  transition: background 0.12s ease;
}

.calendar-item:hover {
  background: var(--bg-hover);
}

.cal-time {
  color: var(--text-dim);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls);
  white-space: nowrap;
}

.cal-event {
  color: var(--text-primary);
  font-size: var(--fs-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-impact {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
}

.cal-impact.high {
  background: var(--negative);
  box-shadow: 0 0 4px rgba(255, 23, 68, 0.4);
}

.cal-impact.medium {
  background: var(--amber);
  box-shadow: 0 0 4px rgba(255, 179, 0, 0.3);
}

.cal-impact.low {
  background: var(--positive);
  box-shadow: 0 0 4px rgba(0, 200, 83, 0.3);
}

.cal-actual {
  color: var(--white);
  font-weight: 600;
  text-align: right;
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

.cal-forecast {
  color: var(--text-secondary);
  text-align: right;
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

.cal-previous {
  color: var(--text-dim);
  text-align: right;
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   SUMMARY BAR
   ============================================================ */
.summary-bar {
  display: flex;
  align-items: center;
  height: 24px;
  min-height: 24px;
  padding: 0 10px;
  background: var(--bg-panel-header);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  gap: 18px;
  overflow-x: auto;
  flex-shrink: 0;
}

.summary-bar::-webkit-scrollbar {
  display: none;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.summary-label {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: var(--ls);
}

.summary-value {
  font-size: var(--fs-xs);
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-value.positive {
  color: var(--positive);
}

.summary-value.negative {
  color: var(--negative);
}

/* ============================================================
   FUNCTION KEY BAR
   ============================================================ */
.function-bar {
  display: flex;
  align-items: stretch;
  height: 30px;
  min-height: 30px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 0 4px;
  gap: 2px;
  flex-shrink: 0;
}

.fkey {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  cursor: pointer;
  transition: background 0.1s ease;
  user-select: none;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  flex: 1;
  justify-content: center;
  max-width: 120px;
}

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

.fkey:active {
  background: rgba(255, 140, 0, 0.1);
}

.fkey-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--orange);
  letter-spacing: var(--ls);
  flex-shrink: 0;
}

.fkey-text {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: modal-fade-in 0.2s ease-out;
}

@keyframes modal-fade-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: modal-scale-in 0.2s ease-out;
}

@keyframes modal-scale-in {
  0%   { opacity: 0; transform: scale(0.95) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-large {
  max-width: 900px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  flex-shrink: 0;
}

.modal-header h2,
.modal-header .modal-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: color 0.12s ease, border-color 0.12s ease;
}

.modal-close:hover {
  color: var(--negative);
  border-color: var(--negative);
}

.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  min-height: 0;
}

/* Help sections */
.help-section {
  margin-bottom: 18px;
}

.help-section h3,
.help-section .help-section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: var(--ls);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.help-table {
  width: 100%;
  border-collapse: collapse;
}

.help-table td {
  padding: 4px 8px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(28, 32, 48, 0.3);
  vertical-align: top;
}

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

.help-cmd {
  color: var(--orange) !important;
  font-weight: 600;
  white-space: nowrap;
}

/* ============================================================
   EQUITY DETAIL MODAL
   ============================================================ */
.equity-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.equity-main-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.equity-ticker-large {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--white);
  letter-spacing: 2px;
}

.equity-name {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  letter-spacing: var(--ls);
}

.equity-price-large {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.equity-change-large {
  font-size: var(--fs-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.equity-change-large.positive {
  color: var(--positive);
}

.equity-change-large.negative {
  color: var(--negative);
}

.equity-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(28, 32, 48, 0.3);
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: var(--ls);
}

.stat-value {
  font-size: var(--fs-sm);
  color: var(--white);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.equity-chart-area {
  position: relative;
  min-height: 200px;
}

.equity-chart-area canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================
   ALERTS (Toast Notifications)
   ============================================================ */
.alert-container {
  position: fixed;
  bottom: 40px;
  right: 14px;
  z-index: 8000;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  pointer-events: none;
  max-width: 380px;
}

.alert-toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  pointer-events: auto;
  animation: slide-in-right 0.3s ease-out;
  line-height: 1.4;
}

.alert-toast.info {
  border-left-color: var(--blue);
}

.alert-toast.warning {
  border-left-color: var(--amber);
}

.alert-toast.error {
  border-left-color: var(--negative);
}

@keyframes slide-in-right {
  0%   { opacity: 0; transform: translateX(100%); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  transition: background 0.15s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: #2A2E3E;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ============================================================
   SELECTION
   ============================================================ */
::selection {
  background: rgba(255, 140, 0, 0.3);
  color: var(--white);
}

::-moz-selection {
  background: rgba(255, 140, 0, 0.3);
  color: var(--white);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1400px) {
  .terminal-grid {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: auto;
  }

  .panel-indices     { grid-column: 1 / 5; grid-row: 1 / 3; }
  .panel-movers      { grid-column: 5 / 9; grid-row: 1 / 3; }
  .panel-chart       { grid-column: 1 / 9; grid-row: 3 / 5; }
  .panel-currencies  { grid-column: 1 / 5; grid-row: 5 / 7; }
  .panel-commodities { grid-column: 5 / 9; grid-row: 5 / 7; }
  .panel-bonds       { grid-column: 1 / 5; grid-row: 7 / 9; }
  .panel-news        { grid-column: 5 / 9; grid-row: 7 / 10; }
  .panel-watchlist   { grid-column: 1 / 5; grid-row: 9 / 11; }
  .panel-calendar    { grid-column: 5 / 9; grid-row: 10 / 11; }
  .panel-crypto      { grid-column: 1 / 5; grid-row: 11 / 12; }
}

@media (max-width: 1024px) {
  .terminal-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .panel-indices,
  .panel-movers,
  .panel-chart,
  .panel-currencies,
  .panel-commodities,
  .panel-bonds,
  .panel-news,
  .panel-watchlist,
  .panel-calendar,
  .panel-crypto {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .terminal-grid {
    grid-template-rows: none;
    overflow-y: auto;
  }

  .panel {
    min-height: 220px;
  }

  .panel-chart {
    min-height: 320px;
  }

  .panel-news {
    min-height: 280px;
  }
}

@media (max-width: 768px) {
  .terminal-header {
    height: auto;
    min-height: 34px;
    flex-wrap: wrap;
    padding: 4px 8px;
    gap: 4px;
  }

  .header-center {
    order: 3;
    flex: 0 0 100%;
    max-width: 100%;
    padding: 2px 0;
  }

  .header-left {
    gap: 8px;
  }

  .logo-text {
    font-size: var(--fs-base);
    letter-spacing: 2px;
  }

  .logo-sub {
    display: none;
  }

  .logo-separator {
    display: none;
  }

  .header-session {
    display: none;
  }

  .function-bar {
    flex-wrap: wrap;
    height: auto;
    min-height: 26px;
    padding: 2px;
  }

  .fkey {
    flex: 0 0 auto;
    padding: 2px 6px;
  }

  .fkey-text {
    display: none;
  }

  .summary-bar {
    gap: 10px;
    padding: 0 6px;
  }

  .equity-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .terminal-grid {
    grid-template-columns: 1fr;
    gap: 1px;
    padding: 1px;
  }

  .panel {
    min-height: 180px;
  }

  .ticker-bar {
    height: 22px;
    min-height: 22px;
  }

  .ticker-item {
    padding: 0 10px;
    gap: 4px;
  }

  .loading-logo {
    font-size: 28px;
    letter-spacing: 6px;
  }

  .loading-sub {
    font-size: var(--fs-sm);
    letter-spacing: 4px;
  }

  .loading-bar-container {
    width: 220px;
  }

  .modal {
    width: 98%;
    max-height: 90vh;
  }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-orange   { color: var(--orange); }
.text-dim      { color: var(--text-dim); }
.text-white    { color: var(--white); }
.text-blue     { color: var(--blue); }
.text-cyan     { color: var(--cyan); }
.text-amber    { color: var(--amber); }

.font-bold     { font-weight: 700; }
.font-mono     { font-family: var(--font-mono); }
.uppercase     { text-transform: uppercase; }
.tabular-nums  { font-variant-numeric: tabular-nums; }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   ADDITIONAL STYLES
   ============================================================ */

/* Clickable rows */
.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: var(--bg-hover) !important;
}

/* Positive/Negative classes (used by JS for text coloring) */
.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* Summary change text */
.summary-change {
  font-size: var(--fs-xs);
  font-weight: 600;
  margin-left: 3px;
}

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

/* News tag color variants */
.tag-market { background: var(--blue); }
.tag-economy { background: var(--amber); }
.tag-corporate { background: var(--orange); }
.tag-crypto { background: #9C27B0; }
.tag-global { background: var(--cyan); }

/* Impact level styling */
.impact-high { background: var(--negative); box-shadow: 0 0 4px rgba(255, 23, 68, 0.4); }
.impact-med { background: var(--amber); box-shadow: 0 0 4px rgba(255, 179, 0, 0.3); }
.impact-low { background: var(--positive); box-shadow: 0 0 4px rgba(0, 200, 83, 0.3); }

/* Chart overlay needs pointer-events for crosshair */
.chart-overlay {
  pointer-events: auto;
}

/* Alert toast sub-elements */
.alert-icon {
  flex-shrink: 0;
  font-size: var(--fs-lg);
  line-height: 1;
}

.alert-msg {
  font-size: var(--fs-sm);
  line-height: 1.4;
}

.alert-toast.fade-out {
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.alert-toast.show {
  opacity: 1;
  transform: translateX(0);
}

/* News item layout improvement */
.news-item {
  display: grid;
  grid-template-columns: 45px auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 6px;
  align-items: center;
}

.news-time {
  grid-row: 1;
  grid-column: 1;
}

.news-tag {
  grid-row: 1;
  grid-column: 2;
}

.news-headline {
  grid-row: 1;
  grid-column: 3;
}

.news-source {
  grid-row: 1;
  grid-column: 4;
}

/* Panel tabs inside header — inline them */
.panel-header .panel-tabs {
  border: none;
  height: auto;
  min-height: auto;
  background: transparent;
}

/* Sparkline canvas in table */
td .sparkline-canvas {
  display: block;
}

/* Cell label bold */
.cell-label {
  color: var(--white) !important;
  font-weight: 600;
}

/* Help section paragraph */
.help-section p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ============================================================
   ADVANCED VIEWPORT LAYOUTS & TERMINAL STYLES
   ============================================================ */

/* Theme variables */
:root {
  --term-amber: #ffb900;
  --term-green: #00ff00;
  --term-light-bg: #eceff1;
  --term-light-text: #263238;
}

/* Theme containers */
.terminal.theme-amber {
  --orange: #ff8c00;
  --amber: #ffb900;
  --white: #ffffff;
  --text-primary: #ffb900;
  --text-secondary: #ff8c00;
  --text-dim: #9e9e9e;
  --bg-primary: #000000;
  --bg-secondary: #0a0e17;
  --border-color: #333333;
}

.terminal.theme-green {
  --orange: #00ff00;
  --amber: #00e676;
  --white: #ffffff;
  --text-primary: #00ff00;
  --text-secondary: #00e676;
  --text-dim: #78909c;
  --bg-primary: #000000;
  --bg-secondary: #070f07;
  --border-color: #005f00;
}

.terminal.theme-light {
  --orange: #e65100;
  --amber: #f57c00;
  --white: #1a1a1a;
  --text-primary: #263238;
  --text-secondary: #37474f;
  --text-dim: #78909c;
  --bg-primary: #eceff1;
  --bg-secondary: #cfd8dc;
  --border-color: #b0bec5;
}

/* Override input styling for themes */
.theme-light input.command-input {
  background: #cfd8dc !important;
  color: #263238 !important;
  border-bottom-color: #37474f !important;
}

/* Dynamic viewports grid */
.terminal-grid {
  display: flex;
  width: 100%;
  height: calc(100vh - 82px);
  background: #000;
  padding: 1px;
  box-sizing: border-box;
  overflow: hidden;
  gap: 1px;
}

.terminal-grid.layout-single {
  flex-direction: column;
}

.terminal-grid.layout-split {
  flex-direction: row;
}

.terminal-grid.layout-quad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* Viewport panel container */
.viewport {
  border: 1px solid #222;
  background: #000;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  height: 100%;
  width: 100%;
}

.viewport.active {
  border: 1px solid var(--orange);
}

.viewport-header {
  background: #0d0d0d;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: bold;
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #1a1a1a;
  user-select: none;
}

.viewport-header .vp-title {
  color: var(--white);
  letter-spacing: 1px;
}

.viewport-header .vp-index {
  color: var(--orange);
}

.viewport-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding: 6px;
  box-sizing: border-box;
}

/* Autocomplete suggestion popover */
.autocomplete-popover {
  position: absolute;
  top: 36px;
  left: 30px;
  width: 320px;
  background: #0a0a0a;
  border: 1px solid var(--orange);
  box-shadow: 0 4px 12px rgba(0,0,0,0.8);
  z-index: 100;
  font-family: var(--font-mono);
  font-size: 11px;
  display: none;
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 6px 10px;
  border-bottom: 1px solid #1a1a1a;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
}

.autocomplete-item:hover, .autocomplete-item.active {
  background: #222;
  color: var(--white);
}

.autocomplete-item .item-sym {
  color: var(--white);
  font-weight: bold;
}

.autocomplete-item .item-desc {
  color: var(--orange);
}

/* B-Unit simulated login screen overlay */
.bunit-login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 20000;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  overflow: hidden;
}

.bunit-container {
  width: 550px;
  border: 2px solid #333;
  background: #050505;
  padding: 24px;
  box-sizing: border-box;
  box-shadow: 0 0 20px rgba(255,140,0,0.1);
  text-align: center;
  position: relative;
}

.bunit-logo {
  font-size: 24px;
  font-weight: bold;
  color: var(--orange);
  letter-spacing: 4px;
  margin-bottom: 4px;
}

.bunit-sub {
  font-size: 11px;
  color: #777;
  letter-spacing: 2px;
  margin-bottom: 24px;
}

.bunit-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  text-align: left;
}

.bunit-scanner-box {
  border: 1px solid #333;
  height: 200px;
  background: #020202;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.bunit-scanner-box:hover {
  border-color: var(--orange);
}

.bunit-scanner-thumb {
  font-size: 54px;
  color: #333;
  transition: color 0.3s ease;
}

.bunit-scanner-box.scanning .bunit-scanner-thumb {
  color: #00ff00;
  animation: scanning-glow 1s infinite alternate;
}

/* Scanline animation */
.scanner-scanline {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: #00ff00;
  box-shadow: 0 0 8px #00ff00;
  display: none;
  animation: scanline-move 2s linear infinite;
}

.bunit-scanner-box.scanning .scanner-scanline {
  display: block;
}

.scanner-label {
  font-size: 9px;
  color: #555;
  margin-top: 10px;
  text-transform: uppercase;
}

.bunit-form-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.bunit-input-group {
  margin-bottom: 16px;
}

.bunit-label {
  font-size: 10px;
  color: #888;
  margin-bottom: 6px;
  display: block;
}

.bunit-token-wrapper {
  display: flex;
  gap: 6px;
}

.bunit-token-input {
  width: 36px;
  height: 36px;
  background: #000;
  border: 1px solid #333;
  color: var(--white);
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  font-family: var(--font-mono);
  box-sizing: border-box;
}

.bunit-token-input:focus {
  border-color: var(--orange);
  outline: none;
}

.bunit-btn {
  background: #111;
  border: 1px solid #333;
  color: var(--orange);
  padding: 8px 16px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1px;
  width: 100%;
  margin-top: 10px;
}

.bunit-btn:hover {
  background: #222;
  border-color: var(--orange);
  color: #fff;
}

.bunit-log {
  border: 1px solid #222;
  background: #000;
  padding: 8px;
  font-size: 9px;
  color: #00ff00;
  height: 70px;
  overflow-y: auto;
  margin-top: 16px;
  text-align: left;
}

@keyframes scanning-glow {
  0% { text-shadow: 0 0 2px #00ff00; }
  100% { text-shadow: 0 0 15px #00ff00; }
}

@keyframes scanline-move {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

/* High-Density Custom Financial Screens styling */
.hd-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--white);
}

.hd-table th {
  background: #111;
  color: var(--orange);
  font-weight: bold;
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid #333;
  font-size: 10px;
}

.hd-table td {
  padding: 3px 6px;
  border-bottom: 1px solid #111;
}

.hd-table tr.hd-header-row {
  background: #0d0d0d;
}

.hd-table tr.hd-header-row td {
  color: var(--amber);
  font-weight: bold;
  border-bottom: 1px solid #222;
}

/* Financial Analysis statements grid */
.fa-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.fa-section-title {
  color: var(--orange);
  font-weight: bold;
  font-size: 11px;
  border-bottom: 1px solid #333;
  padding-bottom: 3px;
  margin-bottom: 6px;
}

/* Analyst recommendations display */
.anr-summary-block {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.anr-consensus-large {
  border: 1px solid #333;
  padding: 10px;
  text-align: center;
  background: #070a0f;
}

.anr-consensus-val {
  font-size: 20px;
  font-weight: bold;
  color: #00ff00;
  margin-top: 4px;
}

.anr-bar-chart {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.anr-bar-row {
  display: grid;
  grid-template-columns: 50px 30px 1fr;
  align-items: center;
  font-size: 10px;
}

.anr-bar-fill {
  height: 8px;
  background: var(--amber);
}

.anr-bar-fill.buy { background: #00c853; }
.anr-bar-fill.hold { background: #ffab00; }
.anr-bar-fill.sell { background: #ff1744; }

/* Dynamic indicator canvas sizes */
.chart-with-indicator {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.indicator-canvas-container {
  height: 80px;
  border-top: 1px dashed #222;
  position: relative;
  background: #0a0e17;
}

/* Description UI components */
.des-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  height: 100%;
}

.des-left, .des-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.des-profile-block {
  border: 1px solid #222;
  background: #080808;
  padding: 8px;
  font-size: 11px;
  line-height: 1.4;
}

.des-profile-title {
  font-weight: bold;
  color: var(--orange);
  margin-bottom: 4px;
  border-bottom: 1px solid #222;
  padding-bottom: 2px;
}

.des-executives-block {
  border: 1px solid #222;
  padding: 8px;
}

