/* TradingView-Inspired Terminal Design System */

:root {
  --bg-canvas:       #0D0E11;
  --bg-surface:      #131722;
  --bg-elevated:     #1C2030;
  --bg-overlay:      #252A3D;
  --bg-hover:        #2A3150;
  --bg-active:       #1E3A5F;

  --accent-bull:     #26A69A;
  --accent-bear:     #EF5350;
  --accent-blue:     #2962FF;
  --accent-purple:   #7B61FF;
  --accent-amber:    #F59E0B;
  --accent-cyan:     #00BCD4;

  --text-primary:    #D1D4DC;
  --text-secondary:  #787B86;
  --text-tertiary:   #4E5263;
  --text-inverse:    #0D0E11;
  --text-bull:       #26A69A;
  --text-bear:       #EF5350;

  --border-subtle:   rgba(255,255,255,0.04);
  --border-default:  rgba(255,255,255,0.08);
  --border-strong:   rgba(255,255,255,0.16);
  --border-accent:   #2962FF;

  --grid-line:       rgba(255,255,255,0.04);
  --crosshair:       rgba(255,255,255,0.3);

  --font-ui:   'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  10px;
  --radius-xl:  14px;

  --shadow-panel:  0 4px 24px rgba(0,0,0,0.6);
  --shadow-modal:  0 8px 48px rgba(0,0,0,0.8);
  --shadow-tooltip: 0 2px 12px rgba(0,0,0,0.9);

  --topnav-height: 48px;
  --ticker-height: 32px;
  --sidebar-left-width: 240px;
  --sidebar-right-width: 320px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body.terminal-body {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-canvas);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: var(--ticker-height);
}

/* Scrollbar */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-canvas); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

::selection {
  background: rgba(41,98,255,0.3);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button {
  font-family: var(--font-ui);
  transition: opacity 150ms ease, transform 100ms ease, background 150ms ease;
}
button:active { transform: scale(0.97); }

a {
  color: inherit;
  text-decoration: none;
}

/* Typography */
.page-title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 18px;
  color: var(--text-primary);
}

.section-header {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.data-label {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 12px;
  color: var(--text-secondary);
}

.price-display {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 24px;
}

.ticker-symbol {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
}

.timestamp {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px;
  color: var(--text-tertiary);
}

.mono { font-family: var(--font-mono); }
.bull { color: var(--accent-bull); }
.bear { color: var(--accent-bear); }

/* Layout Shell */
.terminal-shell {
  display: grid;
  grid-template-rows: var(--topnav-height) 1fr var(--ticker-height);
  grid-template-columns: var(--sidebar-left-width) 1fr var(--sidebar-right-width);
  min-height: 100vh;
  padding-bottom: 0;
}

.terminal-shell.no-right-panel {
  grid-template-columns: var(--sidebar-left-width) 1fr;
}

.terminal-shell.full-width {
  grid-template-columns: 1fr;
}

.topnav {
  grid-column: 1 / -1;
  height: var(--topnav-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav-logo {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-blue);
  margin-right: 16px;
  white-space: nowrap;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.topnav-link {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 12px;
  position: relative;
  transition: color 200ms ease;
}

.topnav-link:hover { color: var(--text-primary); }

.topnav-link.active {
  color: var(--text-primary);
}

.topnav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--accent-blue);
}

.topnav-search {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--text-primary);
  width: 180px;
  font-family: var(--font-ui);
}

.topnav-search::placeholder { color: var(--text-tertiary); }
.topnav-search:focus { outline: none; border-color: var(--border-strong); }

.topnav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.topnav-icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 150ms ease;
}

.topnav-icon-btn:hover { color: var(--text-primary); }

.topnav-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 100ms, background 200ms, border-color 200ms;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.topnav-logout:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
}

.topnav-logout:active {
  transform: scale(0.97);
}

.topnav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Left Sidebar */
.sidebar-left {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-section-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.sidebar-add-btn {
  font-size: 11px;
  color: var(--accent-blue);
  background: transparent;
  border: none;
  cursor: pointer;
}

.sidebar-add-btn:hover { opacity: 0.8; }

.watchlist-scroll {
  flex: 1;
  overflow-y: auto;
}

.watchlist-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 120ms ease;
}

.watchlist-item:hover { background: var(--bg-hover); }
.watchlist-item.active {
  background: var(--bg-active);
  border-left: 2px solid var(--accent-blue);
}

.watchlist-sym    { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-primary); }
.watchlist-price  { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); text-align: right; }
.watchlist-change { font-family: var(--font-mono); font-size: 11px; text-align: right; min-width: 58px; }
.watchlist-change.bull { color: var(--accent-bull); }
.watchlist-change.bear { color: var(--accent-bear); }

