/* ============================================================
   Company Stock Price — design tokens, shell, components, responsive
   Breakpoints:  mobile <640  |  tablet 640–1023  |  desktop ≥1024
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Manrope:wght@400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&family=Syne:wght@400;500;600;700;800&family=DM+Serif+Display:ital@0;1&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --nav-bg: #ffffff;
  --nav-text: #475569;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-text: #1d4ed8;
  --card-shadow: rgba(0,0,0,0.06);

  --up: #16a34a;
  --up-bg: #dcfce7;
  --down: #dc2626;
  --down-bg: #fee2e2;

  /* sector colors */
  --sec-it: #14b8a6;
  --sec-bank: #2563eb;
  --sec-energy: #f59e0b;
  --sec-fmcg: #16a34a;
  --sec-auto: #8b5cf6;
  --sec-pharma: #ec4899;
  --sec-metal: #64748b;

  /* news categories */
  --cat-markets: #2563eb;
  --cat-earnings: #16a34a;
  --cat-ipo: #8b5cf6;
  --cat-economy: #f59e0b;
  --cat-sector: #14b8a6;
  --cat-global: #64748b;

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius: 12px;
  --sidebar-w: 240px;
  --rail-w: 64px;
  --topbar-h: 56px;
  --ticker-h: 36px;
  --maxw: 1440px;

  /* tweakable */
  --tw-accent: #2563eb;
  --tw-radius: 12px;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #162032;
  --border: #334155;
  --border-strong: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --nav-bg: #0b1424;
  --nav-text: #94a3b8;
  --accent: #3b82f6;
  --accent-soft: #172554;
  --accent-text: #93c5fd;
  --card-shadow: rgba(0,0,0,0.4);

  --up-bg: #052e16;
  --down-bg: #450a0a;
}

* {
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }

/* scrollbars */
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== TYPOGRAPHY ===================== */
.h1 { font-family: var(--font-body); font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
.h2 { font-family: var(--font-body); font-size: 20px; font-weight: 600; margin: 0; }
.h3 { font-family: var(--font-body); font-size: 16px; font-weight: 500; margin: 0; }
.body { font-size: 14px; font-weight: 400; }
.muted { font-size: 12px; color: var(--text-muted); letter-spacing: 0.03em; }
.label-up { text-transform: uppercase; font-size: 11px; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.display { font-family: var(--font-display); color: var(--text-primary); }
.price-big { font-family: var(--font-display); font-size: 32px; color: var(--text-primary); line-height: 1; }
.mono { font-family: var(--font-mono); }
.ticker { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.up { color: var(--up); }
.down { color: var(--down); }

/* ===================== APP SHELL ===================== */
.app { min-height: 100vh; }
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
}

/* ---- Ticker marquee ---- */
.ticker-bar {
  position: sticky; top: 0; z-index: 50;
  height: var(--ticker-h);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; overflow: hidden;
}
.ticker-track {
  display: flex; align-items: stretch;
  white-space: nowrap; flex-shrink: 0;
  animation: ticker-scroll 80s linear infinite;
  will-change: transform;
}
.ticker-bar:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 16px; height: var(--ticker-h);
  border: none; background: transparent; cursor: pointer;
  border-right: 1px solid var(--border);
  font-size: 12px; flex-shrink: 0;
}
.ticker-item:hover { background: var(--bg-tertiary); }
.ti-sym { font-family: var(--font-mono); font-weight: 600; color: var(--text-secondary); letter-spacing: 0.02em; }
.ti-price { font-family: var(--font-mono); color: var(--text-primary); }
.ti-chg { font-family: var(--font-mono); font-weight: 600; font-size: 11px; display: inline-flex; align-items: center; gap: 2px; }
.ti-chg.up { color: var(--up); }
.ti-chg.down { color: var(--down); }

/* ---- Sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--nav-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--ticker-h);
  height: calc(100vh - var(--ticker-h));
  overflow-y: auto;
  z-index: 40;
}
.sidebar-brand,
.brand-home {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: background 150ms ease;
  border-top: none;
  border-left: none;
  border-right: none;
}
.brand-mobile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
}
.brand-home:hover,
.brand-mobile:hover { background: var(--bg-secondary); }
.brand-mobile {
  width: auto;
  border-bottom: none;
  padding: 0;
  height: auto;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #0f172a));
  display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.brand-mark-text { font-size: 10px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.brand-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: 800; font-size: 14px; letter-spacing: -0.02em; white-space: nowrap; }
.brand-name .brand-accent { color: var(--accent); }
.brand-domain { font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.01em; }
.brand-word { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-word .pulse { color: var(--accent); }
.sidebar-nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 16px;
  border-radius: 8px;
  color: var(--nav-text);
  font-weight: 500; font-size: 14px;
  border: none; background: transparent;
  width: 100%; text-align: left;
  border-left: 3px solid transparent;
  transition: background 150ms ease, color 150ms ease;
  position: relative;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-left: 3px solid var(--accent);
  font-weight: 600;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item .nav-label { white-space: nowrap; overflow: hidden; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); }

/* tooltip for rail */
.nav-item .tip { display: none; }

/* ---- Topbar ---- */
.topbar {
  grid-area: topbar;
  height: var(--topbar-h);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  gap: 14px; padding: 0 20px;
  position: sticky; top: var(--ticker-h); z-index: 35;
}
.topbar .hamburger,
.topbar .brand-mobile { display: none; }
.search-bar {
  flex: 1; max-width: 480px;
  display: flex; align-items: center; gap: 9px;
  height: 38px; padding: 0 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-muted);
}
.search-bar:hover { border-color: var(--border-strong); }
.search-bar input {
  border: none; background: transparent; outline: none;
  flex: 1; font-family: var(--font-body); font-size: 14px; color: var(--text-primary);
}
.search-bar .kbd {
  font-family: var(--font-mono); font-size: 11px;
  border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 6px; color: var(--text-muted); background: var(--bg-primary);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 9px;
  display: grid; place-items: center;
  border: none; background: transparent; color: var(--text-secondary);
  position: relative;
}
.icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.icon-btn svg { width: 20px; height: 20px; }
.notif-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--down); border: 2px solid var(--bg-primary);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; margin-left: 4px;
}

