/* ── Reset / Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  /* Base surfaces -- deep, slightly blue-black, like a premium fintech app rather than a terminal */
  --bg:        #08090d;
  --surface:   #14151d;
  --surface1:  #14151d;
  --surface2:  #1b1c28;
  --surface3:  #21232f;
  --border:    rgba(255,255,255,.08);
  --border-h:  rgba(255,255,255,.16);

  /* Accent -- vivid indigo -> cyan gradient pair, used for CTAs, highlights, glows */
  --accent:      #6C5CE7;
  --accent-h:    #8579ff;
  --accent-2:    #00D4FF;
  --accent-rgb:  108,92,231;
  --gradient-accent: linear-gradient(135deg, #6C5CE7 0%, #4C7CFF 55%, #00D4FF 100%);

  --pos:       #00D9A3;
  --neg:       #FF5C7A;
  --warn:      #FFB020;
  --pos-rgb:   0,217,163;
  --neg-rgb:   255,92,122;

  --text:      #e7e8ee;
  --muted:     #7a7d8c;
  --font:      'Inter', system-ui, sans-serif;

  /* Radius scale -- rounder, softer than the old terminal look */
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;

  /* Shadows -- soft elevation + a colored glow reserved for primary CTAs/highlights */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.03) inset;
  --shadow-md: 0 8px 24px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.04) inset;
  --shadow-lg: 0 20px 48px rgba(0,0,0,.45);
  --shadow-glow: 0 0 0 1px rgba(var(--accent-rgb),.4), 0 8px 28px rgba(var(--accent-rgb),.28);

  /* Motion -- one shared "premium" easing curve + durations */
  --ease:      cubic-bezier(.16,1,.3,1);
  --dur-fast:  .15s;
  --dur-med:   .3s;
  --dur-slow:  .6s;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(108,92,231,.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(0,212,255,.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Shared transition on anything interactive -- the single biggest "feels expensive"
   lever: nothing snaps, everything eases. Specific components can still tune this. */
a, button, input, select, .icon-btn, .dash-market-tile, .dash-wl-tile,
.dash-action-tile, .dash-card, .stat-card, .search-input, .search-btn {
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-med) var(--ease),
              box-shadow var(--dur-med) var(--ease);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb),.35); }
  50%      { box-shadow: 0 0 0 6px rgba(var(--accent-rgb),0); }
}

.fade-in-up { animation: fadeInUp var(--dur-slow) var(--ease) both; }
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  background: rgba(20,21,29,.72);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.header::-webkit-scrollbar { height: 5px; }
.header::-webkit-scrollbar-track { background: transparent; }
.header::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.header::-webkit-scrollbar-thumb:hover { background: var(--muted); }

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

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.logo-mark {
  display: block;
  border-radius: 7px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06);
}

.search-wrapper { position: relative; flex: 1 1 220px; max-width: 480px; min-width: 220px; }
.search-form { display: flex; width: 100%; gap: 8px; }
.search-input {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 7px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

.search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 7px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.search-btn:hover { background: var(--accent-h); }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
  white-space: nowrap;
  position: relative;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-h); }

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--neg);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9999px;
  padding: 0 5px;
  min-width: 17px;
  text-align: center;
}

/* ── Alert panel ────────────────────────────────────────────────────────── */
.alert-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.alert-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.alert-list { padding: 8px 0; max-height: 320px; overflow-y: auto; }
.alert-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.alert-item:last-child { border-bottom: none; }
.alert-item .alert-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.alert-tag.buy { background: rgba(38,166,154,.2); color: var(--pos); }
.alert-tag.sell { background: rgba(239,83,80,.2); color: var(--neg); }
.alert-tag.rsi { background: rgba(41,98,255,.2); color: var(--accent-h); }