.sidebar-tabs {
  display: flex;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  text-align: center;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.sidebar-tab:hover { color: var(--text-primary); }
.sidebar-tab.active { color: var(--accent-blue); background: rgba(41,98,255,0.08); }

/* Main Content */
.main-content {
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.main-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
}

/* Right Panel */
.sidebar-right {
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s cubic-bezier(0.16,1,0.3,1);
}

.order-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.order-tab-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border-default);
}

.order-tab {
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  background: transparent;
  border: none;
}

.order-tab.buy  { color: var(--accent-bull); }
.order-tab.sell { color: var(--accent-bear); }
.order-tab.active.buy  { background: rgba(38,166,154,0.1); border-bottom: 2px solid var(--accent-bull); }
.order-tab.active.sell { background: rgba(239,83,80,0.1);  border-bottom: 2px solid var(--accent-bear); }

.order-input-group {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-input-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 3px; }

.order-input,
.order-select {
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  transition: border-color 150ms ease;
  width: 100%;
}

.order-input:focus,
.order-select:focus { outline: none; border-color: var(--accent-blue); }

.order-total {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0 16px;
}

.order-depth {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

.depth-bar {
  height: 6px;
  background: var(--bg-canvas);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  margin-bottom: 10px;
}

.depth-bid {
  background: var(--accent-bull);
  height: 100%;
}

.depth-ask {
  background: var(--accent-bear);
  height: 100%;
}

.depth-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  margin-bottom: 4px;
}

.depth-row .ask-label { color: var(--accent-bear); }
.depth-row .bid-label { color: var(--accent-bull); }
.depth-row .depth-pct { color: var(--text-tertiary); }

.btn-buy,
.btn-sell {
  margin: 12px 16px;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 150ms ease, transform 100ms ease;
}

.btn-buy {
  background: var(--accent-bull);
  color: var(--text-inverse);
}

.btn-sell {
  background: var(--accent-bear);
  color: var(--text-inverse);
}

.btn-buy:hover,
.btn-sell:hover { opacity: 0.9; }
.btn-buy:active,
.btn-sell:active { transform: scale(0.98); }

/* Ticker Tape */
.ticker-tape {
  grid-column: 1 / -1;
  height: var(--ticker-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  overflow: hidden;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
}

.ticker-track {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 32px;
  white-space: nowrap;
  animation: ticker-scroll 60s linear infinite;
}

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

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ticker-sym   { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.ticker-price { font-family: var(--font-mono); font-size: 11px; color: var(--text-primary); }
.ticker-change { font-family: var(--font-mono); font-size: 11px; }
.ticker-change.bull { color: var(--accent-bull); }
.ticker-change.bear { color: var(--accent-bear); }

/* Chart Area */
.chart-toolbar {
  height: 40px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 2px;
  flex-shrink: 0;
}

.chart-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  margin: 0 8px;
}

.toolbar-btn {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  border: none;
  background: transparent;
}

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

.timeframe-btn {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  border: none;
  background: transparent;
}

.timeframe-btn:hover  { color: var(--text-primary); background: var(--bg-overlay); }
.timeframe-btn.active { color: var(--accent-blue); background: rgba(41,98,255,0.12); }

.chart-container {
  flex: 1;
  background: var(--bg-surface);
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 300px;
}

.chart-wrapper {
  width: 100%;
  height: 100%;
  min-height: 300px;
  position: relative;
}

.chart-canvas-wrap {
  width: 100%;
  height: 100%;
  min-height: 300px;
  position: absolute;
  inset: 0;
}

.chart-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-overlay) 50%, var(--bg-elevated) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite ease-in-out;
  border-radius: 0;
  z-index: 2;
  pointer-events: none;
}

.chart-tooltip {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  box-shadow: var(--shadow-tooltip);
  pointer-events: none;
}

.indicator-chips {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 10;
}

.indicator-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(19,23,34,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  cursor: move;
}

.indicator-chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Market Cards */
.market-cards-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 16px;
  scrollbar-width: none;
}

.market-cards-row::-webkit-scrollbar { display: none; }

.market-card {
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}

.market-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.market-card .card-sym   { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text-primary); }
.market-card .card-name  { font-size: 11px; color: var(--text-secondary); margin: 2px 0 10px; }
.market-card .card-price { font-family: var(--font-mono); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.market-card .card-price.bull { color: var(--accent-bull); }
.market-card .card-price.bear { color: var(--accent-bear); }
.market-card .card-chg   { font-family: var(--font-mono); font-size: 12px; }
.market-card canvas      { width: 100% !important; height: 48px !important; margin-top: 10px; }

.market-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 8px;
}