/* ---- Main ---- */
.main {
  grid-area: main;
  overflow-x: hidden;
}
.main-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px;
}
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  color: var(--text-muted); font-size: 12px;
}
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a,
.footer-links button { color: inherit; background: none; border: none; padding: 0; font: inherit; cursor: pointer; text-decoration: none; }
.footer-links a:hover,
.footer-links button:hover { color: var(--text-primary); }

/* ---- Legal pages ---- */
.legal-page { max-width: 720px; }
.legal-brand-row { display: flex; align-items: center; gap: 14px; }
.legal-prose { display: flex; flex-direction: column; gap: 22px; }
.legal-section h2 { margin: 0 0 8px; }
.legal-section p { margin: 0; font-size: 14px; line-height: 1.65; color: var(--text-secondary); }
.legal-foot { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.6; }
.legal-inline-link { color: var(--accent); font-weight: 600; background: none; border: none; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }

/* ---- Mobile bottom nav + drawer ---- */
.bottom-nav { display: none; }
.drawer-scrim { display: none; }

/* ===================== INDEX STRIP ===================== */
.index-strip {
  display: flex; gap: 10px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.index-strip::-webkit-scrollbar { display: none; }
.index-tile {
  min-width: 132px; height: 52px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-primary);
  padding: 7px 12px; flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  font: inherit; color: inherit; text-align: left;
  cursor: default; transition: border-color 150ms ease, box-shadow 150ms ease;
}
button.index-tile { cursor: pointer; }
button.index-tile:hover { border-color: var(--border-strong); box-shadow: 0 2px 8px var(--card-shadow); }
.index-tile.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.index-tile .it-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.index-tile .it-row { display: flex; align-items: baseline; gap: 8px; }
.index-tile .it-val { font-family: var(--font-display); font-size: 15px; color: var(--text-primary); }
.index-tile .it-chg { font-family: var(--font-mono); font-size: 11px; font-weight: 500; }