/* ── Main layout ────────────────────────────────────────────────────────── */
.main { padding: 20px; display: flex; flex-direction: column; gap: 16px; min-height: calc(100vh - 56px); }

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* ── Home Dashboard ─────────────────────────────────────────────────────── */
.dash-loading { color: var(--muted); font-size: 13px; padding: 14px 0; }
.dash-market-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  flex-shrink: 0;
}
.dash-market-strip::-webkit-scrollbar { display: none; }
.dash-strip-divider { width: 1px; background: var(--border); flex-shrink: 0; margin: 0 6px; align-self: stretch; }
.dash-market-tile {
  min-width: 148px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  animation: fadeInUp var(--dur-slow) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.dash-market-tile:hover { transform: translateY(-3px); border-color: var(--border-h); box-shadow: var(--shadow-md); }
.dash-market-sym { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 4px; }
.dash-market-price { font-size: 20px; font-weight: 700; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.dash-market-chg { font-size: 12px; font-weight: 600; }

.dash-mid-row, .dash-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-card {
  background: linear-gradient(180deg, var(--surface3) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  animation: fadeInUp var(--dur-slow) var(--ease) both;
}
.dash-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 12px;
}
.dash-wl-grid { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.dash-wl-tile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  animation: fadeInUp var(--dur-med) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.dash-wl-tile:hover { border-color: var(--accent); transform: translateX(3px); box-shadow: var(--shadow-sm); }
.dash-wl-sym { font-size: 13px; font-weight: 700; color: var(--accent-h); }
.dash-wl-price { font-size: 12px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-wl-empty { font-size: 12px; color: var(--muted); padding: 12px 0; }

.dash-actions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dash-action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  text-align: center;
  animation: fadeInUp var(--dur-med) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.dash-action-tile:hover { border-color: transparent; color: #fff; background: var(--gradient-accent); transform: translateY(-3px); box-shadow: var(--shadow-glow); }
.dash-action-tile svg { opacity: .7; transition: opacity var(--dur-fast) var(--ease); }
.dash-action-tile:hover svg { opacity: 1; }

.dash-tip-card {
  background: linear-gradient(135deg, rgba(108,92,231,.12), rgba(0,212,255,.05));
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-image: var(--gradient-accent) 1;
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeInUp var(--dur-slow) var(--ease) both;
}
.dash-tip-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--accent-h); }
.dash-tip-text { font-size: 13px; line-height: 1.7; color: var(--text); }

.dash-recent-list { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.dash-recent-pill {
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-h);
  cursor: pointer;
  transition: border-color .15s;
}
.dash-recent-pill:hover { border-color: var(--accent); }
.dash-recent-empty { font-size: 12px; color: var(--muted); padding: 4px 0; }

.header-divider { width: 1px; height: 24px; background: var(--border); flex-shrink: 0; margin: 0 4px; align-self: center; }

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

/* ── Top row ────────────────────────────────────────────────────────────── */
.top-row {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: start;
}

.chart-wrap { display: flex; flex-direction: column; }
#tvChart { height: 420px; }

/* ── TradingView interval buttons ───────────────────────────────────────── */
.tv-interval-btns { display: flex; gap: 4px; }
.tv-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: 3px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
}
.tv-btn.active, .tv-btn:hover { border-color: var(--accent); color: var(--accent-h); background: rgba(41,98,255,.1); }

/* ── Quote sidebar ──────────────────────────────────────────────────────── */
.quote-sidebar { display: flex; flex-direction: column; gap: 10px; }

.quote-card { padding: 20px; }
.quote-symbol { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.quote-name { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote-price { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.quote-price-sym { opacity: .55; font-weight: 600; margin-right: 1px; }
.quote-price-num { font-variant-numeric: tabular-nums; }
.dash-market-price { font-variant-numeric: tabular-nums; }
.quote-change { font-size: 14px; font-weight: 500; margin-bottom: 16px; }
.quote-change.pos { color: var(--pos); }
.quote-change.neg { color: var(--neg); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.quote-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quote-stat label { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2px; }
.quote-stat span { font-size: 13px; font-weight: 500; }

.poll-card { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.poll-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.poll-row select, .watchlist-panel select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

.analyze-btn, .report-btn, .watchlist-add-btn {
  width: 100%;
  padding: 11px;
  border-radius: var(--r-md);
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all .15s;
}
.analyze-btn {
  background: var(--accent);
  color: #fff;
}
.analyze-btn:hover:not(:disabled) { background: var(--accent-h); }
.analyze-btn:disabled { opacity: .4; cursor: not-allowed; }

.report-btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.report-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-h); }
.report-btn:disabled { opacity: .4; cursor: not-allowed; }

.watchlist-add-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}
.watchlist-add-btn:hover:not(:disabled) { border-color: var(--pos); color: var(--pos); }
.watchlist-add-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs-container { display: flex; flex-direction: column; }
.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 4px;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 12px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.tab-btn.active { color: var(--accent-h); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-content { padding: 20px; min-height: 200px; }

/* ── Technicals tab ─────────────────────────────────────────────────────── */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.tech-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
}
.tech-item label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; display: block; margin-bottom: 6px; }
.tech-item .tech-val { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.tech-item .tech-sub { font-size: 11px; color: var(--muted); }
.tech-item .tech-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  margin-top: 4px;
}
.badge-bull { background: rgba(38,166,154,.15); color: var(--pos); }
.badge-bear { background: rgba(239,83,80,.15); color: var(--neg); }
.badge-neutral { background: rgba(107,114,128,.15); color: var(--muted); }
.badge-warn { background: rgba(245,158,11,.15); color: var(--warn); }

.rsi-bar-wrap { margin-top: 8px; }
.rsi-bar-track { height: 6px; border-radius: 3px; background: var(--border); position: relative; }
.rsi-bar-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.rsi-labels { display: flex; justify-content: space-between; font-size: 9px; color: var(--muted); margin-top: 2px; }

/* ── Fundamentals tab ───────────────────────────────────────────────────── */
.fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.fund-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
}
.fund-item label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; display: block; margin-bottom: 6px; }
.fund-item span { font-size: 16px; font-weight: 600; }
.fund-desc {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

/* ── News tab ───────────────────────────────────────────────────────────── */
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s;
}
.news-item:hover { border-color: var(--accent); }
.news-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 5px;
}
.news-dot.old { background: var(--muted); }
.news-body { flex: 1; }
.news-title { font-size: 13px; font-weight: 500; margin-bottom: 4px; line-height: 1.4; }
.news-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; }

/* ── AI Analysis tab ────────────────────────────────────────────────────── */
.ai-loading { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; padding: 40px 0; animation: fadeInUp .3s var(--ease, ease); }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  box-shadow: 0 0 10px rgba(var(--accent-rgb, 108,92,231), .35);
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-direction {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.dir-bull { background: rgba(38,166,154,.15); color: var(--pos); }
.dir-bear { background: rgba(239,83,80,.15); color: var(--neg); }
.dir-neutral { background: rgba(107,114,128,.15); color: var(--muted); }

.confidence-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.confidence-label { font-size: 12px; color: var(--muted); min-width: 80px; }
.confidence-track { flex: 1; height: 8px; background: var(--border); border-radius: var(--r-sm); }
.confidence-fill { height: 100%; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--accent), var(--pos)); transition: width .5s; }
.confidence-pct { font-size: 13px; font-weight: 600; min-width: 36px; text-align: right; }

.ai-summary {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 16px;
}

.ai-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.ai-col h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.ai-col.bull h4 { color: var(--pos); }
.ai-col.bear h4 { color: var(--neg); }
.ai-col ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ai-col ul li {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  line-height: 1.4;
}
.ai-col.bull ul li { background: rgba(38,166,154,.08); color: var(--text); }
.ai-col.bear ul li { background: rgba(239,83,80,.08); color: var(--text); }

