/* ══════════════════════════════════════════════════════════════
   NARRATIVESTOCK  ·  Design System
   Dark-first · Glass · Apple-inspired · Responsive
   ══════════════════════════════════════════════════════════════ */

/* ── RESET ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0 }

/* ── TOKENS · DARK (default) ─────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Background */
  --bg:            #09090e;
  --bg-glow-a:     rgba(59, 126, 255, 0.07);
  --bg-glow-b:     rgba(120, 60, 255, 0.05);

  /* Glass */
  --glass-sidebar: rgba(11, 13, 20, 0.80);
  --glass-card:    rgba(14, 17, 26, 0.68);
  --glass-topbar:  rgba(9,  9,  14, 0.78);
  --glass-blur:    20px;

  /* Surfaces */
  --surface:       rgba(20, 23, 34, 0.72);
  --surface2:      rgba(28, 32, 46, 0.65);
  --surface3:      rgba(36, 41, 58, 0.60);

  /* Borders */
  --border:        rgba(255, 255, 255, 0.058);
  --border-strong: rgba(255, 255, 255, 0.105);

  /* Text */
  --text:          #eceef5;
  --text-2:        #8c919f;
  --text-3:        #464e60;

  /* Accent */
  --blue:          #3b7eff;
  --blue-dim:      rgba(59, 126, 255, 0.13);
  --blue-border:   rgba(59, 126, 255, 0.30);

  /* Semantic */
  --green:         #22c55e;
  --green-dim:     rgba(34, 197, 94,  0.11);
  --red:           #f04a4a;
  --red-dim:       rgba(240, 74,  74,  0.11);
  --amber:         #f59e0b;

  /* Shadows */
  --shadow-sm:  0 1px 4px  rgba(0,0,0, 0.35);
  --shadow-md:  0 4px 20px rgba(0,0,0, 0.45);
  --shadow-lg:  0 8px 40px rgba(0,0,0, 0.55);

  /* Layout */
  --sidebar-w:   260px;
  --topbar-h:    52px;
  --radius:      14px;
  --radius-sm:   9px;
  --radius-pill: 999px;
}

/* ── TOKENS · LIGHT ──────────────────────────────────────────── */
html[data-theme="light"] {
  color-scheme: light;

  --bg:            #eaecf4;
  --bg-glow-a:     rgba(59, 126, 255, 0.10);
  --bg-glow-b:     rgba(120, 60, 255, 0.07);

  --glass-sidebar: rgba(255, 255, 255, 0.74);
  --glass-card:    rgba(255, 255, 255, 0.68);
  --glass-topbar:  rgba(234, 236, 244, 0.80);

  --surface:       rgba(255, 255, 255, 0.80);
  --surface2:      rgba(245, 247, 252, 0.85);
  --surface3:      rgba(236, 239, 248, 0.90);

  --border:        rgba(0, 0, 0, 0.070);
  --border-strong: rgba(0, 0, 0, 0.125);

  --text:          #0e1018;
  --text-2:        #5a6070;
  --text-3:        #9ba3b4;

  --shadow-sm:  0 1px 4px  rgba(0,0,0, 0.07);
  --shadow-md:  0 4px 20px rgba(0,0,0, 0.10);
  --shadow-lg:  0 8px 40px rgba(0,0,0, 0.14);
}

/* ── BASE ────────────────────────────────────────────────────── */
html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Ambient glow behind glass */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 10% 5%,  var(--bg-glow-a) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 90% 90%, var(--bg-glow-b) 0%, transparent 70%);
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 10px; left: 10px; bottom: 10px;
  width: var(--sidebar-w);
  z-index: 150;
  display: flex;
  flex-direction: column;
  background: var(--glass-sidebar);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;       /* clips all children to the rounded corners */
  box-shadow: var(--shadow-lg);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-top {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 28px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* Soft fade at the bottom so scrollable content looks intentional, not cut off */
  mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
}
.sidebar-top::-webkit-scrollbar { display: none; }

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 6px 12px;
  user-select: none;
}
.logo-img {
  width: 44px; height: 44px;
  border-radius: 13px;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 4px 18px rgba(59,126,255,.38);
}
.logo-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.logo-text {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -.4px;
  color: var(--text-2);
  line-height: 1.1;
}
.logo-text strong {
  font-weight: 700;
  color: var(--blue);
}
.logo-tagline {
  font-size: 8px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1;
}

/* Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: color .15s, background .15s, border-color .15s;
  width: 100%;
}
.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
}
html[data-theme="light"] .nav-item:hover {
  background: rgba(0,0,0,.04);
}
.nav-item.active {
  color: var(--blue);
  background: var(--blue-dim);
  border-color: var(--blue-border);
}
.nav-icon {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: .85;
}

/* Sidebar bottom — pinned, never scrolls */
.sidebar-bottom {
  flex-shrink: 0;
  padding: 12px 12px 20px;   /* 20px bottom = clears the 20px border-radius curve */
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Profile row */
.profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  text-align: left;
  transition: background .15s, border-color .15s;
}
.profile-row:hover { background: var(--surface3); border-color: var(--border-strong); }

.profile-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue-dim);
  border: 1px solid var(--blue-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--blue);
}
.profile-avatar svg { width: 16px; height: 16px; }

.profile-text { flex: 1; min-width: 0; }
.profile-name { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); }
.profile-sub  { display: block; font-size: 10.5px; color: var(--text-3); margin-top: 1px; }

.profile-chevron { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }

/* Theme segmented control */
.theme-seg {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.theme-seg-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.theme-seg-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.theme-seg-btn:hover { color: var(--text-2); }
.theme-seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ── APP SHELL ───────────────────────────────────────────────── */
.app-shell {
  margin-left: calc(var(--sidebar-w) + 20px); /* sidebar width + gap */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ── TOPBAR (mobile only) ────────────────────────────────────── */
.topbar {
  display: none; /* hidden on desktop — enabled in mobile media query */
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  flex-shrink: 0;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  background: var(--glass-topbar);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border-bottom: 1px solid var(--border);
}
/* Topbar: 3-column grid → side | logo | login */
.topbar-side {
  width: 36px;
  flex-shrink: 0;
}

.mobile-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.mobile-logo-img {
  width: 26px; height: 26px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 2px 10px rgba(59,126,255,.35);
  flex-shrink: 0;
}
.mobile-logo-text {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -.4px;
  color: var(--text-2);
  line-height: 1;
}
.mobile-logo-text strong {
  font-weight: 700;
  color: var(--blue);
}

/* Hamburger — kept for potential future use but hidden */
.hamburger {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--text-2);
  display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hamburger svg { width: 18px; height: 18px; }

/* Topbar search button (top-left on mobile) */
.topbar-search-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--text-2);
  display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color .15s;
}
.topbar-search-btn svg { width: 18px; height: 18px; }

/* Topbar login button (top-right on mobile) — prominent filled style */
.topbar-login-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: none;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center; justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  transition: opacity .15s;
}
.topbar-login-btn:active { opacity: .8; }
.topbar-login-btn svg { width: 16px; height: 16px; }
/* When signed in: show avatar, no background */
.topbar-login-btn.signed-in {
  background: none;
  border: 1px solid var(--border-strong);
  padding: 0;
  width: 36px; height: 36px;
}
.topbar-login-btn .topbar-avatar {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
}

/* Card-topbar search (above the screener table) */
.card-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.card-search-btn {
  display: none; /* shown only on mobile via media query */
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--text-2);
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color .15s;
}
.card-search-btn svg { width: 15px; height: 15px; }

/* ── SIDEBAR SEARCH ──────────────────────────────────────────── */
/* Command-palette trigger — filled surface + border + ⌘K badge */
.sidebar-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.sidebar-search-btn:hover {
  color: var(--text-2);
  background: var(--surface3);
  border-color: rgba(255,255,255,.16);
}
html[data-theme="light"] .sidebar-search-btn:hover {
  background: var(--surface3);
  border-color: rgba(0,0,0,.14);
}
.sidebar-search-btn svg { width: 14px; height: 14px; flex-shrink: 0; opacity: .65; }
.sidebar-search-btn span { flex: 1; }

/* ⌘K badge inside search trigger */
.sidebar-search-kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface3);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 2px 5px;
  letter-spacing: .2px;
  flex-shrink: 0;
  user-select: none;
  line-height: 1.4;
}

/* Search bar inside picker */
.stock-picker-searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 6px;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: border-color .2s;
}
.stock-picker-searchbar:focus-within {
  border-color: var(--blue-border);
}
.stock-picker-searchbar svg { width: 13px; height: 13px; stroke: var(--text-3); flex-shrink: 0; }
.stock-picker-searchbar input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--text); font-size: 13px;
}
.stock-picker-searchbar input::placeholder { color: var(--text-3); }