.market-tab {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 150ms ease;
}

.market-tab:hover { color: var(--text-primary); }
.market-tab.active {
  color: var(--accent-blue);
  background: rgba(41,98,255,0.12);
  border-color: rgba(41,98,255,0.3);
}

/* Data Table */
.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table thead th:first-child { text-align: left; }
.data-table thead th:hover { color: var(--text-primary); }
.data-table thead th.sorted { color: var(--accent-blue); }

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

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

.data-table tbody td {
  padding: 9px 12px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.data-table tbody td:first-child {
  text-align: left;
  font-family: var(--font-ui);
  font-weight: 500;
}

.cell-bull { color: var(--accent-bull); }
.cell-bear { color: var(--accent-bear); }
.cell-heat-bull { background: rgba(38,166,154,0.08); }
.cell-heat-bear { background: rgba(239,83,80,0.08); }

/* Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 4px;
  padding: 16px;
}

.heatmap-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 150ms ease;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border-subtle);
}

.heatmap-cell:hover { transform: scale(1.04); z-index: 1; }
.heatmap-cell .hm-sym { font-weight: 600; font-size: 11px; }
.heatmap-cell .hm-pct { font-size: 11px; margin-top: 2px; }

/* Gauge */
.gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.gauge-svg {
  width: 160px;
  height: 90px;
}

.gauge-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 8px;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  margin-top: 4px;
}

/* Metric Cards */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
}

.metric-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.metric-card-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.metric-card-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-card-value.bull { color: var(--accent-bull); }
.metric-card-value.bear { color: var(--accent-bear); }

.metric-card-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 4px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 16px;
}

.stat-cell {
  background: var(--bg-elevated);
  padding: 12px 14px;
}

.stat-cell-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-cell-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Tabbed Panel */
.tab-panel {
  border-top: 1px solid var(--border-default);
  background: var(--bg-elevated);
}

.tab-panel-nav {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
}

.tab-panel-btn {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 150ms ease;
}

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

.tab-panel-content {
  padding: 16px;
  display: none;
}

.tab-panel-content.active { display: block; }

/* Filter Panel */
.screener-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  min-height: 0;
}

.filter-panel {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  padding: 16px;
  overflow-y: auto;
}

.filter-group {
  margin-bottom: 20px;
}

.filter-group-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.filter-range {
  width: 100%;
  accent-color: var(--accent-blue);
  margin: 8px 0;
}

.filter-range-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
}

.filter-chip {
  background: rgba(41,98,255,0.15);
  border: 1px solid rgba(41,98,255,0.4);
  color: var(--accent-blue);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-chip-remove {
  cursor: pointer;
  opacity: 0.7;
}

.filter-chip-remove:hover { opacity: 1; }

/* Drawing Tools Strip */
.drawing-strip {
  width: 40px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
}

.drawing-tool {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all 150ms ease;
}

.drawing-tool:hover { color: var(--text-primary); background: var(--bg-overlay); }
.drawing-tool.active { color: var(--accent-blue); background: rgba(41,98,255,0.12); }

.chart-with-tools {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Portfolio Layout */
.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}

.portfolio-chart-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.portfolio-chart-card h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.donut-wrap {
  position: relative;
  max-width: 240px;
  margin: 0 auto;
}

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

/* Dashboard Hero */
.dashboard-hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0;
  min-height: 380px;
  border-bottom: 1px solid var(--border-default);
}

.dashboard-hero-chart {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-default);
}

.dashboard-overview {
  background: var(--bg-elevated);
  padding: 16px;
  overflow-y: auto;
}

.overview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.overview-item:last-child { border-bottom: none; }

.overview-sym {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.overview-price {
  font-family: var(--font-mono);
  font-size: 12px;
}

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 200px 1fr;
  gap: 0;
  border-top: 1px solid var(--border-default);
}

.dashboard-panel {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
}

.dashboard-panel:last-child { border-right: none; }

.panel-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Tooltip */
.tooltip {
  position: absolute;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-primary);
  box-shadow: var(--shadow-tooltip);
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Correlation Matrix */
.correlation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.correlation-table th,
.correlation-table td {
  padding: 6px 8px;
  text-align: center;
  font-family: var(--font-mono);
  border: 1px solid var(--border-subtle);
}

.correlation-table th {
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--bg-elevated);
}

