/* InsiderStreet.ai - Main Stylesheet */
/* Light mode default, three-column layout */

:root {
  /* Light mode (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  
  /* Accent colors */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --orange: #f59e0b;
  --orange-bg: #fffbeb;
  --purple: #8b5cf6;
  
  /* Layout */
  --header-height: 56px;
  --watchlist-width: 200px;
  --chat-width: 420px;
  --radius: 12px;
  --radius-sm: 6px;
}

.dark {
  color-scheme: dark;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-hover: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
  --green-bg: #064e3b;
  --red-bg: #7f1d1d;
  --orange-bg: #78350f;
}

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

/* Base */
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
  line-height: 1.5;
}

/* Typography */
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono, .num, .price, .value, .pct {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

/* ==================== THREE COLUMN LAYOUT ==================== */
.app-container {
  display: grid;
  grid-template-columns: var(--watchlist-width) 1fr var(--chat-width);
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "header header header"
    "watchlist canvas chat";
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ==================== HEADER ==================== */
.header {
  grid-area: header;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.logo-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.logo:hover { text-decoration: none; }
.logo img { width: 28px; height: 28px; border-radius: 6px; }

.tagline {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-left: 38px;
}

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  padding: 5px 0;
  gap: 0 2px;
}

.nav-item {
  position: relative;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.nav-sep {  width: 1px;  height: 16px;  background: var(--border, #2a2a4a);  margin: 0 4px;  align-self: center;  opacity: 0.5;}
.nav-item svg {
  width: 12px;
  height: 12px;
  opacity: 0.6;
}

/* Dropdown */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.2s;
  z-index: 200;
}

.dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}

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

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


/* ===== Search Bar ===== */
.search-wrapper { position: relative; flex: 0 1 320px; margin: 0 12px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 10px; color: var(--text-muted); pointer-events: none; }
.search-input {
  width: 100%;
  padding: 7px 36px 7px 32px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent, #6366f1); box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
.search-kbd {
  position: absolute; right: 8px;
  font-size: 10px; font-family: inherit;
  padding: 1px 5px; border-radius: 3px;
  background: var(--bg-hover, #2a2a3e);
  border: 1px solid var(--border);
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1.4;
}
.search-input:focus + .search-kbd { display: none; }

.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg, 0 8px 30px rgba(0,0,0,0.3));
  max-height: 420px;
  overflow-y: auto;
  z-index: 300;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
  cursor: pointer;
}
.search-item:hover, .search-item.active { background: var(--bg-hover); text-decoration: none; }

.search-img { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; flex-shrink: 0; background: var(--bg-secondary); }
.search-img-placeholder { width: 28px; height: 28px; border-radius: 6px; background: var(--bg-secondary); flex-shrink: 0; }

.search-info { flex: 1; min-width: 0; }
.search-sym { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.search-name { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.search-tag { font-size: 9px; font-weight: 600; padding: 1px 4px; border-radius: 3px; background: rgba(99,102,241,0.15); color: var(--accent, #6366f1); }

.search-meta { text-align: right; flex-shrink: 0; }
.search-mcap { font-size: 12px; font-weight: 600; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; }
.search-exch { font-size: 9px; color: var(--text-muted); }

.search-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* Header actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

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

.btn-primary {
  padding: 6px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

/* ==================== WATCHLIST PANEL ==================== */
.watchlist {
  grid-area: watchlist;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

.watchlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.watchlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

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

.watchlist-symbol { font-weight: 600; font-size: 13px; }
.watchlist-change { font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.watchlist-change.positive { color: var(--green); }
.watchlist-change.negative { color: var(--red); }
/* Watchlist enhanced */
a.watchlist-item { display: flex; flex-direction: column; align-items: flex-start; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s; text-decoration: none; color: inherit; gap: 3px; }
a.watchlist-item:hover { background: var(--bg-hover); }
.wl-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; width: 100%; }
.wl-company { font-size: 9px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.wl-scores { display: flex; align-items: center; gap: 4px; padding-left: 0; }
.wl-badge { font-size: 10px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.wl-badge-bullish { background: var(--green, #22c55e); }
.wl-badge-caution { background: var(--yellow, #eab308); }
.wl-badge-neutral { background: #666; }
.wl-credit { font-size: 9px; font-weight: 600; padding: 1px 4px; border-radius: 3px; background: var(--bg-hover, #2a2a3e); color: var(--text-secondary, #aaa); }
.wl-tech { font-size: 9px; font-weight: 600; padding: 1px 4px; border-radius: 3px; }
.wl-tech-bullish { color: #22c55e; background: rgba(34,197,94,0.12); }
.wl-tech-lean-bullish { color: #84cc16; background: rgba(132,204,22,0.12); }
.wl-tech-neutral { color: #facc15; background: rgba(250,204,21,0.12); }
.wl-tech-lean-bearish { color: #f97316; background: rgba(249,115,22,0.12); }
.wl-tech-bearish { color: #ef4444; background: rgba(239,68,68,0.12); }
.wl-days { font-size: 9px; font-weight: 600; padding: 1px 4px; border-radius: 3px; background: var(--bg-hover, #2a2a3e); color: var(--text-muted, #888); font-family: 'JetBrains Mono', monospace; }
.wl-pct { font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 3px; font-family: 'JetBrains Mono', monospace; }
.wl-pct-pos { color: #22c55e; background: rgba(34,197,94,0.12); }
.wl-pct-neg { color: #ef4444; background: rgba(239,68,68,0.12); }


/* ==================== CANVAS (Main Content) ==================== */
.canvas {
  grid-area: canvas;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-secondary);
}

/* ==================== SECTIONS ==================== */
.section {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}

.section-title .icon { font-size: 18px; }

.see-all {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

.see-all:hover { text-decoration: underline; }

/* ==================== CARD GRID ==================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 1400px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1100px) {
  .card-grid { grid-template-columns: 1fr; }
}

/* ==================== CONVERGENCE CARD ==================== */
.convergence-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.convergence-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-symbol { font-size: 18px; font-weight: 700; }
.card-symbol-link { color: inherit; text-decoration: none; }
.card-symbol-link:hover .card-symbol { color: var(--accent, #3b82f6); }

.card-company {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
}

.badge-bullish { background: var(--green-bg); color: var(--green); }
.badge-caution { background: var(--orange-bg); color: var(--orange); }
.badge-bearish { background: var(--red-bg); color: var(--red); }

/* Score bar */
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.score-label { font-size: 11px; color: var(--text-secondary); }
.score-value { font-size: 16px; font-weight: 700; color: var(--accent); }

.score-bar {
  height: 5px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  margin-bottom: 12px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 3px;
}

/* Signal rows */
.signal-rows {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-bottom: 10px;
}

.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 11px;
}

.signal-label { color: var(--text-secondary); }
.signal-value { font-weight: 600; }
.signal-value.positive { color: var(--green); }
.signal-value.negative { color: var(--red); }
.signal-value.neutral { color: var(--text-muted); }

/* Performance */
.performance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.perf-change { font-size: 15px; font-weight: 700; }
.perf-change.positive { color: var(--green); }
.perf-change.negative { color: var(--red); }
.perf-label { font-size: 10px; color: var(--text-muted); }

/* ==================== TRADE CARD ==================== */
.trade-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.trade-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.trade-symbol { font-size: 15px; font-weight: 700; min-width: 55px; }
.trade-symbol-link { color: inherit; text-decoration: none; }
.trade-symbol-link:hover .trade-symbol { color: var(--accent, #3b82f6); }

.trade-details { flex: 1; }
.trade-actor { font-size: 12px; font-weight: 500; margin-bottom: 2px; }
.trade-meta { font-size: 10px; color: var(--text-muted); }

.trade-amount { text-align: right; }
.trade-value { font-size: 12px; font-weight: 600; }
.trade-value.buy { color: var(--green); }
.trade-value.sell { color: var(--red); }
.trade-date { font-size: 10px; color: var(--text-muted); }

.trade-tag {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.trade-tag.buy { background: var(--green); color: white; }
.trade-tag.sell { background: var(--red); color: white; }

/* ==================== CHAT PANEL ==================== */
.chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  height: 100%;
  overflow: hidden;
}

.chat-header {
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 8px;
  margin-left: auto;
  line-height: 1;
}
.chat-close:hover {
  color: var(--text-primary);
}


/* Sidebar collapse when chat is open */
.watchlist.collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}
.app-container.chat-active {
  grid-template-columns: 0px 1fr calc(var(--chat-width) + var(--watchlist-width));
}
.sidebar-toggle {
  display: none;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
}
.sidebar-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.chat-active .sidebar-toggle {
  display: block;
}

/* Mobile chat full width + minimize */
@media (max-width: 768px) {
  .chat-close {
    display: block;
  }
  .chat {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60vh;
    z-index: 999;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }
  .chat.minimized {
    display: none;
  }
  .chat-fab.show {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  min-height: 0;
}

.chat-message { margin-bottom: 12px; }
.chat-message.user { text-align: right; }

.chat-message .bubble {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 90%;
  font-size: 13px;
  line-height: 1.5;
}

.chat-message.user .bubble {
  background: var(--accent);
  color: white;
  border-radius: 12px 12px 4px 12px;
}

.chat-message.ai .bubble {
  background: var(--bg-tertiary);
  text-align: left;
  max-width: 100%;
  width: 100%;
}

.chat-input-area {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--bg-primary);
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  resize: none;
  min-height: 40px;
  max-height: 100px;
}

.chat-input:focus { border-color: var(--accent); outline: none; }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send {
  flex-shrink: 0;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
}

.chat-send:hover { background: var(--accent-hover); }
/* ==================== UTILITIES ==================== */
.positive, .green { color: var(--green); }
.negative, .red { color: var(--red); }
.muted { color: var(--text-muted); }
.small { font-size: 11px; }
.text-right { text-align: right; }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

/* ==================== SCROLLBAR ==================== */
/* Thin auto-hide scrollbar (Firefox) */
* { scrollbar-width: thin; scrollbar-color: transparent transparent; }
*:hover { scrollbar-color: var(--border) transparent; }

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; }
*:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }
*:hover::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Light mode override */
:root:not(.dark) *:hover { scrollbar-color: rgba(0,0,0,0.15) transparent; }
:root:not(.dark) *:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }
:root:not(.dark) *:hover::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) 1fr auto;
    grid-template-areas:
      "header"
      "canvas"
      "chat";
    overflow: auto;
  }
  .watchlist { display: none; }
}

/* ==================== STATS BANNER ==================== */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 12px;
}

.stat {
  text-align: center;
  color: white;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
}

@media (max-width: 800px) {
  .stats-banner {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* ==================== HERO STATS BAR ==================== */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.hero-stat {
  text-align: center;
}
.hero-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  line-height: 1.2;
}
.hero-stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}
.hero-stat-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}
@media (max-width: 600px) {
  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .hero-stat-value {
    font-size: 1.1rem;
  }
}

/* ==================== STOCK PAGE ==================== */
.stock-header {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.stock-header-main {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
  margin-bottom: 12px;
}

.stock-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stock-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg-secondary);
}

.stock-symbol {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.stock-name {
  font-size: 14px;
  color: var(--text-secondary);
}

.stock-price-group {
  text-align: right;
  transition: background-color 0.7s ease-out;
  border-radius: 6px;
  padding: 2px 6px;
  margin: -2px -6px;
}
.flash-green { background-color: rgba(34, 197, 94, 0.25) !important; }
.flash-red { background-color: rgba(239, 68, 68, 0.25) !important; }

.stock-price {
  font-size: 28px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.stock-price .usd-equiv,
.stat-val .usd-equiv {
  font-size: 0.75em;
  font-weight: 400;
  color: var(--text-muted, #888);
  margin-left: 4px;
}

.stock-change {
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
}

.stock-extended {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
  opacity: 0.85;
}

.stock-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  overflow: hidden;
  max-width: 100%;
}
@media (max-width: 768px) {
  .stock-meta .ar-badge {
    flex-basis: 100%;
    margin-top: 2px;
  }
  .stock-meta .ar-dot {
    display: none;
  }
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-break {
  flex-basis: 100%;
  height: 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 9px 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
  text-decoration: none;
}

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

/* Overview Grid */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

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

@media (max-width: 800px) {
  .overview-grid { grid-template-columns: 1fr; }
}

.overview-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.overview-card.full-width {
  grid-column: 1 / -1;
}

.overview-card.overview-about {
  grid-column: span 2;
}
.overview-about .description {
  max-height: 200px;
  overflow-y: auto;
}
@media (max-width: 768px) {
  .overview-card.overview-about { grid-column: span 1; }
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.stat-label { color: var(--text-secondary); }
.stat-val { font-weight: 600; }

/* Convergence Mini */
.convergence-mini .score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.convergence-mini .score-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-bottom: 12px;
}

.convergence-mini .signal-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 4px 0;
}

.convergence-mini .perf-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.convergence-mini .perf-change {
  font-size: 16px;
  font-weight: 700;
}

.convergence-mini .perf-label {
  font-size: 10px;
  color: var(--text-muted);
}

/* Ratings */
.rating-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.rating-segment.buy { background: var(--green); }
.rating-segment.hold { background: var(--orange); }
.rating-segment.sell { background: var(--red); }

.rating-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 10px;
}

.price-target {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

/* Description */
.description {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* No Data */
.no-data {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

/* Recent Activity */
.recent-activity {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.recent-activity h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

/* Mini Table */
.mini-table {
  font-size: 12px;
}

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

.mini-table th {
  text-align: left;
  padding: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.mini-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.mini-table tr:last-child td {
  border-bottom: none;
}

/* ==================== DATA TABLES ==================== */
.data-section {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.data-section .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.data-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.record-count {
  font-size: 11px;
  color: var(--text-muted);
}

.data-table-wrap {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  padding: 10px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

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

.data-table .text-right { text-align: right; }
.data-table .small { font-size: 10px; }

.data-table .trade-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.data-table .trade-tag.buy { background: var(--green-bg); color: var(--green); }
.data-table .trade-tag.sell { background: var(--red-bg); color: var(--red); }

.data-table .no-data {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

/* ==================== SUMMARY GRID ==================== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

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

@media (max-width: 600px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

.summary-item {
  text-align: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.summary-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

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

.summary-change {
  font-size: 11px;
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}

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

/* ==================== INSTITUTIONAL OVERVIEW ==================== */
.inst-overview-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}

@media (max-width: 900px) {
  .inst-overview-grid { 
    grid-template-columns: 1fr;
  }
}

.chart-container {
  min-height: 250px;
}

.summary-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-item-lg {
  text-align: center;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.summary-item-lg .summary-value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.summary-item-lg .summary-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.summary-item-lg .summary-change {
  font-size: 12px;
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.activity-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
}

.activity-item.green-bg { background: var(--green-bg); }
.activity-item.red-bg { background: var(--red-bg); }

.activity-val {
  font-size: 18px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.green-bg .activity-val { color: var(--green); }
.red-bg .activity-val { color: var(--red); }

.activity-lbl {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Filing link */
.filing-link {
  color: #60a5fa;
  text-decoration: none;
  font-size: 0.85rem;
}
.filing-link:hover {
  text-decoration: underline;
}


/* Mobile horizontal scroll for data sections */
@media (max-width: 768px) {
  .data-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    min-width: 500px;
  }
  .chart-container {
    min-width: 350px;
  }
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
    min-width: 350px;
  }
  .ratios-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stock-tabs .tabs {
    gap: 2px 4px;
  }
}


/* ==================== MOBILE SCROLL FIX ==================== */
/* Prevent horizontal page overflow */
html, body { overflow-x: hidden; max-width: 100vw; }

/* Canvas content must not overflow viewport */
.canvas { max-width: 100vw; box-sizing: border-box; }

@media (max-width: 1024px) {
  .canvas { padding: 12px; }

  /* All tab sections: contain their children */
  .an-section, .tc-section, .pr-section {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ECharts containers: shrink to fit */
  .an-chart, .an-chart-tall, .an-radar-wrap,
  .tc-chart, .tc-chart-sm, .tc-chart-lg, .tc-gauge,
  .pr-chart, .pr-chart-lg,
  .an-edge-trend, .an-edge-gauge {
    max-width: 100%;
    min-width: 0;
  }

  /* Grids: collapse to fewer columns */
  .an-scorecard { grid-template-columns: 1fr; }
  .an-risk-grid { grid-template-columns: repeat(2, 1fr); }
  .an-val-grid { grid-template-columns: repeat(2, 1fr); }
  .an-gd-grid { grid-template-columns: repeat(2, 1fr); }
  .an-dupont-flow { font-size: 0.8rem; }
  .an-dupont-box { min-width: 80px; padding: 0.5rem; }
  .an-edge-hero { grid-template-columns: 1fr; }
  .an-edge-pillars { grid-template-columns: repeat(2, 1fr); }
  .an-exec-table { min-width: 600px; }
  .an-prod-grid { grid-template-columns: repeat(2, 1fr); }

  .tc-hero { grid-template-columns: 1fr; }
  .tc-gauge-grid { grid-template-columns: repeat(2, 1fr); }
  .tc-pattern-grid { grid-template-columns: 1fr; }

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

  /* Tables: horizontal scroll wrapper */
  .pr-table-wrap, .tc-ma-table, .an-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .pr-table, .tc-ma-table table {
    min-width: 600px;
  }

  /* Stock header: stack on mobile */
  .stock-header-main { flex-direction: column; gap: 8px; }
}

@media (max-width: 480px) {
  .canvas { padding: 8px; }

  .an-risk-grid { grid-template-columns: 1fr; }
  .an-val-grid { grid-template-columns: repeat(2, 1fr); }
  .tc-gauge-grid { grid-template-columns: 1fr; }
  .pr-signal-grid { grid-template-columns: 1fr; }
  .an-edge-score-row .label { width: 100px; font-size: 0.78rem; }
  .tc-score-row .label { width: 80px; font-size: 0.78rem; }

  .an-chart, .tc-chart, .pr-chart { height: 250px; }
  .an-chart-tall, .tc-chart-lg, .pr-chart-lg { height: 300px; }
}

/* ==================== HOMEPAGE GRID + NEWS FEED ==================== */

.home-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto auto;
  gap: 12px;
}

/* Tighten section spacing inside homepage */
.home-main .section { margin-bottom: 5px; }
.home-main .section-header { margin-bottom: 5px; }
.home-main .card-grid { gap: 10px; }

.home-main {
  min-width: 0;
  grid-row: 1;
  grid-column: 1;
}

.home-feed {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  grid-row: 1;
  grid-column: 2;
  /* Don't let feed content influence row height — clamp to left column */
  height: 0;
  min-height: calc(100% - 3px);
}

/* Stats banner spans both columns */
.home-stats {
  grid-column: 1 / -1;
}

.feed-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 1rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.feed-bolt {
  font-size: 1.1rem;
}

.feed-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s;
}

.feed-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.feed-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 24px;
  margin-top: 1px;
}
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 1px;
}

/* Category badge colors - icons only, no backgrounds */
.feed-upgrade    { color: var(--green); }
.feed-downgrade  { color: var(--red); }
.feed-target     { color: var(--accent); }
.feed-insider    { color: var(--orange); }
.feed-congress_house,
.feed-congress_senate { color: var(--purple); }
.feed-corporate  { color: var(--text-secondary); }
.feed-index      { color: var(--accent); }
.feed-earnings   { color: var(--green); }
.feed-score      { color: #d97706; }
.dark .feed-score { color: #fbbf24; }
/* Breaking feed: VIP institutional & big movers */
.feed-vip         { color: #f59e0b; font-weight: 600; }
.feed-institution { color: #8b5cf6; }
.feed-mover_up    { color: var(--green); font-weight: 600; }
.feed-mover_down  { color: var(--red); font-weight: 600; }
.dark .feed-vip   { color: #fbbf24; }


.feed-body {
  flex: 1;
  min-width: 0;
}

.feed-headline {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-primary);
}

.feed-headline strong {
  color: var(--accent);
  font-weight: 600;
}

.feed-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

.feed-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 1200px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-main {
    grid-column: 1;
    grid-row: 1;
  }
  .home-feed {
    grid-column: 1;
    grid-row: 2;
    position: static;
    height: auto;
    min-height: 0;
    max-height: 400px;
  }
  .home-stats { grid-column: 1; }
}

@media (max-width: 1024px) {
  .home-feed { max-height: 350px; }
}


/* ==================== ETF DETAIL PAGE ==================== */
/* Reuses stock classes: overview-grid, overview-card, card-title, stats-grid,
   stat-item, stat-label, stat-val, mini-table, recent-activity, badge-*,
   signal-row, no-data, data-table, etc.
   Only ETF-unique styles below. */

/* ETF header — mirrors .stock-header */
.etf-header { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.etf-header-main { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.etf-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.etf-badge { display: inline-block; background: var(--accent); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px; letter-spacing: 0.5px; }
.badge-bearish { background: var(--red-bg); color: var(--red); }

/* Holding type badges */
.etfh-badge { display: inline-block; font-size: 9px; font-weight: 600; padding: 1px 6px; border-radius: 3px; margin-left: 4px; vertical-align: middle; letter-spacing: 0.3px; }
.etfh-badge-private { background: #8b5cf6; color: #fff; }
.etfh-badge-bond { background: #f59e0b; color: #fff; }
.etfh-badge-swap { background: #06b6d4; color: #fff; }
.etfh-badge-cash { background: #10b981; color: #fff; }
.etfh-badge-other { background: #64748b; color: #fff; }

/* Private/bond row tinting */
.etfh-row-private { background: rgba(139, 92, 246, 0.06); }
.etfh-row-bond { background: rgba(245, 158, 11, 0.06); }

/* Filter chips (holdings & changes) */
.etfh-filter-chips { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.etfh-chip { padding: 5px 12px; font-size: 11px; font-weight: 500; border: 1px solid var(--border); border-radius: 20px; color: var(--text-secondary); text-decoration: none; }
.etfh-chip:hover { color: var(--text-primary); border-color: var(--text-muted); text-decoration: none; }
.etfh-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Pagination */
.etfh-pagination { display: flex; align-items: center; gap: 4px; margin-top: 16px; justify-content: center; }
.etfh-page-btn { padding: 5px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; }
.etfh-page-btn:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.etfh-page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.etfh-page-dots { color: var(--text-muted); padding: 0 4px; }

/* Sort header links in data tables */
.etfh-sort { color: var(--text-secondary); text-decoration: none; }
.etfh-sort:hover { color: var(--accent); text-decoration: none; }

/* Summary line */
.etfh-summary { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }

/* Positive/Negative helpers (if not already defined) */
.positive { color: var(--green); }
.negative { color: var(--red); }

/* ========== Screener Page ========== */
.screener-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 4px;
}
.screener-chips { display: flex; gap: 4px; }
.screener-chip {
  padding: 5px 12px; font-size: 12px; font-weight: 500; border: 1px solid var(--border);
  border-radius: 20px; background: transparent; color: var(--text-secondary);
  cursor: pointer; transition: all .15s;
}
.screener-chip:hover { border-color: var(--accent); color: var(--accent); }
.screener-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.screener-select, .screener-input {
  padding: 5px 10px; font-size: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-primary);
  font-family: inherit;
}
.screener-select:focus, .screener-input:focus { outline: none; border-color: var(--accent); }
.screener-input-sm { width: 80px; }
.screener-num-group { display: flex; align-items: center; gap: 4px; }
.screener-num-group label {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}
.screener-check {
  display: flex; align-items: center; gap: 4px; font-size: 12px;
  color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.screener-check input { accent-color: var(--accent); }
.sort-header { cursor: pointer; user-select: none; white-space: nowrap; }
.sort-header:hover { color: var(--accent); }
.sort-arrow { font-size: 10px; color: var(--accent); }
.screener-bool { font-weight: 600; }

/* Screener filter grid */
.screener-filter-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px;
  padding: 12px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.scr-fg-item label:first-child {
  display: block; font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; white-space: nowrap;
}
.scr-fg-item .screener-select { width: 100%; }
.scr-range { display: flex; gap: 4px; }
.scr-range input {
  width: 50%; padding: 4px 6px; font-size: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-primary);
  font-family: inherit;
}
.scr-range input:focus { outline: none; border-color: var(--accent); }


/* AI Chat additions */
.chat-welcome {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 10px;
}
.chat-welcome p {
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--text-primary);
}
.chat-welcome ul {
  margin: 0;
  padding-left: 16px;
}
.chat-welcome li {
  margin: 4px 0;
}
.chat-message.typing .bubble {
  background: var(--surface);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.chat-message .bubble strong {
  font-weight: 600;
}
.chat-message .bubble em {
  font-style: italic;
}


/* Chat floating action button (mobile only) */
.chat-fab {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
}
.chat-fab:hover {
  background: var(--accent-hover);
}
@media (max-width: 1024px) {
  .chat.minimized {
    display: none;
  }
  .chat-fab.show {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Weekly Expected Move Range */
.wem-container {
  margin-top: 12px;
  padding: 8px 0;
}

.wem-label {
  font-size: 11px;
  color: var(--text-secondary, #888);
  margin-bottom: 6px;
}

.wem-pct {
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
  margin-left: 4px;
}

.wem-range {
  position: relative;
  height: 8px;
  background: var(--bg-card, #1a1a2e);
  border-radius: 4px;
  margin: 8px 0;
}

.wem-bar-2sigma {
  position: absolute;
  height: 100%;
  background: rgba(239, 68, 68, 0.2);
  border-radius: 4px;
}

.wem-bar-1sigma {
  position: absolute;
  height: 100%;
  background: rgba(34, 197, 94, 0.3);
  border-radius: 4px;
}

.wem-start-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #666;
  transform: translateX(-50%);
}

.wem-start {
  color: #888;
  font-size: 10px;
}

.wem-price-dot {
  position: absolute;
  top: -2px;
  width: 4px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.wem-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-secondary, #888);
  font-family: 'JetBrains Mono', monospace;
}

.wem-val {
  flex: 1;
  text-align: center;
}

.wem-current {
  font-weight: 700;
  color: var(--text-primary, #e0e0e0);
}

/* Mini Candlestick Chart */
.mini-chart {
  width: 100%;
  height: 180px;
  min-width: 300px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stock-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.returns-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  align-items: center;
}

.return-item {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
}

.return-item.positive {
  color: #22c55e;
}

.return-item.negative {
  color: #ef4444;
}



.stock-quote-section {
  text-align: right;
}

@media (max-width: 768px) {
  .stock-header-main {
    grid-template-columns: 1fr !important;
  }
  .stock-quote-section {
    text-align: left;
  }
  .mini-chart {
    height: 150px;
    min-width: auto;
    order: 2;
  }
}

/* ==================== GLAUXIE CHAT ENHANCEMENTS ==================== */
.chat-md-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.chat-md-link:hover { opacity: 0.8; }

.chat-sources {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chat-source-link {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.chat-source-link:hover {
  background: var(--accent);
  color: white;
}

.chat-chart-container {
  margin: 8px 0 4px;
  max-width: 90%;
}
.chat-chart-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.chat-chart {
  width: 220px;
  height: 180px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.chat-message.ai .bubble ul {
  margin: 4px 0;
  padding-left: 16px;
}
.chat-message.ai .bubble li { margin: 2px 0; }
.chat-message.ai .bubble code {
  background: var(--bg-secondary);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.chat-message.ai .bubble pre {
  background: var(--bg-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 11px;
  margin: 6px 0;
}
.chat-message.ai .bubble pre code {
  background: none;
  padding: 0;
}

/* News card on stock overview */
.overview-news .news-list { display: flex; flex-direction: column; gap: 8px; }
.overview-news .news-item { display: flex; gap: 8px; text-decoration: none; color: inherit; padding: 6px; border-radius: 6px; }
.overview-news .news-item:hover { background: rgba(255,255,255,0.05); }
.overview-news .news-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.overview-news .news-headline { font-size: 0.82rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.overview-news .news-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.news-sentiment { font-size: 0.75rem; font-weight: 600; padding: 1px 5px; border-radius: 3px; margin-right: 4px; }
.news-sentiment.bullish { background: rgba(46,204,113,0.15); color: #2ecc71; }
.news-sentiment.bearish { background: rgba(231,76,60,0.15); color: #e74c3c; }


/* ==================== MOBILE & WEBVIEW LAYOUT ==================== */
/* WebView app feel */
html { -webkit-tap-highlight-color: transparent; }
.app-container { overscroll-behavior: none; }

@media (max-width: 768px) {
  /* Normal document flow — page scrolls naturally */
  .app-container {
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Header: wrap logo+actions top, nav wraps below, search full-width */
  .header {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 4px;
    padding-top: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .logo-group { order: 1; }
  .header-actions { order: 2; margin-left: auto; }
  .tagline { display: none; }

  /* Nav wraps — all buttons visible */
  .nav {
    order: 3;
    width: 100%;
    padding: 2px 0;
    gap: 0;
  }
  .nav-sep { display: none; }
  .nav > div { display: none; }
  .nav-item { padding: 5px 8px; font-size: 11px; }

  /* Search below nav, full width */
  .search-wrapper {
    order: 4;
    width: 100%;
    flex: 1 1 100%;
    margin: 0;
  }
  .search-kbd { display: none; }

  /* Safe areas for notched devices / WebView */
  .canvas {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* Hero section tighten */
  .hero-section h1 { font-size: 1.35rem; }
  .hero-section p { font-size: 0.85rem; }

  /* Touch-friendly */
  a, button { touch-action: manipulation; }
}

@media (max-width: 480px) {
  .hero-section h1 { font-size: 1.2rem; }
  .hero-stats { padding: 12px; gap: 8px; }
  .hero-stat-value { font-size: 1rem; }
  .hero-stat-label { font-size: 0.65rem; }
  .feed-item { padding: 8px 12px; }
  .feed-headline { font-size: 0.78rem; }
}