/* ── PAGE ────────────────────────────────────────────────────── */
.page {
  height: 100svh;
  padding: 22px 24px 10px;
  max-width: 1280px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── INDEX TABS ──────────────────────────────────────────────── */
.index-tabs[hidden] { display: none !important; }
.index-tabs {
  display: flex;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.index-tabs::-webkit-scrollbar { display: none; }

.index-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 17px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
}
.index-tab:hover { color: var(--text); }
.index-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.index-tab .chip {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface2);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
}
.index-tab.active .chip { color: var(--blue); background: var(--blue-dim); }

/* "+" add-markets button */
.tab-add-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s;
  position: relative;
}
.tab-add-btn:hover { color: var(--text-2); }
.tab-add-btn svg { width: 14px; height: 14px; }

/* Dropdown panel */
.tab-dropdown {
  position: fixed; /* set via JS; declared here for animation */
  z-index: 300;
  width: 260px;
  background: var(--glass-sidebar);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: dropIn .15s ease;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
.tab-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.tab-dropdown-header span {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3);
}
.tab-dropdown-header em {
  font-size: 11px; font-style: normal;
  color: var(--text-3);
}
.tab-dropdown-list {
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 6px;
}
.tab-dropdown-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 2px;
  border-radius: 8px;
  transition: background .12s;
}
.tab-dropdown-item:hover { background: rgba(255,255,255,.055); }
html[data-theme="light"] .tab-dropdown-item:hover { background: rgba(0,0,0,.04); }
.tab-dropdown-item.item-active { background: var(--blue-dim); }
.tab-dropdown-item.item-active .tab-dd-label { color: var(--blue); }

/* Row button (flag + label + count) */
.tab-dd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  min-width: 0;
}
.tab-dd-row:hover { background: none; }

.tab-dd-flag  { font-size: 16px; flex-shrink: 0; }
.tab-dd-label { flex: 1; font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.tab-dd-count { font-size: 10px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; flex-shrink: 0; }

/* Pin button */
.tab-dd-pin {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .12s, background .12s;
  opacity: 0;
}
.tab-dropdown-item:hover .tab-dd-pin { opacity: 1; }
.tab-dd-pin.pinned { opacity: 1; color: var(--blue); }
.tab-dd-pin:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,.1); }
html[data-theme="light"] .tab-dd-pin:hover:not(:disabled) { background: rgba(0,0,0,.06); }
.tab-dd-pin:disabled { opacity: .25; cursor: not-allowed; }

.tab-dd-maxnote {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--amber);
  border-top: 1px solid var(--border);
  text-align: center;
}
.tab-dd-maxnote[hidden] { display: none; }

/* Ghost tab: active market that is not pinned */
.index-tab.ghost {
  border-bottom-style: dashed;
  opacity: .75;
}

/* ── SCREENER CARD ───────────────────────────────────────────── */
.screener-view[hidden], #chart-view[hidden] { display: none; }
.screener-view {
  flex: 1;
  min-height: 0;
  display: flex;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--glass-card);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* Card top bar */
.card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
.result-label { font-size: 12px; color: var(--text-2); }
.result-label strong { color: var(--text); font-weight: 600; }
.search-scope-hint { color: var(--blue); font-size: 11px; font-weight: 500; margin-left: 4px; }

/* Timeframe pills */
.tf-buttons {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
.tf-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  color: var(--text-2);
  background: none;
  border: none;
  transition: color .12s, background .12s;
  white-space: nowrap;
}
.tf-btn:hover:not(.active) { color: var(--text); }
.tf-btn.active { background: var(--blue-dim); color: var(--blue); }

/* Table */
.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 700px; }

thead { position: sticky; top: 0; z-index: 2; background: var(--glass-card); backdrop-filter: blur(8px); }
thead tr, tbody tr { border-bottom: 1px solid var(--border); }

th {
  padding: 9px 14px;
  text-align: right;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .55px;
  white-space: nowrap;
  user-select: none;
}
th.left, td.left { text-align: left; }
th.sortable { cursor: pointer; transition: color .15s; }
th.sortable:hover, th.active-sort { color: var(--text-2); }
.sort-ic { display: inline-block; margin-left: 3px; font-size: 9px; opacity: .35; }
th.active-sort .sort-ic { opacity: 1; color: var(--blue); }