.ai-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.ai-section { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; }
.ai-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; }
.ai-section ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ai-section ul li { font-size: 12px; line-height: 1.4; padding-left: 12px; position: relative; }
.ai-section ul li::before { content: '•'; position: absolute; left: 0; color: var(--muted); }

.signals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.signal-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}
.signal-card.buy { border-color: var(--pos); background: rgba(38,166,154,.05); }
.signal-card.sell { border-color: var(--neg); background: rgba(239,83,80,.05); }
.signal-card.wait { border-color: var(--warn); background: rgba(245,158,11,.05); }
.signal-card.hold, .signal-card.close { border-color: var(--muted); background: rgba(107,114,128,.05); }
.signal-action {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.signal-action.buy { color: var(--pos); }
.signal-action.sell, .signal-action.close { color: var(--neg); }
.signal-action.wait, .signal-action.hold { color: var(--warn); }
.signal-action.scale { color: var(--accent-h); }
.signal-trigger { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.signal-levels { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.signal-level label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 2px; }
.signal-level span { font-size: 13px; font-weight: 600; }
.signal-level.entry span { color: var(--accent-h); }
.signal-level.sl span { color: var(--neg); }
.signal-level.tp span { color: var(--pos); }
.signal-level.rr span { color: var(--warn); }

.horizon-badge {
  display: inline-block;
  background: rgba(41,98,255,.12);
  color: var(--accent-h);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--r-xl);
  margin-top: 8px;
}

/* ── Watchlist panel ────────────────────────────────────────────────────── */
.watchlist-panel {
  position: fixed;
  top: 56px;
  right: -300px;
  width: 280px;
  height: calc(100vh - 56px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 150;
  transition: right .25s;
  display: flex;
  flex-direction: column;
}
.watchlist-panel.open { right: 0; }
.watchlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.watchlist-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.watchlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .1s;
  gap: 8px;
}
.watchlist-item:hover { background: var(--surface2); }
.watchlist-item .wi-sym { font-size: 13px; font-weight: 600; }
.watchlist-item .wi-price { font-size: 13px; }
.watchlist-item .wi-chg { font-size: 11px; }
.watchlist-item .wi-remove { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: var(--r-sm); font-size: 14px; opacity: 0; transition: opacity .15s; }
.watchlist-item:hover .wi-remove { opacity: 1; }
.poll-settings { padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-header .close-btn {
  font-size: 20px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 10px;
}
.modal-header .close-btn:hover { background: var(--surface2); border-color: var(--neg); color: var(--neg); }
.modal-actions { display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }

.report-section { margin-bottom: 24px; }
.report-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.report-table { width: 100%; border-collapse: collapse; }
.report-table td { padding: 7px 10px; font-size: 13px; border-bottom: 1px solid var(--border); }
.report-table td:first-child { color: var(--muted); width: 45%; }
.report-table td:last-child { font-weight: 500; }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.close-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: var(--r-sm); transition: color .15s; }
.close-btn:hover { color: var(--text); }
.muted { color: var(--muted); font-size: 13px; }
.loading-placeholder {
  color: var(--muted);
  font-size: 13px;
  padding: 20px 0;
  text-align: center;
  position: relative;
  animation: fadeInUp .3s var(--ease, ease);
}
.loading-placeholder::after {
  content: '';
  display: block;
  width: 120px;
  height: 3px;
  margin: 10px auto 0;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

/* ── Metric Tooltip ─────────────────────────────────────────────────────── */
#metricTip {
  position: fixed;
  z-index: 500;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  overflow: hidden;
  animation: tipIn .15s ease;
}
@keyframes tipIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

.tip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: rgba(41,98,255,.08);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-h);
}
.tip-body { padding: 4px 0; }
.tip-section { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tip-section:last-child { border-bottom: none; }
.tip-section h4 { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 5px; }
.tip-section p { font-size: 12px; line-height: 1.6; color: var(--text); margin: 0; }

[data-tip] { cursor: help; border-bottom: 1px dashed var(--muted); transition: color .15s, border-color .15s; }
[data-tip]:hover { color: var(--accent-h); border-bottom-color: var(--accent-h); }
.risk-item label[data-tip] { display: inline-block; }

/* ── Learning Center panel ───────────────────────────────────────────────── */
.learn-panel {
  position: fixed;
  top: 56px;
  right: -620px;
  width: 600px;
  height: calc(100vh - 56px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 160;
  transition: right .25s;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.learn-panel.open { right: 0; }

.learn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.learn-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-h);
}

.learn-tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.learn-tabs-nav::-webkit-scrollbar { display: none; }
.learn-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.learn-tab-btn.active { color: var(--accent-h); border-bottom-color: var(--accent); }
.learn-tab-btn:hover:not(.active) { color: var(--text); }

.learn-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Learning content styles */
.lc-section { margin-bottom: 28px; }
.lc-section h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.lc-section .lc-subtitle { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.lc-section p { font-size: 13px; line-height: 1.7; color: var(--text); margin-bottom: 10px; }
.lc-section ul, .lc-section ol { padding-left: 18px; margin-bottom: 10px; }
.lc-section li { font-size: 13px; line-height: 1.7; color: var(--text); margin-bottom: 4px; }

.lc-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
}
.lc-card h3 { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--accent-h); }
.lc-card p { font-size: 12px; line-height: 1.6; color: var(--text); margin: 0; }

.lc-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.lc-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.lc-step-body { flex: 1; }
.lc-step-body strong { font-size: 13px; display: block; margin-bottom: 2px; }
.lc-step-body span { font-size: 12px; color: var(--muted); }

