/* DESIGN VARIABLE ARCHITECTURE TOKENS */
:root {
  --bg-main: #0b0e11;
  --bg-surface: #161a1e;
  --bg-surface-hover: #1e2329;
  --border-color: #2b3139;
  --accent-color: #00c076;
  --accent-down: #f23645;
  --text-main: #eaecef;
  --text-muted: #848e9c;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --header-height: 64px;
}

.light-mode {
  --bg-main: #f6f8fa;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f3f5;
  --border-color: #d0d7de;
  --accent-color: #00965e;
  --accent-down: #d9383a;
  --text-main: #24292f;
  --text-muted: #57606a;
}

/* GLOBAL NORMALIZATION ELEMENT DEFAULTS */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* TOP SCROLLING TICKER TAPE OVERLAYS */
.ticker-tape {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  height: 32px;
  overflow: hidden;
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.tape-track {
  display: flex;
  white-space: nowrap;
  animation: scrollTape 35s linear infinite;
}

.tape-item {
  display: inline-flex;
  gap: 8px;
  padding: 0 24px;
  font-size: 12px;
  font-family: monospace;
  font-weight: 600;
  border-right: 1px solid var(--border-color);
}

@keyframes scrollTape {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}

/* NAVIGATION INTERFACE NAVBAR HEADER */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  height: auto;
  min-height: var(--header-height);
  padding: 12px var(--fluid-padding, 20px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  margin-top: 40px;
}

#marketTimeLabel {
  color: var(--text-muted);
  font-weight: 500;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px; /* Provides precise, readable horizontal spacing between image and text */
}

.brand h1 {
  font-size: 18px;
  letter-spacing: 1px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
}

/* KEEPS LOGO CRISP AND SNAPPED PERFECTIONALLY ALONGSIDE THE TEXT */
.logo-img {
  height: 24px;   /* Constrains vertical boundary height to match header rows */
  width: auto;    /* Preserves original aspect ratio automatically */
  object-fit: contain;
  display: block;
}

.brand .accent { color: var(--accent-color); }

.badge {
  background: rgba(0, 192, 118, 0.15);
  color: var(--accent-color);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ATOMIC SEARCH WRAPPER WITH PORTAL INTERFACING */
.search-wrapper {
  flex: 1;
  max-width: 520px;
  min-width: 280px;
  display: flex;
  gap: 8px;
  position: relative;
}

.search-input-field {
  position: relative;
  flex: 1;
}

.search-glass-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrapper input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 12px 10px 36px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrapper input:focus {
  border-color: var(--accent-color);
}

/* SUGGESTION DROPDOWN PORTAL OVERLAYS */
.autocomplete-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  display: none;
}

.suggestion-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.suggestion-row:hover {
  background-color: var(--bg-surface-hover);
}

.suggestion-row .sym-badge {
  font-weight: 700;
  color: var(--accent-color);
  background: rgba(0, 192, 118, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* BUTTON CONTROLLER COMPONENT ELEMENTS */
.btn-primary {
  background: var(--accent-color);
  color: #fff;
  border: none;
  font-weight: 600;
  padding: 0 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}

/* REFINED SIDEBAR SUB-ACTION HEADERS */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* FIXING THE "+ ADD CURRENT" WATCHLIST BUTTON */
.btn-text {
  background: transparent;
  border: none;
  color: var(--accent-color);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: var(--font-family);
  transition: background-color 0.15s, opacity 0.15s;
}

.btn-text:hover {
  background-color: rgba(0, 192, 118, 0.1); /* Subtle green glow context on hover */
  opacity: 0.95;
}

/* Light mode override safety for the action text button */
.light-mode .btn-text {
  color: var(--accent-color);
}

.btn-primary:hover { opacity: 0.9; }

/* CONTAINER HOLDING THE TIMESTAMPS AND TOGGLE BUTTON */
.header-actions {
  display: flex;
  align-items: center; /* Vertically centers the pill and button on the same line */
  gap: 12px;           /* Pushes the toggle button to the right of the live time with crisp spacing */
}

/* THE BUTTON LOOKS LIKE AN INTEGRATED TERMINAL UTILITY */
.btn-icon {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px; /* Matches the exact height of your market status pill tag */
  transition: background-color 0.15s, border-color 0.15s;
}

.btn-icon:hover { 
  background: var(--bg-surface-hover); 
  border-color: var(--text-muted);
}

/* ALIGN THEME TOGGLE SIDE-BY-SIDE WITH TIME IN HEADER */
.header-actions {
  display: flex;
  align-items: center; 
  gap: 12px;           
}

.header-actions .btn-icon {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background-color 0.15s, border-color 0.15s;
}

.header-actions .btn-icon:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--text-muted);
}