td {
  padding: 12px 14px;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 13px;
}
tbody tr { transition: background .1s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
html[data-theme="light"] tbody tr:hover { background: rgba(0,0,0,.025); }

/* Star col */
.td-star { width: 44px; padding-left: 16px; padding-right: 6px; }
.star-btn {
  background: none; border: none;
  font-size: 16px; color: var(--text-3);
  padding: 4px;
  transition: color .15s, transform .12s;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.star-btn:hover { color: var(--amber); transform: scale(1.18); }
.star-btn.on { color: var(--amber); }

/* Symbol cell */
.stock-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.slogo {
  width: 34px; height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -.5px;
  overflow: hidden;
  background: var(--bg-3);
}
.slogo-img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 50%;
}
.sticker {
  font-size: 13px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  display: flex; align-items: center; gap: 5px;
  letter-spacing: -.2px;
}
.sexch {
  font-size: 9.5px; color: var(--text-3);
  background: var(--surface3);
  border-radius: 4px; padding: 1px 5px;
  font-weight: 400; font-family: Inter, sans-serif;
  letter-spacing: .1px;
}
.sname {
  font-size: 11px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 190px;
  margin-top: 1px;
}

/* Data cells */
.td-price { font-family: 'JetBrains Mono', monospace; font-weight: 500; }
.td-vol, .td-mcap { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-2); }

/* Pct badge */
.pct {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 9px; border-radius: 6px;
  min-width: 76px; justify-content: flex-end;
  letter-spacing: -.2px;
}
.pct.pos { color: var(--green); background: var(--green-dim); }
.pct.neg { color: var(--red);   background: var(--red-dim);   }
.pct.neu { color: var(--text-2); background: var(--surface3); }

/* Sparklines */
.sparkline { width: 100px; height: 32px; display: block; margin-left: auto; }
.sparkline path { fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark-empty { display: block; width: 100px; text-align: right; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.eod-note {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-3);
}
.eod-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-3); opacity: .5; flex-shrink: 0;
}

/* Pagination */
.pagination { display: flex; align-items: center; gap: 5px; }
.page-btn {
  padding: 4px 11px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: none; color: var(--text-2);
  font-size: 12px; font-weight: 500;
  transition: all .15s;
}
.page-btn:hover:not(:disabled) { color: var(--text); background: var(--surface2); }
.page-btn:disabled { opacity: .28; cursor: default; }
.page-btn.active { background: var(--blue-dim); border-color: var(--blue-border); color: var(--blue); }

/* Loading */
.loading-cell { padding: 56px !important; text-align: center; color: var(--text-3); }

/* ── CHART VIEW ──────────────────────────────────────────────── */
/* Outer wrapper: flex column so header and scroll area share the viewport height */
#chart-view {
  display: flex;
  flex-direction: column;
  margin-top: -12px;               /* align detail header with the fixed sidebar top */
  height: calc(100svh - 20px);      /* match sidebar top/bottom inset */
  max-height: calc(100svh - 20px);
  overflow: hidden;                /* only .chart-scroll scrolls */
  overscroll-behavior: contain;
}

/* Header pill: plain flex item — never scrolls, never de-sticks */
.chart-head {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;          /* above .chart-scroll and its backdrop-filter children */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: -22px;  /* card top sits at ~midpoint of header pill */
  background: var(--glass-card);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Scroll area: fills remaining height, clips iframes at its own top edge */
.chart-scroll {
  flex: 1;
  min-height: 0;                  /* required: lets flex child shrink below content size */
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 30px;              /* gap between cut and card top edge */
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* Glass card: TV chart + info panel live here */
.chart-card {
  background: var(--glass-card);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* Left / right side groups */
.chart-head-side {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-head-right { justify-content: flex-end; }

.back-btn {
  display: flex; align-items: center; gap: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-2);
  font-size: 12px; font-weight: 600;
  padding: 7px 12px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.back-btn:hover { color: var(--text); background: var(--surface3); }
.back-btn svg { width: 14px; height: 14px; }

/* ── CHART NAV: Apple-style — no border wrapper, ghost arrows ── */
.chart-nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

/* Ghost icon buttons for prev / next */
.chart-nav-step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-3);
  transition: background .15s, color .15s;
  cursor: pointer;
}
.chart-nav-step:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text-2);
}
.chart-nav-step:disabled { opacity: .22; cursor: default; }
.chart-nav-step svg { width: 14px; height: 14px; pointer-events: none; }