.lc-resource {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s;
}
.lc-resource:hover { border-color: var(--accent); }
.lc-resource-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.lc-resource-icon.book { background: rgba(41,98,255,.15); }
.lc-resource-icon.course { background: rgba(38,166,154,.15); }
.lc-resource-icon.video { background: rgba(239,83,80,.15); }
.lc-resource-icon.web { background: rgba(245,158,11,.15); }
.lc-resource-body strong { font-size: 13px; display: block; margin-bottom: 2px; }
.lc-resource-body span { font-size: 11px; color: var(--muted); }
.lc-resource-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-left: 6px;
  vertical-align: middle;
}
.tag-free { background: rgba(38,166,154,.15); color: var(--pos); }
.tag-book { background: rgba(41,98,255,.15); color: var(--accent-h); }
.tag-video { background: rgba(239,83,80,.15); color: var(--neg); }

.lc-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.lc-highlight {
  border-left: 3px solid var(--accent);
  background: rgba(41,98,255,.05);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1.6;
}
.lc-formula {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-family: monospace;
  font-size: 13px;
  color: var(--accent-h);
  margin: 8px 0;
  text-align: center;
}

/* ── Glossary ───────────────────────────────────────────────────────────── */
.glossary-search {
  display: block;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 9px 14px;
  outline: none;
  margin: 10px 0 4px;
  box-sizing: border-box;
  transition: border-color .15s;
}
.glossary-search:focus { border-color: var(--accent); }
.glossary-list { display: flex; flex-direction: column; }
.glossary-item { padding: 12px 20px; border-bottom: 1px solid var(--border); }
.glossary-item:last-child { border-bottom: none; }
.glossary-term { font-size: 13px; font-weight: 700; color: var(--accent-h); margin-bottom: 4px; }
.glossary-def { font-size: 12px; line-height: 1.65; color: var(--text); }

/* ── Search Dropdown ────────────────────────────────────────────────────── */
#searchDropdown {
  /* Positioned in JS (left/top/width) from #searchWrapper's bounding rect -
     fixed + rendered outside .header so it's never clipped by the header's
     overflow-x:auto scroll container or its backdrop-filter containing block. */
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-md, 10px);
  z-index: 350;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.55));
  overflow: hidden;
  animation: fadeInUp .15s var(--ease, ease);
}
.sd-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.sd-item:last-child { border-bottom: none; }
.sd-item:hover, .sd-item.active { background: var(--surface2); }
.sd-sym { font-weight: 700; font-size: 13px; color: var(--accent-h); min-width: 58px; }
.sd-name { font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-type { font-size: 10px; color: var(--muted); background: var(--surface2); border-radius: var(--r-sm); padding: 2px 7px; flex-shrink: 0; }

/* ── Portfolio Panel ────────────────────────────────────────────────────── */
.portfolio-panel {
  position: fixed;
  top: 56px;
  right: -670px;
  width: 650px;
  height: calc(100vh - 56px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 170;
  transition: right .25s;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.portfolio-panel.open { right: 0; }

.portfolio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.portfolio-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-h);
}

.portfolio-form {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pf-field > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 8px;
}
.pf-optional { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; }

.pf-capital-row { display: flex; gap: 8px; }
.pf-capital-row select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
  outline: none;
}
.pf-capital-row input[type="number"] {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
}
.pf-capital-row input[type="number"]:focus { border-color: var(--accent); }

input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; margin-top: 4px; }
input[type="range"].pf-ctrl-disabled { opacity: .3; pointer-events: none; }

.pf-ai-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  margin-top: 6px;
  user-select: none;
}
.pf-ai-opt input { accent-color: var(--accent); cursor: pointer; }
.pf-ai-opt:has(input:checked) span { color: var(--accent-h); }

.pf-radio-none { opacity: .6; }
.pf-radio-none:has(input:checked) { opacity: 1; border-color: var(--muted) !important; background: rgba(107,114,128,.1) !important; color: var(--muted) !important; }

.pf-radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pf-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color .15s, background .15s;
  user-select: none;
}
.pf-radio:has(input:checked) { border-color: var(--accent); background: rgba(41,98,255,.1); color: var(--accent-h); }
.pf-radio input { display: none; }

.pf-check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.pf-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color .15s, background .15s;
  user-select: none;
}
.pf-check:has(input:checked) { border-color: var(--accent); background: rgba(41,98,255,.1); color: var(--accent-h); }
.pf-check input { display: none; }

.pf-build-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--r-md);
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  transition: background .15s;
  margin-top: 4px;
}
.pf-build-btn:hover { background: var(--accent-h); }
.pf-build-btn:disabled { opacity: .5; cursor: not-allowed; }

.portfolio-results {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.pf-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
  gap: 8px;
}
.pf-results-actions { display: flex; gap: 6px; }
.pf-results-scroll { flex: 1; overflow-y: auto; }

.pf-chart-wrap {
  padding: 20px;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}
#portfolioChart { max-width: 260px; max-height: 260px; }

.pf-holdings { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.pf-holding-row {
  display: grid;
  grid-template-columns: 56px 1fr 72px;
  gap: 8px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pf-holding-row:last-child { border-bottom: none; }
.pf-holding-sym { font-size: 13px; font-weight: 700; padding-top: 2px; }
.pf-holding-info { min-width: 0; }
.pf-holding-name { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-holding-sector { font-size: 10px; color: var(--muted); margin-top: 1px; }
.pf-holding-reason { font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.pf-slider { width: 100%; margin-top: 6px; accent-color: var(--accent); cursor: pointer; }
.pf-holding-right { text-align: right; }
.pf-holding-pct { font-size: 14px; font-weight: 700; }
.pf-holding-amt { font-size: 10px; color: var(--muted); margin-top: 2px; }

.pf-thesis { padding: 16px 20px; }
.pf-thesis-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
}
.pf-thesis-card h4 { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; }
.pf-thesis-card p { font-size: 12px; line-height: 1.6; margin: 0; }

.pf-sector-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pf-sector-label { font-size: 11px; color: var(--muted); min-width: 100px; }
.pf-sector-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; }
.pf-sector-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.pf-sector-pct { font-size: 11px; font-weight: 600; min-width: 30px; text-align: right; }

/* ── Portfolio Inner Tabs + Positions Pane ──────────────────────────────── */
.pf-inner-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
}
.pf-inner-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.pf-inner-tab:hover { color: var(--text); }
.pf-inner-tab.active { color: var(--accent-h); border-bottom-color: var(--accent); }

.pf-positions-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
#pfBuilderPane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#pfBuilderPane .portfolio-form { min-height: 0; }
.positions-add-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.positions-add-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 70px; }
.positions-add-field label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.positions-add-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
.positions-add-input:focus { border-color: var(--accent); }
.positions-add-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--r-sm);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  align-self: flex-end;
  flex-shrink: 0;
  transition: opacity .15s;
}
.positions-add-btn:hover { opacity: .85; }