/* Animations */
@keyframes flash-bull { 0%,100%{background:transparent} 50%{background:rgba(38,166,154,0.2)} }
@keyframes flash-bear { 0%,100%{background:transparent} 50%{background:rgba(239,83,80,0.2)} }
.flash-bull { animation: flash-bull 0.6s ease; }
.flash-bear { animation: flash-bear 0.6s ease; }

@keyframes price-up   { 0%{color:var(--text-primary)} 30%{color:var(--accent-bull)} 100%{color:var(--text-primary)} }
@keyframes price-down { 0%{color:var(--text-primary)} 30%{color:var(--accent-bear)} 100%{color:var(--text-primary)} }
.price-flash-up   { animation: price-up   0.5s ease; }
.price-flash-down { animation: price-down 0.5s ease; }

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

.watchlist-item:nth-child(1) { animation: fadeSlideIn 0.3s ease 0.0s both; }
.watchlist-item:nth-child(2) { animation: fadeSlideIn 0.3s ease 0.05s both; }
.watchlist-item:nth-child(3) { animation: fadeSlideIn 0.3s ease 0.10s both; }
.watchlist-item:nth-child(4) { animation: fadeSlideIn 0.3s ease 0.15s both; }
.watchlist-item:nth-child(5) { animation: fadeSlideIn 0.3s ease 0.20s both; }
.watchlist-item:nth-child(6) { animation: fadeSlideIn 0.3s ease 0.25s both; }
.watchlist-item:nth-child(7) { animation: fadeSlideIn 0.3s ease 0.30s both; }
.watchlist-item:nth-child(8) { animation: fadeSlideIn 0.3s ease 0.35s both; }
.watchlist-item:nth-child(9) { animation: fadeSlideIn 0.3s ease 0.40s both; }
.watchlist-item:nth-child(10) { animation: fadeSlideIn 0.3s ease 0.45s both; }

@keyframes cardReveal {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.market-card { animation: cardReveal 0.4s cubic-bezier(0.16,1,0.3,1) both; }
.market-card:nth-child(1) { animation-delay: 0s; }
.market-card:nth-child(2) { animation-delay: 0.06s; }
.market-card:nth-child(3) { animation-delay: 0.12s; }
.market-card:nth-child(4) { animation-delay: 0.18s; }
.market-card:nth-child(5) { animation-delay: 0.24s; }
.market-card:nth-child(6) { animation-delay: 0.30s; }

@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position:  400px 0; }
}

.scroll-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.scroll-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile drawer */
.mobile-drawer-btn {
  display: none;
  position: fixed;
  bottom: 48px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: var(--text-inverse);
  border: none;
  font-size: 20px;
  cursor: pointer;
  z-index: 99;
  box-shadow: var(--shadow-panel);
}

.bottom-sheet {
  display: none;
  position: fixed;
  bottom: var(--ticker-height);
  left: 0;
  right: 0;
  height: 60vh;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  backdrop-filter: blur(12px);
  overflow-y: auto;
}

.bottom-sheet.open { transform: translateY(0); }

.sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

.sheet-backdrop.open { display: block; }

/* Responsive */
@media (max-width: 1024px) {
  .terminal-shell {
    grid-template-columns: 40px 1fr;
  }

  .terminal-shell.has-right {
    grid-template-columns: 40px 1fr;
  }

  .sidebar-left {
    width: 40px;
    overflow: hidden;
  }

  .sidebar-left .watchlist-scroll,
  .sidebar-left .sidebar-tabs,
  .sidebar-left .sidebar-section-header span,
  .sidebar-left .sidebar-add-btn {
    display: none;
  }

  .sidebar-left .sidebar-section-header {
    justify-content: center;
    padding: 12px 4px;
  }

  .sidebar-right {
    display: none;
  }

  .sidebar-right.drawer-open {
    display: flex;
    position: fixed;
    top: var(--topnav-height);
    right: 0;
    bottom: var(--ticker-height);
    width: var(--sidebar-right-width);
    z-index: 150;
    box-shadow: var(--shadow-panel);
  }

  .mobile-drawer-btn { display: flex; align-items: center; justify-content: center; }

  .dashboard-hero { grid-template-columns: 1fr; }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .metric-cards { grid-template-columns: 1fr; }
  .portfolio-grid { grid-template-columns: 1fr; }
  .screener-layout { grid-template-columns: 1fr; }
  .filter-panel { display: none; }
}

@media (max-width: 768px) {
  .terminal-shell {
    grid-template-columns: 1fr;
  }

  .sidebar-left { display: none; }

  .topnav-links { display: none; }
  .topnav-search { width: 120px; }

  .bottom-sheet { display: block; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