/* Stock identity: NVDA · NVIDIA Corp. — clickable to open picker */
.chart-identity-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  background: none;
  border: none;
  border-radius: 10px;
  color: inherit;
  cursor: pointer;
  min-width: 0;
  white-space: nowrap;
  transition: background .15s;
}
.chart-identity-btn:hover { background: var(--surface2); }

.chart-ticker {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
}
.chart-name-sep {
  color: var(--text-3);
  font-size: 14px;
  font-weight: 300;
  flex-shrink: 0;
  line-height: 1;
}
.chart-fullname {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ── STAR / WATCHLIST BUTTON ─────────────────────────────────── */
.chart-star-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: none; border: none; border-radius: 8px;
  color: var(--text-3);
  cursor: pointer; flex-shrink: 0;
  margin-left: 4px;  /* small gap after the nav arrows */
  transition: color .15s, background .15s;
}
.chart-star-btn:hover { background: var(--surface2); color: var(--text-2); }
.chart-star-btn svg { width: 17px; height: 17px; pointer-events: none; transition: fill .15s, stroke .15s; }
.chart-star-btn.starred { color: var(--amber); }
.chart-star-btn.starred svg { fill: var(--amber); stroke: var(--amber); }
.chart-star-btn.starred:hover { color: var(--amber); }

/* Sidebar: Google profile avatar image */
.profile-avatar-img {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}

/* ── AUTH MODAL ──────────────────────────────────────────────── */
.auth-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 900;
}
.auth-modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 901;
  width: min(360px, calc(100vw - 32px));
  background: var(--glass-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 32px 36px;
  text-align: center;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-lg);
}
html[data-theme="light"] .auth-modal {
  background: rgba(255,255,255,.92);
}
.auth-modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: none; border: none;
  color: var(--text-3); border-radius: 6px;
  cursor: pointer; transition: color .15s, background .15s;
}
.auth-modal-close:hover { color: var(--text); background: var(--surface2); }
.auth-modal-close svg { width: 12px; height: 12px; }
.auth-modal-icon {
  margin-bottom: 16px;
  color: var(--amber);
}
.auth-modal-icon svg { width: 40px; height: 40px; stroke: var(--amber); }
.auth-modal-title {
  font-size: 18px; font-weight: 700;
  color: var(--text); margin-bottom: 10px;
}
.auth-modal-body {
  font-size: 13px; color: var(--text-2);
  line-height: 1.6; margin-bottom: 28px;
}
#google-signin-btn { display: flex; justify-content: center; min-height: 44px; }

.google-signin-custom {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  border-radius: 6px;
  border: 1px solid #dadce0;
  background: #fff;
  color: #3c4043;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Google Sans', 'Inter', sans-serif;
  letter-spacing: .25px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.google-signin-custom:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(0,0,0,.14);
}

/* ── Share button (chart header) ────────────────────────────── */
.chart-share-trigger {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.chart-share-trigger:hover {
  background: var(--surface2);
  border-color: var(--border-strong);
  color: var(--text);
}
.chart-share-trigger svg { width: 16px; height: 16px; pointer-events: none; }

/* ── Share modal ─────────────────────────────────────────────── */
.share-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
}
.share-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 501;
  width: min(640px, calc(100vw - 32px));
  background: var(--glass-sidebar);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.45);
}
.share-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.share-modal-title {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.share-modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px; border: none;
  background: transparent; color: var(--text-3);
  cursor: pointer; transition: background .15s, color .15s;
}
.share-modal-close:hover { background: var(--surface2); color: var(--text); }
.share-modal-close svg { width: 12px; height: 12px; }