.positions-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 16px;
}
.positions-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 13px;
}
.positions-table-wrap { overflow-x: auto; padding: 0 20px; margin-top: 12px; }
.positions-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.positions-table th {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  padding: 6px 8px;
  text-align: right;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.positions-table th:first-child { text-align: left; }
.positions-table td {
  padding: 9px 8px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.positions-table td:first-child { text-align: left; font-weight: 700; color: var(--accent-h); }
.positions-table tr:last-child td { border-bottom: none; }
.positions-summary-row td { background: var(--surface2); font-weight: 700; border-top: 2px solid var(--border); }
.positions-summary-row td:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.positions-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  border-radius: var(--r-sm);
  transition: color .15s;
}
.positions-remove-btn:hover { color: var(--neg); }

.positions-alloc-section { padding: 16px 20px 0; }
.positions-alloc-title { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 10px; }
.positions-header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 0;
}
.positions-header-title { font-size: 12px; font-weight: 700; color: var(--text); }
.positions-refresh-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  transition: color .15s, border-color .15s;
}
.positions-refresh-btn:hover { color: var(--text); border-color: var(--text); }

/* ── T212 Badge ─────────────────────────────────────────────────────────── */
.t212-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: rgba(38,166,154,.15);
  color: var(--pos);
  letter-spacing: .3px;
  vertical-align: middle;
}

/* ── Pattern Detection tab ──────────────────────────────────────────────── */
.pattern-grid { display: flex; flex-direction: column; gap: 14px; }
.pattern-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.pattern-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.pattern-name { font-size: 15px; font-weight: 700; }
.pattern-desc { font-size: 13px; line-height: 1.6; color: var(--text); margin-bottom: 12px; }
.pattern-levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.pattern-level {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 10px;
  text-align: center;
}
.pattern-level label {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 4px;
}
.pattern-level span { font-size: 13px; font-weight: 600; }
.pattern-note { font-size: 12px; line-height: 1.5; margin-top: 6px; color: var(--muted); }

/* ── Calendar Panel ────────────────────────────────────────────────────── */
.calendar-panel {
  position: fixed;
  top: 56px;
  right: -360px;
  width: 340px;
  height: calc(100vh - 56px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 155;
  transition: right .25s;
  display: flex;
  flex-direction: column;
}
.calendar-panel.open { right: 0; }
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.calendar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-h);
}
.calendar-body { flex: 1; overflow-y: auto; }

.cal-event {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.cal-event:hover { background: var(--surface2); }
.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.cal-dot-earnings { background: var(--accent-h); }
.cal-dot-exdiv    { background: var(--pos); }
.cal-dot-divpay   { background: var(--warn); }
.cal-event-body { flex: 1; min-width: 0; }
.cal-event-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; flex-wrap: wrap; }
.cal-sym { font-size: 13px; font-weight: 700; color: var(--accent-h); }
.cal-label { font-size: 12px; color: var(--text); }
.cal-event-bottom { display: flex; justify-content: space-between; align-items: center; }
.cal-date { font-size: 11px; color: var(--muted); }
.cal-countdown {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-md);
  background: rgba(41,98,255,.12);
  color: var(--accent-h);
}

/* ── Journal Tab ────────────────────────────────────────────────────────── */
.journal-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.journal-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
}
.journal-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.journal-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.journal-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.tag-thesis { background: rgba(41,98,255,.15);  color: var(--accent-h); }
.tag-risk   { background: rgba(239,83,80,.15);  color: var(--neg); }
.tag-entry  { background: rgba(38,166,154,.15); color: var(--pos); }
.tag-target { background: rgba(38,166,154,.15); color: var(--pos); }
.tag-stop   { background: rgba(239,83,80,.15);  color: var(--neg); }
.tag-watch  { background: rgba(245,158,11,.15); color: var(--warn); }
.journal-entry-meta { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--muted); flex-shrink: 0; }
.journal-entry-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.journal-delete { font-size: 12px; padding: 1px 5px; }

.journal-form {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.journal-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
  line-height: 1.5;
}
.journal-textarea:focus { border-color: var(--accent); }
.journal-textarea::placeholder { color: var(--muted); }

.journal-tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.journal-tag-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .4px;
  transition: all .15s;
}
.journal-tag-btn:hover { border-color: var(--accent); color: var(--accent-h); }
.journal-tag-btn.active { border-color: var(--accent); background: rgba(41,98,255,.12); color: var(--accent-h); }

.journal-save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
  transition: background .15s;
}
.journal-save-btn:hover { background: var(--accent-h); }

/* ── Risk Metrics Section ───────────────────────────────────────────────── */
.risk-section {
  margin-top: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.risk-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 12px;
}
.risk-period {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}
.risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.risk-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.risk-item label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: help;
  border-bottom: 1px dashed var(--muted);
  width: fit-content;
}
.risk-item label:hover { color: var(--accent-h); border-bottom-color: var(--accent-h); }
.risk-val { font-size: 18px; font-weight: 700; }