/* CORE DASHBOARD RESPONSIVE DUAL-GRID */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 16px var(--fluid-padding, 20px);
  max-width: 1680px;
  margin: 0 auto;
}

/* SIDEBAR RE-ORDERING PANELS */
.sidebar-panel {
  display: flex;
  flex-column: wrap;
  flex-direction: column;
  gap: 16px;
}

.main-content-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0; /* Clear grid stretching issues */
}

/* REUSABLE PRO CARD DESIGN MATRIX ELEMENT */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

.card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: 0.3px;
  border-left: 3px solid var(--accent-color);
  padding-left: 8px;
}

/* STOCK OVERVIEW DETAILS PROFILE HERO CARD */
.stock-hero-card {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-main) 100%);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
}

.hero-layout-split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.meta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.exchange-tag, .sector-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border-color);
  color: var(--text-muted);
}

.hero-core-profile h2 {
  font-size: 26px;
  font-weight: 800;
}

.hero-core-profile h4 {
  color: var(--text-muted);
  font-weight: 500;
  font-family: monospace;
}

.price-value {
  font-size: 28px;
  font-weight: 800;
  font-family: monospace;
}

.quick-stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.strip-item h5 {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.strip-item span {
  font-size: 15px;
  font-weight: 700;
  font-family: monospace;
}

/* INTELLIGENT CHART VIEWPORT FRAME WORKSTATION */
.workstation-panel {
  display: flex;
  flex-direction: column;
}

.workstation-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

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

.control-group-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.chart-controls {
  display: flex;
  background: var(--bg-main);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.btn-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

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

.btn-toggle.active {
  background: var(--bg-surface-hover);
  color: var(--accent-color);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-indicator.active { color: #f59e0b; }

.chart-container-frame {
  position: relative;
  width: 100%;
  height: clamp(300px, 45vh, 500px); /* Secure aspect mapping dynamically scaled */
}

/* DATA BREAKDOWNS SUB GRIDS ELEMENTS */
.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.profile-bio {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* FORECAST RADIAL ALIGNMENT MATRIX PANEL */
.forecast-layout {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.consensus-meter-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  min-width: 120px;
  flex: 1;
}

.gauge-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-color);
}

.gauge-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* COMPREHENSIVE DATA GRID TABLES STRUCTURES */
.table-container-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table, .comparison-matrix {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table td {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.02);
}

.comparison-matrix th, .comparison-matrix td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.comparison-matrix th {
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(0,0,0,0.05);
}

.comparison-matrix .active-col {
  background: rgba(0, 192, 118, 0.03);
  font-weight: 600;
}

.interactive-rows tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.interactive-rows tbody tr:hover { background: var(--bg-surface-hover); }

.interactive-rows th {
  padding: 10px 8px;
  color: var(--text-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border-color);
}

.interactive-rows td { padding: 12px 8px; }

/* REUSABLE DYNAMIC WATCHLIST NODES CARDS */
.watchlist-container, .trending-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.watchlist-card, .trending-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.watchlist-card:hover, .trending-item:hover {
  transform: translateY(-1px);
  border-color: var(--accent-color);
  background: var(--bg-surface-hover);
}

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  border: 1px dashed var(--border-color);
  border-radius: 6px;
}

/* SCREENER RUNNER CONTROLS PACK */
.screener-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.screener-filters select {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  outline: none;
}

/* HELPER UTILITIES PACK */
.up { color: var(--accent-color) !important; }
.down { color: var(--accent-down) !important; }
.text-right { text-align: right; }
.font-weight-bold { font-weight: 700; }
.margin-top { margin-top: 20px; }
.margin-top-sm { margin-top: 12px; }

.app-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  margin-top: 40px;
}

#marketTimeLabel {
  font-weight: 500;
  color: var(--text-muted);
}

/* ====== BREAKPOINTS PACK FOR PHONE AND TABLET ====== */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr; /* Snap sidebar element down below data view */
  }
  .sidebar-panel {
    order: 2; /* Ensure watchlist flows underneath primary tracking charts */
  }
}

@media (max-width: 640px) {
  :root { --fluid-padding: 12px; }
  
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .search-wrapper { max-width: 100%; }
  .workstation-header { flex-direction: column; align-items: flex-start; }
  .hero-layout-split { flex-direction: column; text-align: left; }
  .hero-pricing.text-right { text-align: left; margin-top: 8px; }
  .flex-column-mobile { flex-direction: column; align-items: flex-start; gap: 12px; }
}