/* Canvas preview */
.share-canvas-wrap {
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
  line-height: 0;
  border: 1px solid var(--border);
}
#share-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Action buttons row */
.share-actions {
  display: flex; gap: 8px;
}
.share-action-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.share-btn-x {
  background: #000; color: #fff; border: 1px solid #333;
}
.share-btn-x:hover { background: #1a1a1a; }
html[data-theme="light"] .share-btn-x { background: #111; border-color: #222; }
.share-btn-img,
.share-btn-link {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
}
.share-btn-img:hover,
.share-btn-link:hover { background: var(--surface3); border-color: var(--border-strong); }

@media (max-width: 480px) {
  .share-actions { flex-direction: column; }
  .share-action-btn { flex: none; }
}

/* Chart mode is a primary view switch, separate from contextual settings. */
.chart-mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
}
.chart-mode-btn {
  min-width: 60px;
  height: 28px;
  padding: 0 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.chart-mode-btn:hover { color: var(--text); }
.chart-mode-btn.active {
  background: var(--surface3);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Chart settings side panel */
.chart-menu-wrap {
  position: relative;
  flex-shrink: 0;
}
.chart-menu-trigger {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.chart-menu-trigger:hover {
  background: var(--surface2);
  border-color: var(--border-strong);
  color: var(--text);
}
.chart-menu-trigger svg { width: 16px; height: 16px; pointer-events: none; }

.chart-settings-panel {
  flex: 0 0 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgba(11, 13, 20, 0.45);
  backdrop-filter: blur(36px) saturate(180%);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: chartSettingsIn .2s cubic-bezier(.2,.8,.2,1);
}
.chart-settings-panel[hidden] { display: none !important; }
html[data-theme="light"] .chart-settings-panel {
  background: rgba(255, 255, 255, 0.45);
}
@keyframes chartSettingsIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
.chart-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chart-settings-eyebrow {
  margin: 0 0 2px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.chart-settings-header h2 { margin: 0; color: var(--text); font-size: 16px; line-height: 1.2; }
.chart-settings-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-2);
}
.chart-settings-close:hover { color: var(--text); background: var(--surface3); }
.chart-settings-close svg { width: 15px; height: 15px; }
.chart-settings-body {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.chart-menu-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3);
  padding: 6px 10px 4px;
  margin: 0;
}
.chart-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: none; background: none;
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
  text-align: left;
  transition: background .12s, color .12s;
}
.chart-menu-item:hover { background: rgba(255,255,255,.055); color: var(--text); }
html[data-theme="light"] .chart-menu-item:hover { background: rgba(0,0,0,.04); }
.chart-menu-item.active { color: var(--blue); }
.chart-menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.chart-menu-select {
  width: calc(100% - 12px);
  margin: 2px 6px 5px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.chart-menu-select:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.chart-menu-checkgrid {
  display: grid;
  gap: 2px;
  padding: 2px 8px 5px;
}
.chart-menu-checkgrid label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}
.chart-menu-checkgrid input { accent-color: var(--blue); }
.chart-menu-sublabel {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.chart-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}
/* Chart + settings inspector: the inspector narrows the chart instead of covering it. */
.chart-main-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  min-width: 0;
  height: calc(100vh - 180px);
  min-height: 480px;
  max-height: 900px;
}

/* Chart + info: vertical stack */
.tv-chart-shell {
  flex: 1 1 auto;
  min-width: 0;
  /* Explicit pixel height so TradingView autosize can measure the container */
  position: relative;           /* needed so absolute children fill this box */
  height: auto;
  min-height: 0;
  max-height: none;
  border: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgb(12,15,26);
  transition: background .25s;
}
html[data-theme="light"] .tv-chart-shell {
  background: rgb(242,243,248);
}
.tv-placeholder {
  height: 100%;
  min-height: 0;
  display: grid; place-items: center;
  color: var(--text-3); padding: 20px; text-align: center;
}
.tv-widget-host {
  position: absolute; inset: 0;   /* fills .tv-chart-shell */
}