/* ── Candlestick Patterns Section ───────────────────────────────────────── */
.candle-section { margin-bottom: 4px; }
.candle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.candle-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
}
.candle-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.candle-name { font-size: 13px; font-weight: 700; }
.candle-date { font-size: 10px; color: var(--muted); margin-bottom: 6px; }
.candle-desc { font-size: 12px; color: var(--text); line-height: 1.5; margin: 0; }

/* ── Backtest Tab ───────────────────────────────────────────────────────── */
.bt-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
}
.bt-chart-wrap {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bt-bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 70px;
  align-items: center;
  gap: 10px;
}
.bt-bar-label { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-bar-track { height: 10px; background: var(--surface2); border-radius: var(--r-sm, 5px); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.25); }
.bt-bar-fill {
  height: 100%;
  border-radius: var(--r-sm, 5px);
  width: 0;
  transition: width .7s var(--ease, cubic-bezier(.16,1,.3,1));
  animation: growIn .7s var(--ease, cubic-bezier(.16,1,.3,1)) forwards;
}
@keyframes growIn { from { width: 0; } }
.bt-bar-fill.pos { background: linear-gradient(90deg, var(--pos), color-mix(in srgb, var(--pos) 70%, white 15%)); }
.bt-bar-fill.neg { background: linear-gradient(90deg, var(--neg), color-mix(in srgb, var(--neg) 70%, white 15%)); }
.bt-bar-val { font-size: 12px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.bt-bar-val.pos { color: var(--pos); }
.bt-bar-val.neg { color: var(--neg); }

.bt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.bt-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 12px);
  padding: 16px;
  position: relative;
  transition: border-color .2s var(--ease, ease), transform .2s var(--ease, ease), box-shadow .2s var(--ease, ease);
  box-shadow: var(--shadow-sm);
}
.bt-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.bt-card.bt-best { border-color: var(--pos); box-shadow: 0 0 0 1px var(--pos), var(--shadow-md); }
.bt-best-badge {
  position: absolute;
  top: -8px;
  right: 12px;
  background: var(--pos);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.bt-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.bt-desc { font-size: 11px; color: var(--muted); margin-bottom: 12px; line-height: 1.4; }
.bt-return { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 12px; }
.bt-return.pos { color: var(--pos); }
.bt-return.neg { color: var(--neg); }
.bt-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bt-stat label { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.bt-stat span { font-size: 13px; font-weight: 600; }

.bt-disclaimer {
  font-size: 11px;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  line-height: 1.5;
}

/* ── Print styles ───────────────────────────────────────────────────────── */
@media print {
  .header, .watchlist-panel, .modal-header .icon-btn, .modal-header .close-btn { display: none; }
  .modal-overlay { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; border: none; max-height: none; }
  body { background: #fff; color: #000; }
}

/* ── Analyst Tab ─────────────────────────────────────────────────────────── */
.analyst-section { margin-bottom: 4px; }
.analyst-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.analyst-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.analyst-consensus-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.rec-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 16px;
  border-radius: var(--r-md);
  letter-spacing: .3px;
}
.rec-strong-buy  { background: rgba(38,166,154,.22); color: var(--pos); }
.rec-buy         { background: rgba(38,166,154,.13); color: var(--pos); }
.rec-hold        { background: rgba(245,158,11,.15); color: var(--warn); }
.rec-sell        { background: rgba(239,83,80,.13);  color: var(--neg); }
.rec-strong-sell { background: rgba(239,83,80,.22);  color: var(--neg); }
.rec-neutral     { background: rgba(107,114,128,.15); color: var(--muted); }

.pt-range-wrap { margin-bottom: 16px; }
.pt-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.pt-range-track {
  height: 8px;
  background: var(--border);
  border-radius: var(--r-sm);
  position: relative;
}
.pt-range-fill {
  height: 100%;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--neg), var(--warn), var(--pos));
}
.pt-range-marker {
  position: absolute;
  top: -5px;
  width: 3px;
  height: 18px;
  border-radius: 2px;
  transform: translateX(-50%);
}
.pt-marker-cur { background: var(--text); }
.pt-marker-avg { background: var(--accent-h); }
.pt-range-sublabels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
}
.pt-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 3px;
}
.pt-dot-cur { background: var(--text); }
.pt-dot-avg { background: var(--accent-h); }

.rec-bar-wrap { margin-top: 8px; }
.rec-bar-label { font-size: 10px; color: var(--muted); margin-bottom: 5px; }
.rec-stacked-bar {
  display: flex;
  height: 10px;
  border-radius: var(--r-sm);
  overflow: hidden;
  gap: 1px;
}
.rec-seg { height: 100%; min-width: 2px; }
.rec-seg-strong-buy  { background: var(--pos); }
.rec-seg-buy         { background: rgba(38,166,154,.6); }
.rec-seg-hold        { background: var(--warn); }
.rec-seg-sell        { background: rgba(239,83,80,.6); }
.rec-seg-strong-sell { background: var(--neg); }
.rec-bar-legend {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  flex-wrap: wrap;
}

.earnings-table-wrap { overflow-x: auto; }
.earnings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.earnings-table th {
  text-align: left;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.earnings-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.earnings-table tr:last-child td { border-bottom: none; }
.earnings-row-beat { background: rgba(38,166,154,.05); }
.earnings-row-miss { background: rgba(239,83,80,.05); }
.earnings-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: .4px;
  display: inline-block;
}

.ownership-table-wrap { overflow-x: auto; }
.ownership-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ownership-table th {
  text-align: left;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.ownership-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ownership-table tr:last-child td { border-bottom: none; }

/* ── Valuation / DCF Tab ─────────────────────────────────────────────────── */
.dcf-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .dcf-layout { grid-template-columns: 1fr; } }