/* ===================== CARDS ===================== */
.card {
  border: 1px solid var(--border);
  border-radius: var(--tw-radius);
  background: var(--bg-primary);
  padding: 16px 20px;
  transition: box-shadow 150ms ease, border-color 150ms ease, background-color 0.2s ease;
}
.card.hoverable:hover {
  box-shadow: 0 4px 12px var(--card-shadow);
  border-color: var(--border-strong);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.link-btn:hover { gap: 7px; }

/* change chip */
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
  padding: 3px 8px; border-radius: 7px; white-space: nowrap;
}
.chip.up { background: var(--up-bg); color: var(--up); }
.chip.down { background: var(--down-bg); color: var(--down); }
.chip.sm { font-size: 11px; padding: 2px 6px; border-radius: 6px; }

/* stock quote card */
.quote-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-primary);
}
.quote-card.hoverable:hover { box-shadow: 0 4px 12px var(--card-shadow); border-color: var(--border-strong); }
.qc-left { min-width: 0; }
.qc-name {
  font-size: 14px; font-weight: 500; color: var(--text-primary);
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.qc-ticker { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.qc-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.qc-price { font-family: var(--font-display); font-size: 20px; color: var(--text-primary); line-height: 1; }

/* avatar circle for stocks */
.stock-ava {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  color: #fff; font-weight: 700; font-size: 12px; font-family: var(--font-body);
}

/* metric card */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-card {
  border: 1px solid var(--border); border-radius: var(--tw-radius);
  background: var(--bg-primary); overflow: hidden;
}
.metric-band { height: 8px; width: 100%; }
.metric-body { padding: 14px 16px; }
.metric-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.03em; text-transform: uppercase; font-weight: 600; }
.metric-val { font-family: var(--font-display); font-size: 22px; color: var(--text-primary); margin: 4px 0 2px; line-height: 1.1; }
.metric-sub { font-size: 11px; color: var(--text-muted); }

/* ===================== NEWS ===================== */
.cat-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 999px; color: #fff;
}
.source-badge {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  display: inline-flex; align-items: center; gap: 5px;
}
.source-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* featured */
.news-featured { border: 1px solid var(--border); border-radius: var(--tw-radius); overflow: hidden; background: var(--bg-primary); }
.news-featured:hover { box-shadow: 0 4px 12px var(--card-shadow); }
.news-featured .nf-img { width: 100%; height: 220px; object-fit: cover; display: block; }
.news-featured .nf-body { padding: 16px 20px 18px; }
.news-featured .nf-head { font-family: var(--font-display); font-style: italic; font-size: 24px; line-height: 1.2; color: var(--text-primary); margin: 10px 0 8px; }
.news-featured .nf-sum { font-size: 13px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nf-meta { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.sentiment { margin-left: auto; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.sentiment.bull { background: var(--up-bg); color: var(--up); }
.sentiment.bear { background: var(--down-bg); color: var(--down); }

/* standard news card */
.news-std {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: var(--tw-radius);
  background: var(--bg-primary); padding: 14px;
}
.news-std:hover { box-shadow: 0 4px 12px var(--card-shadow); border-color: var(--border-strong); }
.news-std .ns-img { width: 80px; height: 64px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.news-std .ns-head { font-size: 14px; font-weight: 500; color: var(--text-primary); margin: 5px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.news-std:hover .ns-head { color: var(--accent); }
.news-std .ns-time { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* compact row */
.news-compact { display: flex; flex-direction: column; }
.news-compact .nc-row {
  display: flex; align-items: center; gap: 10px;
  min-height: 38px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.news-compact .nc-row:last-child { border-bottom: none; }
.nc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.nc-head { font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.news-compact .nc-row:hover .nc-head { color: var(--accent); }
.nc-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* ===================== TABLE / SCREENER ===================== */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pill-row { display: flex; gap: 7px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--border); background: var(--bg-primary);
  color: var(--text-secondary); font-weight: 500; font-size: 13px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center;
}
.pill:hover { border-color: var(--border-strong); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.screener-search {
  width: 240px; height: 38px;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--bg-primary);
  color: var(--text-muted);
}
.screener-search input { border: none; background: transparent; outline: none; flex: 1; font-family: var(--font-body); font-size: 14px; color: var(--text-primary); }
.select {
  height: 38px; padding: 0 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-primary);
  color: var(--text-primary); font-family: var(--font-body); font-size: 14px;
}

.table-wrap { border: 1px solid var(--border); border-radius: var(--tw-radius); overflow: auto; background: var(--bg-primary); }
table.screener { width: 100%; border-collapse: collapse; min-width: 880px; }
table.screener thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-primary);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600;
  text-align: right; padding: 12px 16px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
table.screener thead th.sortable { cursor: pointer; }
table.screener thead th.sortable:hover { color: var(--text-primary); }
table.screener th.col-rank, table.screener td.col-rank { text-align: center; width: 52px; }
table.screener th.col-company, table.screener td.col-company { text-align: left; }
table.screener th.col-company, table.screener td.col-company {
  position: sticky; left: 0; z-index: 1; background: var(--bg-primary);
  min-width: 200px; max-width: 280px;
}
table.screener thead th.col-company { z-index: 3; }
table.screener tbody td {
  padding: 0 16px; height: 48px; text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-primary); white-space: nowrap;
}
table.screener tbody tr:last-child td { border-bottom: none; }
table.screener tbody tr:hover td { background: var(--bg-secondary); }
table.screener tbody tr:hover td.col-company { background: var(--bg-secondary); }
td.col-company .cc { display: flex; align-items: center; gap: 10px; }
td.col-company .cc-name {
  font-weight: 500;
  white-space: normal;
  line-height: 1.35;
  font-size: 13px;
}
table.screener tbody td.col-company { white-space: normal; vertical-align: middle; }
td.col-company .cc-ticker { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
td .mono-num { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.sort-ind { font-size: 10px; margin-left: 3px; opacity: 0.9; }
.row-action {
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg-primary);
  color: var(--accent); font-weight: 600; font-size: 12px; height: 30px; padding: 0 12px;
}
.row-action:hover { background: var(--accent-soft); }

/* mobile stock card list */
.stock-card-list { display: none; flex-direction: column; gap: 10px; }
.stock-card {
  border: 1px solid var(--border); border-radius: var(--tw-radius);
  background: var(--bg-primary); padding: 14px;
}
.sc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sc-id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sc-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.sc-stat .k { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sc-stat .v { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-primary); margin-top: 2px; }

/* ===================== STOCK DETAIL ===================== */
.detail-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.detail-price { display: flex; align-items: baseline; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.time-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.time-tab {
  background: transparent; border: none; padding: 6px 10px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; border-radius: 0;
}
.time-tab:hover { color: var(--text-primary); }
.time-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.kv-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.kv {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px;
}
.kv .k { font-size: 12px; color: var(--text-muted); }
.kv .v { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-primary); }

/* chart bits */
.chart-tip {
  position: absolute; pointer-events: none;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12px;
  box-shadow: 0 4px 12px var(--card-shadow); z-index: 5; white-space: nowrap;
}
.chart-tip .ct-date { color: var(--text-muted); font-size: 11px; }
.chart-tip .ct-val { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }

/* empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 80px 20px; gap: 12px; color: var(--text-muted);
}
.empty-state .es-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--bg-tertiary); display: grid; place-items: center; color: var(--text-secondary); }

/* search overlay (mobile) */
.search-overlay {
  position: fixed; inset: 0; z-index: 60; background: var(--bg-primary);
  display: flex; flex-direction: column;
}
.search-overlay-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-overlay-head input { flex: 1; border: none; background: transparent; outline: none; font-family: var(--font-body); font-size: 16px; color: var(--text-primary); }
.recent-list { padding: 14px; }
.recent-row { display: flex; align-items: center; gap: 12px; height: 48px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.news-feed-layout,
.news-layout { display: grid; grid-template-columns: 65fr 35fr; gap: 20px; align-items: start; }
.trending-strip { display: none; }

/* ============================================================
   TABLET  640–1023  → icon rail sidebar
   ============================================================ */
@media (max-width: 1023px) {
  .shell { grid-template-columns: var(--rail-w) 1fr; }
  .sidebar { --collapsed: 1; }
  .sidebar .brand-stack { display: none; }
  .sidebar-brand { justify-content: center; padding: 0; }
  .nav-item { padding: 0; justify-content: center; border-left-width: 0; }
  .nav-item.active { border-left-width: 0; border-radius: 8px; }
  .nav-item .nav-label { display: none; }
  .nav-item:hover .tip {
    display: block; position: absolute; left: calc(100% + 8px); top: 50%;
    transform: translateY(-50%); background: var(--text-primary); color: var(--bg-primary);
    padding: 5px 9px; border-radius: 6px; font-size: 12px; white-space: nowrap; z-index: 50;
    box-shadow: 0 4px 12px var(--card-shadow);
  }
  .sidebar-foot { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .news-feed-layout,
  .news-layout { grid-template-columns: 1fr; }
  .idx-grid { grid-template-columns: repeat(2, 1fr); }
  .ipo-grid { grid-template-columns: repeat(2, 1fr); }
  .main-inner { padding: 16px; }
  .sk-grid-2-1 { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBILE  <640  → bottom nav, no sidebar, drawer
   ============================================================ */
@media (max-width: 639px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar { display: none; }

  /* drawer mode */
  .sidebar.drawer-open {
    display: flex; position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px; z-index: 70;
    --collapsed: 0;
  }
  .sidebar.drawer-open .brand-stack { display: flex; }
  .sidebar.drawer-open .sidebar-brand { justify-content: flex-start; padding: 0 16px; }
  .sidebar.drawer-open .nav-item { padding: 0 16px; justify-content: flex-start; border-left-width: 3px; }
  .sidebar.drawer-open .nav-item .nav-label { display: inline; }
  .sidebar.drawer-open .nav-item.active { border-left-width: 3px; }
  .sidebar.drawer-open .sidebar-foot { display: block; }
  .drawer-scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 65; }

  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .hamburger { display: grid; }
  .topbar .search-bar { display: none; }
  .topbar .brand-mobile {
    display: flex; align-items: center; gap: 8px;
    position: absolute; left: 50%; transform: translateX(-50%);
  }
  .topbar .search-trigger { display: grid; }
  .topbar-actions .notif-only { }

  .main { padding-bottom: 64px; }
  .main-inner { padding: 12px; }
  .footer { display: none; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-primary); border-top: 1px solid var(--border);
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; border: none; background: transparent; color: var(--text-muted);
    font-size: 10px; font-weight: 600; min-height: 44px;
  }
  .bn-item svg { width: 22px; height: 22px; }
  .bn-item.active { color: var(--accent); }

  .metric-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .idx-grid { grid-template-columns: 1fr; }
  .ipo-grid { grid-template-columns: 1fr; }
  .qb-row { gap: 6px; }
  .qb-row .select { min-width: 0; flex: 1 1 40%; }
  .qb-val { flex: 1 1 100%; }
  .table-wrap { display: none; }
  .stock-card-list { display: flex; }
  .filter-bar { position: sticky; top: calc(var(--ticker-h) + var(--topbar-h)); background: var(--bg-secondary); z-index: 20; padding: 8px 0; margin: 0 0 12px; }
  .filter-bar .pill-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filter-bar .pill-row::-webkit-scrollbar { display: none; }
  .screener-search { width: 100%; }
  .h1 { font-size: 22px; }
  .h2 { font-size: 17px; }
  .price-big { font-size: 26px; }

  /* trending strip on top */
  .news-side { display: none; }
  .trending-strip { display: block; }
}

/* ===================== DENSITY (tweak) ===================== */
[data-density="compact"] .card { padding: 11px 14px; }
[data-density="compact"] .quote-card { padding: 10px 12px; }
[data-density="compact"] .section { margin-bottom: 18px; }
[data-density="compact"] table.screener tbody td { height: 40px; }
[data-density="compact"] .main-inner { padding: 16px; }
[data-density="comfy"] .card { padding: 22px 26px; }
[data-density="comfy"] .quote-card { padding: 18px 20px; }
[data-density="comfy"] .section { margin-bottom: 36px; }
[data-density="comfy"] table.screener tbody td { height: 56px; }

/* ===================== LIVE / SETTINGS ===================== */
.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 6px;
  background: var(--bg-tertiary); color: var(--text-muted);
}
.live-badge.sm { font-size: 10px; padding: 2px 6px; }
.live-badge .lb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.live-badge.on { background: var(--up-bg); color: var(--up); }
.live-badge.on .lb-dot { background: var(--up); box-shadow: 0 0 0 0 var(--up); animation: pulse-dot 1.8s infinite; }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 60%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.live-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg-secondary);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.live-pill .lp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.live-pill.on { border-color: color-mix(in srgb, var(--up) 40%, var(--border)); color: var(--up); background: var(--up-bg); }
.live-pill.on .lp-dot { background: var(--up); }

.modal-scrim {
  position: fixed; inset: 0; z-index: 80; background: rgba(2,6,23,0.5);
  display: grid; place-items: center; padding: 20px;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
  width: 100%; max-width: 460px; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--bg-secondary); }
.key-input {
  flex: 1; height: 42px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-secondary);
  font-family: var(--font-mono); font-size: 13px; color: var(--text-primary); outline: none;
}
.key-input:focus { border-color: var(--accent); }
.live-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.switch { width: 46px; height: 26px; border-radius: 999px; border: none; background: var(--border-strong); position: relative; flex-shrink: 0; transition: background 0.18s ease; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.18s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch.on { background: var(--accent); }
.switch.on .knob { transform: translateX(20px); }
.modal-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 16px; padding: 12px; border-radius: 10px; background: var(--bg-secondary); color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.modal-note svg { flex-shrink: 0; margin-top: 1px; color: var(--text-muted); }

/* ===================== SHIMMER / SKELETON ===================== */
.shimmer {
  display: block;
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    color-mix(in srgb, var(--bg-secondary) 65%, var(--bg-primary)) 45%,
    var(--bg-tertiary) 90%
  );
  background-size: 200% 100%;
  animation: shimmer 1.35s ease-in-out infinite;
  flex-shrink: 0;
}
.shimmer-circle { flex-shrink: 0; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .shimmer { animation: none; opacity: 0.65; }
}

.sk-page { pointer-events: none; }
.sk-index-strip { gap: 10px; }
.sk-index-tile {
  flex: 0 0 148px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--tw-radius);
  background: var(--bg-primary);
}
.sk-grid-2-1 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
.sk-mover-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.sk-stat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.sk-stat-row:last-child { border-bottom: none; }
.sk-quote-card { padding: 14px 16px; }
.sk-idx-card { pointer-events: none; }
.sk-member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.sk-table th, .sk-table td { padding: 14px 16px; vertical-align: middle; }
.sk-news-featured { padding: 0; overflow: hidden; }
.sk-news-row { padding: 14px 16px; }
.sk-ipo-card { padding: 16px; }
.sk-ipo-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sk-ticker { overflow: hidden; }
.sk-ticker-item {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 0 20px; height: var(--ticker-h);
  border-right: 1px solid var(--border);
}
.skeleton { background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }

@media (max-width: 639px) {
  .modal-scrim { align-items: flex-end; padding: 0; }
  .modal-sheet { max-width: 100%; border-radius: 18px 18px 0 0; animation: sheet-up 0.22s ease; }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .live-pill .lp-text { display: none; }
}

/* ===================== IN-SITE NEWS ARTICLE ===================== */
.news-article-page { max-width: 820px; }
.news-article { overflow: hidden; padding: 0; }
.news-article-hero { border-radius: 0; width: 100%; }
.news-article-body { padding: 22px 24px 26px; }
.news-article-content p {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-primary);
}
.news-article-content p:last-child { margin-bottom: 0 !important; }
.news-article-lead {
  font-size: 18px !important;
  line-height: 1.6 !important;
  font-weight: 500;
  color: var(--text-secondary) !important;
  margin-bottom: 20px !important;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.news-row { cursor: pointer; }
.news-featured.card { cursor: pointer; }

/* ===================== USAGE GATE + ADMIN ===================== */
.app-gated { filter: blur(6px); pointer-events: none; user-select: none; }
.gate-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 20px;
  animation: fade-in 0.2s ease;
}
.gate-sheet {
  width: 100%; max-width: 420px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px 22px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}
.gate-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.gate-form { margin-top: 4px; }
.gate-input { width: 100%; margin-top: 6px; font-family: var(--font-body); }
.gate-submit { width: 100%; height: 44px; margin-top: 18px; font-size: 15px; font-weight: 600; }
.gate-err {
  margin-top: 12px; padding: 10px 12px; border-radius: 9px;
  background: var(--down-bg); color: var(--down); font-size: 13px;
}
.admin-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px; background: var(--bg-secondary);
}
.admin-card {
  width: 100%; max-width: 400px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
}
.admin-dash {
  display: block; max-width: 1100px; margin: 0 auto; width: 100%;
}
.admin-top {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.admin-table th, .admin-table td { font-size: 13px; }

/* ===================== SEGMENTED CONTROL ===================== */
.seg { display: inline-flex; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn { display: inline-flex; align-items: center; gap: 5px; border: none; background: transparent; color: var(--text-secondary); font-weight: 600; font-size: 13px; height: 34px; padding: 0 14px; border-radius: 7px; }
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.on { background: var(--bg-primary); color: var(--accent); box-shadow: 0 1px 3px var(--card-shadow); }

/* ===================== QUERY BUILDER ===================== */
.qb-count { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 8px; }
.qb-empty { padding: 16px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--text-muted); font-size: 13px; text-align: center; }
.qb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qb-join { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-muted); width: 52px; flex-shrink: 0; letter-spacing: 0.04em; }
.qb-row .select { flex: 1; min-width: 130px; }
.qb-row .qb-op { flex: 0 0 64px; min-width: 64px; text-align: center; }
.qb-val { display: flex; align-items: center; gap: 6px; flex: 0 0 150px; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-primary); }
.qb-val input { border: none; background: transparent; outline: none; width: 100%; font-family: var(--font-mono); font-size: 13px; color: var(--text-primary); }
.qb-unit { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.qb-del { width: 38px; height: 38px; flex-shrink: 0; color: var(--text-muted); }
.qb-del:hover { color: var(--down); background: var(--down-bg); }

/* ===================== INDICES ===================== */
.idx-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.idx-card { text-align: left; border: 1px solid var(--border); background: var(--bg-primary); border-radius: var(--tw-radius); padding: 14px 16px; cursor: pointer; transition: box-shadow 150ms ease, border-color 150ms ease; }
.idx-card:hover { box-shadow: 0 4px 12px var(--card-shadow); border-color: var(--border-strong); }
.idx-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ===================== IPO ===================== */
.ipo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.ipo-status { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.ipo-status.open { background: var(--up-bg); color: var(--up); }
.ipo-status.up { background: var(--accent-soft); color: var(--accent); }
.ipo-status.gain { background: var(--up-bg); color: var(--up); }
.ipo-status.loss { background: var(--down-bg); color: var(--down); }
.ipo-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.ipo-stats .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ipo-stats .v { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.ipo-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }

/* ===================== CALCULATORS ===================== */
.calc-val { font-family: var(--font-mono); font-weight: 600; font-size: 14px; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 8px; }
.calc-range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; outline: none; cursor: pointer; }
.calc-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg-primary); box-shadow: 0 1px 4px rgba(0,0,0,0.25); cursor: pointer; }
.calc-range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg-primary); cursor: pointer; }
.calc-legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); padding: 7px 0; }
.calc-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.calc-legend .lv { margin-left: auto; font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }
.calc-legend.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; font-weight: 600; color: var(--text-primary); }
.calc-legend.total .lv { font-size: 15px; color: var(--accent); }

/* honor reduced motion for entrance bits only; keep functional transitions */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; }
  .ticker-track { animation: none !important; }
  .ticker-bar { overflow-x: auto; }
}