/* ── Preload pool: stacked iframes, only .tv-active is visible ── */
.tv-iframe-wrapper {
  /* TradingView draws a one-pixel frame inside its cross-origin iframe. */
  position: absolute; inset: -1px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
.tv-iframe-wrapper.tv-active {
  opacity: 1;
  pointer-events: auto;
}
.tv-iframe-wrapper iframe {
  width: 100%; height: 100%;
  border: none; display: block;
}
/* Info panel — below chart */
.info-panel {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--glass-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}

/* Tab bar */
.info-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.info-tab {
  flex: 1;
  height: 38px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font-size: 12px; font-weight: 600;
  transition: color .15s, border-color .15s;
}
.info-tab:hover { color: var(--text); }
.info-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Tab panes */
.info-content { overflow: hidden; }
.info-pane { display: none; }
.info-pane.active { display: block; }

/* Widget sizes */
.profile-widget,
.news-widget,
.technical-widget {
  height: 500px;
  background: rgb(12,15,26);
  color-scheme: dark;
}
html[data-theme="light"] .profile-widget,
html[data-theme="light"] .news-widget,
html[data-theme="light"] .technical-widget {
  background: #fff;
  color-scheme: light;
}
/* Give the cross-origin iframe its final color before TradingView renders. */
.profile-widget .tradingview-widget-container,
.news-widget .tradingview-widget-container,
.technical-widget .tradingview-widget-container { height: 100%; width: 100%; background: inherit; }
.profile-widget .tradingview-widget-container__widget,
.news-widget .tradingview-widget-container__widget,
.technical-widget .tradingview-widget-container__widget,
.profile-widget iframe,
.news-widget iframe,
.technical-widget iframe { background: inherit; }

.stock-profile-card {
  padding: 24px 28px 22px;
  color: var(--text);
}
.stock-profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stock-profile-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
  flex-shrink: 0;
}
.stock-profile-title {
  flex: 1;
  min-width: 0;
}
.stock-profile-kicker {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.stock-profile-title h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
  font-weight: 750;
}
.stock-profile-title h3 span {
  color: var(--text-2);
  font-weight: 650;
}
.stock-profile-score {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--blue-dim);
  border: 1px solid var(--blue-border);
  font-weight: 800;
}
.stock-profile-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 22px;
}
.stock-profile-price strong {
  font-size: 34px;
  line-height: 1;
  font-weight: 760;
}
.stock-profile-price > span:last-child {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 650;
}
.stock-profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
}
.stock-profile-metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.026);
  padding: 12px;
  min-width: 0;
}
html[data-theme="light"] .stock-profile-metric {
  background: rgba(255,255,255,.52);
}
.stock-profile-metric span,
.stock-profile-label {
  display: block;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}
.stock-profile-metric strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 15px;
  font-weight: 720;
  overflow-wrap: anywhere;
}
.stock-profile-section {
  margin-top: 22px;
}
.stock-profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.narrative-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--blue-dim);
  border: 1px solid var(--blue-border);
  color: var(--blue);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.stock-profile-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  margin-top: 24px;
  padding-top: 14px;
  color: var(--text-3);
  font-size: 12px;
}
.stock-profile-footer a {
  color: var(--blue);
  font-weight: 650;
}


/* ── STOCK PICKER BOTTOM SHEET ───────────────────────────────── */

/* [hidden] override: ensures display:none wins when attribute is set */
.stock-picker-backdrop[hidden],
.stock-picker[hidden] { display: none !important; }

.stock-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 499;
}
.stock-picker {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 500;
  width: min(100%, 480px);
  max-height: 68vh;
  display: flex;
  flex-direction: column;
  background: rgba(11, 13, 20, 0.45);
  backdrop-filter: blur(36px) saturate(180%);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: sheetUp .26s cubic-bezier(.4,0,.2,1);
}
@keyframes sheetUp {
  from { transform: translateX(-50%) translateY(100%); }
  to   { transform: translateX(-50%) translateY(0); }
}

.stock-picker-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 10px auto 0;
  flex-shrink: 0;
}

.stock-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.stock-picker-title {
  font-size: 13px; font-weight: 600;
  color: var(--text);
}
.stock-picker-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--text-2);
  transition: background .15s;
}
.stock-picker-close:hover { background: var(--surface3); }
.stock-picker-close svg { width: 13px; height: 13px; }

.stock-picker-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding: 6px;
  scrollbar-width: thin;
}

/* Stock picker row */
.stock-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.stock-picker-item:hover { background: rgba(255,255,255,.055); }
html[data-theme="light"] .stock-picker-item:hover { background: rgba(0,0,0,.04); }
html[data-theme="light"] .stock-picker {
  background: rgba(255, 255, 255, 0.45);
}
.stock-picker-item.active {
  background: var(--blue-dim);
  border: 1px solid var(--blue-border);
}

.picker-logo {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -.5px;
}
.picker-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.picker-ticker {
  font-size: 13px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -.2px;
  color: var(--text);
}
.picker-name {
  font-size: 11px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}

/* List-trigger button in stock-nav */

/* ── MOBILE BOTTOM BAR ───────────────────────────────────────── */
.mobile-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 150;
  background: var(--glass-sidebar);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border-top: 1px solid var(--border);
  padding: 8px 0 max(env(safe-area-inset-bottom), 8px);
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.mobile-tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 0;
  border: none; background: none;
  color: var(--text-3); font-size: 10px; font-weight: 500;
  transition: color .15s;
}
.mobile-tab svg { width: 22px; height: 22px; }
.mobile-tab.active { color: var(--blue); }
.mobile-tab-login.signed-in { color: var(--green); }
.mobile-tab-login .mobile-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */

/* Medium: tighten cells when full sidebar leaves less room — keep all columns */
@media (max-width: 960px) {
  td { padding: 10px 6px; }
  th { padding: 7px 6px; }
  .td-star { padding-left: 10px; padding-right: 2px; width: 36px; }
  .pct { min-width: 52px; font-size: 10.5px; padding: 3px 6px; }
  .sname { max-width: 140px; }
}

/* Mobile: no sidebar, bottom nav replaces it */
@media (max-width: 680px) {
  :root { --sidebar-w: 0px; }

  /* Sidebar completely hidden on mobile — bottom nav handles navigation */
  .sidebar { display: none; }
  .sidebar-overlay { display: none !important; }
  .hamburger { display: none; }

  .app-shell { margin-left: 0; }
  .topbar { display: grid; }
  .mobile-bar { display: grid; }
  .page {
    height: auto;
    min-height: calc(100svh - var(--topbar-h));
    padding: 10px 10px 88px;
  }
  .search-box { max-width: 100%; }

  /* Show search icon inside the screener card on mobile */
  .card-search-btn { display: flex; }

  /* ── Screener table — hide non-essential columns on mobile ── */
  .col-vol,
  .col-mcap { display: none; }
  thead th:last-child,
  tbody td:last-child { display: none; }   /* sparkline */

  /* Fix horizontal overflow */
  table { min-width: 100%; }

  /* Hide exchange badge — saves horizontal space */
  .sexch { display: none; }

  /* Trim company name */
  .sname { max-width: 110px; font-size: 10.5px; }

  /* Better touch targets */
  td { padding: 11px 10px; font-size: 12.5px; }
  th { padding: 8px 10px; font-size: 10px; }

  /* Tighter star column */
  .td-star { width: 36px; padding-left: 10px; padding-right: 4px; }

  /* Smaller logo avatar */
  .slogo { width: 30px; height: 30px; font-size: 9.5px; }

  /* Tighter stock cell gap */
  .stock-cell { gap: 8px; }

  /* Ticker slightly smaller */
  .sticker { font-size: 12.5px; }

  /* Shrink pct badge so it doesn't eat the whole column */
  .pct { min-width: 60px; font-size: 10.5px; padding: 3px 7px; }

  /* Card topbar: stack result count and timeframe pills */
  .card-topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .tf-btn { padding: 4px 8px; font-size: 10.5px; }

  /* table-scroll: fill remaining vertical space */
  .table-scroll {
    max-height: calc(100svh - var(--topbar-h) - 100px);
    overflow-x: hidden;
  }

  /* Index tabs: scrollable row, no wrap */
  .index-tabs {
    padding: 0 2px 4px;
    gap: 6px;
  }

  /* ── Chart view mobile ── */
  #chart-view {
    margin-top: 0;
    height: calc(100svh - var(--topbar-h) - 14px);
    max-height: calc(100svh - var(--topbar-h) - 14px);
  }
  .chart-card { padding: 10px; }
  .chart-head { gap: 6px; margin-bottom: 6px; }
  .back-btn span { display: none; } /* icon only */
  .back-btn { padding: 7px 9px; }
  .chart-nav-step { width: 28px; height: 28px; }
  .chart-identity-btn { padding: 5px 8px; gap: 6px; }
  .chart-mode-btn { min-width: 28px; width: 28px; padding: 0; font-size: 0; }
  .chart-mode-btn::after { content: attr(data-short); font-size: 11px; }

  /* Ticker + fullname: scale down */
  .chart-ticker { font-size: 13px; }
  .chart-name-sep { display: none; }
  .chart-fullname { display: none; }

  /* Chart shell and settings panel remain equally tall on mobile. */
  .chart-main-row {
    gap: 8px;
    height: calc(100svh - var(--topbar-h) - 195px);
    min-height: 300px;
    max-height: none;
  }
  .chart-settings-panel { flex-basis: min(240px, 46vw); }

  /* Info panel: shorter on mobile */
  .profile-widget, .news-widget, .technical-widget { height: 360px; }
}

/* ── Watchlist empty state ──────────────────────────────────── */
.watchlist-empty {
  padding: 48px 20px !important;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
  line-height: 2;
}
.btn-signin-inline {
  margin-top: 10px;
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--blue-dim);
  color: var(--blue);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-signin-inline:hover { background: rgba(59,126,255,.22); }