.dcf-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 14px;
}
.dcf-prefill-note {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 18px;
  padding: 8px 12px;
  background: rgba(41,98,255,.07);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--accent);
  line-height: 1.4;
}
.dcf-field { margin-bottom: 18px; }
.dcf-field > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 6px;
}
.dcf-note { font-size: 11px; color: var(--muted); }
.dcf-readout { font-size: 12px; font-weight: 700; color: var(--accent-h); min-width: 42px; text-align: right; }
.dcf-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
}
.dcf-input:focus { border-color: var(--accent); }
.dcf-input[readonly] { opacity: .55; cursor: not-allowed; }
.dcf-edu { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.dcf-intrinsic-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  text-align: center;
  margin-bottom: 14px;
}
.dcf-intrinsic-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 6px; }
.dcf-intrinsic-val   { font-size: 38px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 4px; }
.dcf-upside          { font-size: 14px; font-weight: 600; margin-top: 4px; }
.dcf-upside.pos      { color: var(--pos); }
.dcf-upside.neg      { color: var(--neg); }

.dcf-breakdown {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 14px;
}
.dcf-bd-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.dcf-bd-row:last-child { border-bottom: none; }
.dcf-bd-total { font-weight: 700; font-size: 13px; }

.dcf-proj-wrap, .dcf-sensitivity-wrap {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 14px;
}
.dcf-proj-table, .dcf-sens-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dcf-proj-table th, .dcf-sens-table th,
.dcf-proj-table td, .dcf-sens-table td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.dcf-proj-table th:first-child, .dcf-sens-table th:first-child,
.dcf-proj-table td:first-child, .dcf-sens-table td:first-child { text-align: left; }
.dcf-proj-table tr:last-child td, .dcf-sens-table tr:last-child td { border-bottom: none; }
.dcf-proj-table th, .dcf-sens-table th {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
}
.sens-high-upside { background: rgba(38,166,154,.18); color: var(--pos); font-weight: 600; }
.sens-downside    { background: rgba(239,83,80,.15);  color: var(--neg); font-weight: 600; }
.sens-neutral     { color: var(--text); }
.sens-invalid     { color: var(--muted); background: rgba(107,114,128,.1); }
.sens-legend {
  display: flex;
  gap: 8px;
  font-size: 11px;
  flex-wrap: wrap;
}
.sens-legend span { padding: 2px 8px; border-radius: var(--r-sm); }

/* ── Correlation Matrix ──────────────────────────────────────────────────── */
.correlation-wrap {
  padding: 8px 0 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.correlation-card { padding: 0 16px 8px; }
.corr-matrix-wrap { }
.corr-matrix-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.corr-table { border-collapse: separate; border-spacing: 2px; font-size: 11px; width: 100%; }
.corr-table th {
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-h);
  text-align: center;
}
.corr-label { font-size: 11px; font-weight: 700; color: var(--text); padding: 4px 6px; white-space: nowrap; }
.corr-cell {
  text-align: center;
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r-sm, 5px);
  font-variant-numeric: tabular-nums;
  transition: transform .15s var(--ease, ease), box-shadow .15s var(--ease, ease);
}
.corr-cell:hover { transform: scale(1.08); box-shadow: 0 0 0 1px rgba(255,255,255,.25), var(--shadow-sm); position: relative; z-index: 1; }
.corr-diag { color: var(--muted); }
.corr-legend {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 10px;
  flex-wrap: wrap;
}
.corr-leg { padding: 2px 6px; border-radius: 3px; }
.corr-leg-green { background: rgba(var(--pos-rgb),.15); color: var(--pos); }
.corr-leg-red   { background: rgba(var(--neg-rgb),.15); color: var(--neg); }

/* ── Calc Panel ──────────────────────────────────────────────────────────── */
.calc-panel {
  position: fixed; top: 56px; right: -420px; width: 400px;
  height: calc(100vh - 56px); background: var(--surface1);
  border-left: 1px solid var(--border); z-index: 165;
  display: flex; flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.35);
}
.calc-panel.open { right: 0; }
.calc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface2); flex-shrink: 0;
}
.calc-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
}
.calc-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.calc-form { display: flex; flex-direction: column; gap: 12px; }
.calc-field { display: flex; flex-direction: column; gap: 4px; }
.calc-field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.calc-readout { color: var(--accent-h); font-weight: 700; }
.calc-required { color: var(--neg); }
.calc-optional { color: var(--muted); font-weight: 400; text-transform: none; font-size: 11px; }
.calc-input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--r-sm); padding: 8px 10px;
  font-size: 13px; font-family: inherit; width: 100%; box-sizing: border-box;
  transition: border-color .15s;
}
.calc-input:focus { outline: none; border-color: var(--accent-h); }
.calc-results {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px;
}
.calc-results-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.calc-result-item {
  background: var(--surface1); border-radius: var(--r-sm);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
}
.calc-result-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.calc-big-val { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.2; }
.calc-rr-val  { font-size: 18px; font-weight: 700; line-height: 1.2; }
.calc-result-sub { font-size: 11px; color: var(--muted); }
.rr-good { color: var(--pos); }
.rr-warn { color: #f59e0b; }
.rr-bad  { color: var(--neg); }
.calc-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0; }
.calc-warn { font-size: 12px; color: #f59e0b; padding: 8px 0; }
.calc-axis-wrap {
  display: flex; flex-direction: column; gap: 0; margin-top: 4px;
}
.calc-axis-track {
  position: relative; height: 10px; background: var(--surface2);
  border-radius: var(--r-sm); overflow: hidden;
}
.calc-axis-zone-loss {
  position: absolute; top: 0; height: 100%; background: rgba(239,83,80,.25);
}
.calc-axis-zone-gain {
  position: absolute; top: 0; height: 100%; background: rgba(38,166,154,.25);
}
.calc-axis-marker {
  position: absolute; top: 0; width: 3px; height: 100%; border-radius: 2px;
}
.calc-marker-stop   { background: var(--neg); }
.calc-marker-entry  { background: var(--accent-h); }
.calc-marker-target { background: var(--pos); }
.calc-axis-sublabels {
  position: relative; height: 36px; font-size: 10px;
}
.calc-axis-lbl {
  position: absolute; transform: translateX(-50%);
  text-align: center; color: var(--muted); line-height: 1.3;
  white-space: nowrap; top: 4px;
}
.calc-edu { display: flex; flex-direction: column; gap: 6px; }
.calc-edu-toggle {
  background: none; border: 1px dashed var(--border);
  color: var(--muted); padding: 7px 12px; border-radius: var(--r-sm);
  font-size: 12px; cursor: pointer; text-align: left;
  display: flex; justify-content: space-between; align-items: center;
  transition: border-color .15s, color .15s;
}
.calc-edu-toggle:hover { border-color: var(--accent-h); color: var(--text); }
.calc-edu-body { display: flex; flex-direction: column; gap: 8px; }
.calc-edu-item {
  background: var(--surface2); border-left: 3px solid var(--accent-h);
  border-radius: 0 6px 6px 0; padding: 10px 12px;
  font-size: 12px; color: var(--muted); line-height: 1.6;
}
.calc-edu-item strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ── Compare Panel ───────────────────────────────────────────────────────── */
.compare-panel {
  position: fixed; top: 56px; right: -770px; width: 750px;
  height: calc(100vh - 56px); background: var(--surface1);
  border-left: 1px solid var(--border); z-index: 172;
  display: flex; flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.35);
}
.compare-panel.open { right: 0; }
.compare-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface2); flex-shrink: 0;
}
.compare-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
}
.compare-body { flex: 1; overflow-y: auto; padding: 16px; }
.cmp-intro { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.cmp-search-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.cmp-sym-input-wrap {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 5px 10px;
}
.cmp-sym-input {
  background: none; border: none; color: var(--text);
  font-size: 13px; font-weight: 700; font-family: inherit;
  width: 70px; text-transform: uppercase; outline: none;
}
.cmp-remove-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 11px; padding: 0 2px; line-height: 1;
}
.cmp-remove-btn:hover { color: var(--neg); }
.cmp-add-btn {
  background: none; border: 1px dashed var(--border);
  color: var(--muted); padding: 6px 14px; border-radius: var(--r-xl);
  font-size: 12px; cursor: pointer; transition: border-color .15s, color .15s;
}
.cmp-add-btn:hover { border-color: var(--accent-h); color: var(--text); }
.cmp-table-wrap { overflow-x: auto; margin-top: 8px; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cmp-header-row th { padding: 8px 10px; text-align: center; border-bottom: 2px solid var(--border); background: var(--surface2); }
.cmp-sym-col { min-width: 110px; }
.cmp-sym-header { font-size: 14px; font-weight: 700; color: var(--accent-h); }
.cmp-sym-name { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.cmp-metric-col { width: 140px; }
.cmp-metric-label { font-size: 11px; color: var(--muted); padding: 6px 10px; white-space: nowrap; }
.cmp-table td { text-align: center; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.cmp-section-header td {
  background: var(--surface2); color: var(--muted);
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; padding: 8px 10px; text-align: left;
}
.cmp-best  { color: var(--pos) !important; font-weight: 700; }
.cmp-worst { color: var(--neg) !important; font-weight: 700; }
.cmp-legend {
  display: flex; gap: 16px; margin-top: 10px;
  font-size: 11px; flex-wrap: wrap; color: var(--muted);
}
.cmp-legend .cmp-best  { font-size: 11px; }
.cmp-legend .cmp-worst { font-size: 11px; }

/* ── Macro Panel ─────────────────────────────────────────────────────────── */
.macro-panel {
  position: fixed; top: 56px; right: -620px; width: 600px;
  height: calc(100vh - 56px); background: var(--surface1);
  border-left: 1px solid var(--border); z-index: 168;
  display: flex; flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.35);
}
.macro-panel.open { right: 0; }
.macro-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface2); flex-shrink: 0;
}
.macro-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
}
.macro-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 0; }
.macro-timestamp {
  font-size: 11px; color: var(--muted); background: var(--surface2);
  border-radius: var(--r-xl); padding: 4px 12px; margin-bottom: 16px;
  align-self: flex-start;
}
.macro-section { margin-bottom: 24px; }
.macro-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); margin-bottom: 10px;
}
.macro-indices-list { display: flex; flex-direction: column; gap: 8px; }
.macro-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 14px;
  transition: border-color .15s;
}
.macro-item:hover { border-color: var(--accent-h); }
.macro-item-left { display: flex; flex-direction: column; gap: 2px; }
.macro-item-sym  { font-size: 13px; font-weight: 700; color: var(--accent-h); }
.macro-item-name { font-size: 11px; color: var(--muted); }
.macro-item-right { display: flex; align-items: center; gap: 10px; }
.macro-item-price { font-size: 13px; font-weight: 600; color: var(--text); }
.macro-change { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-sm); }
.macro-change.pos { background: rgba(38,166,154,.15); color: var(--pos); }
.macro-change.neg { background: rgba(239,83,80,.15);  color: var(--neg); }
.macro-change.muted { color: var(--muted); }
.macro-sector-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px;
}
.macro-sector-cell {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 8px; text-align: center;
  display: flex; flex-direction: column; gap: 3px;
}
.macro-sector-sym  { font-size: 13px; font-weight: 700; color: var(--text); }
.macro-sector-name { font-size: 10px; color: var(--muted); }
.macro-sector-chg  { font-size: 14px; font-weight: 700; }
.macro-sector-chg.pos { color: var(--pos); }
.macro-sector-chg.neg { color: var(--neg); }
.macro-sector-legend { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
