/* ═══════════════════════════════════════════════════════
   MARKET PULSE — CoinMarketCap-inspired design system
   Bloomberg terminal palette · Table-first · Data dense
   ═══════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;
  --topbar-h:    56px;
  --controls-h:  58px;
  --bg:          #13151a;
  --surface:     #1b1d27;
  --surface-2:   #222535;
  --surface-3:   #2a2d3e;
  --ink:         #e8ecf5;
  --ink-2:       #b2b9cc;
  --muted:       #7a8195;
  --faint:       #363a4d;
  --line:        #252838;
  --line-2:      #2e3248;
  --orange:      #ff6b35;
  --orange-dim:  rgba(255,107,53,0.15);
  --green:       #16c784;
  --green-bg:    rgba(22,199,132,0.12);
  --red:         #ea3943;
  --red-bg:      rgba(234,57,67,0.12);
  --blue:        #58a6ff;
  --blue-bg:     rgba(88,166,255,0.1);
  --amber:       #f0b90b;
  --amber-bg:    rgba(240,185,11,0.12);
  --shadow:      0 8px 24px rgba(0,0,0,0.5);
  --radius:      6px;
  --font-ui:     Inter, "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  --font-mono:   "JetBrains Mono","Fira Mono","Cascadia Code","Courier New",monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg:        #f0f3fb;
  --surface:   #ffffff;
  --surface-2: #f6f8ff;
  --surface-3: #eaeef8;
  --ink:       #1a1d2e;
  --ink-2:     #4a5068;
  --muted:     #818aab;
  --faint:     #c8cfe8;
  --line:      #dde2f0;
  --line-2:    #c8cfe8;
  --shadow:    0 8px 24px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-width: 320px;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 14px;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,p { margin: 0; }
a { color: inherit; }
button,input,select { font: inherit; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 3px; }

/* ══════════════════════════════════════
   GLOBAL STATS BAR (CMC-style)
   ══════════════════════════════════════ */
.global-stats-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
  height: 30px;
}
.global-stats-bar::-webkit-scrollbar { display: none; }
.gs-inner {
  display: flex; align-items: center; height: 100%;
  padding: 0 clamp(12px,3vw,48px); gap: 0;
  white-space: nowrap;
  font-size: 0.7rem; font-family: var(--font-mono); color: var(--muted);
}
.gs-item {
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px; height: 100%;
  border-right: 1px solid var(--line-2);
}
.gs-item:first-child { padding-left: 0; }
.gs-item:last-child  { border-right: none; }
.gs-item strong { color: var(--ink); font-weight: 600; }
.gs-item strong.up   { color: var(--green); }
.gs-item strong.down { color: var(--red); }
.gs-change { font-size: 0.65rem; font-weight: 700; }
.gs-change.up   { color: var(--green); }
.gs-change.down { color: var(--red); }
.live-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--green);
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ══════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  display: flex; align-items: center;
  width: 100%;
  padding: 0 clamp(12px,3vw,48px);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  min-width: max-content; text-decoration: none; color: inherit;
  padding-right: 24px; margin-right: 8px;
  border-right: 1px solid var(--line);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--orange); color: #fff;
  font-weight: 900; font-size: 0.78rem; letter-spacing: -0.03em;
}
.brand-name { font-size: 0.9rem; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.brand-sub  { font-size: 0.65rem; color: var(--muted); margin-top: 1px; }

.nav-links {
  display: flex; align-items: center; height: 100%; margin-left: 8px;
}
.nav-links a {
  display: flex; align-items: center; height: 56px; padding: 0 14px;
  text-decoration: none; color: var(--muted);
  font-size: 0.82rem; font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: color 120ms, border-color 120ms;
  white-space: nowrap;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--orange); }

.topbar-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; padding-left: 16px;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 0 12px;
  height: 34px; transition: border-color 140ms;
}
.search-box:focus-within { border-color: var(--orange); }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--ink); font-size: 0.82rem; width: 180px;
}
.search-box input::placeholder { color: var(--muted); }
.search-icon { color: var(--muted); font-size: 0.85rem; }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--ink-2); cursor: pointer; display: grid; place-items: center;
  font-size: 0.9rem; transition: background 120ms, border-color 120ms, color 120ms;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--orange); color: var(--orange); }
.icon-btn:disabled { opacity: 0.4; cursor: wait; }
.icon-btn.spinning { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.watchlist-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 3px; background: var(--orange);
  color: #fff; font-size: 0.6rem; font-weight: 900; margin-left: 3px;
}

/* ══════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════ */
main { padding: 0 0 48px; }

.page-head {
  padding: 20px clamp(12px,3vw,48px) 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.page-head-row {
  display: flex; align-items: flex-end;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.page-eyebrow {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--orange); margin-bottom: 4px;
}
.page-title { font-size: clamp(1.2rem,2.5vw,1.8rem); font-weight: 800; letter-spacing: -0.02em; }
.page-subtitle { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.update-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 5px 12px;
  font-size: 0.72rem; font-family: var(--font-mono); color: var(--muted);
  white-space: nowrap;
}

/* ══════════════════════════════════════
   MACRO SUMMARY BAR
   ══════════════════════════════════════ */
.macro-summary {
  display: flex; align-items: center; gap: 0;
  padding: 0 clamp(12px,3vw,48px);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
  height: 52px;
}
.macro-summary::-webkit-scrollbar { display: none; }
.macro-item {
  display: flex; flex-direction: column;
  padding: 0 20px; border-right: 1px solid var(--line);
  min-width: max-content; white-space: nowrap;
}
.macro-item:first-child { padding-left: 0; }
.macro-item:last-child  { border-right: none; }
.macro-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.macro-val   { font-size: 0.88rem; font-family: var(--font-mono); font-weight: 700; color: var(--ink); margin-top: 1px; }
.macro-val .up   { color: var(--green); }
.macro-val .down { color: var(--red); }
.regime-pill {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 10px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em;
}
.regime-pill.bull  { background: var(--green-bg);  color: var(--green); }
.regime-pill.bear  { background: var(--red-bg);    color: var(--red); }
.regime-pill.mixed { background: var(--amber-bg);  color: var(--amber); }

/* ══════════════════════════════════════
   MARKET SEGMENT ANALYSIS
   ══════════════════════════════════════ */
.segment-section {
  padding: 14px clamp(12px,3vw,48px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.segment-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.segment-strip {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.segment-card {
  flex: 1 1 200px; min-width: 180px; max-width: 320px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  transition: border-color 140ms, box-shadow 140ms;
}
.segment-card:hover { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange-dim); }
.segment-card.skeleton { opacity: 0.4; }
.segment-card-inner { padding: 14px 16px; }
.segment-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.segment-icon { font-size: 1.1rem; }
.segment-chg {
  font-size: 0.8rem; font-weight: 800;
  font-family: var(--font-mono); padding: 2px 8px;
  border-radius: 4px;
}
.segment-chg.up   { color: var(--green); background: var(--green-bg); }
.segment-chg.down { color: var(--red);   background: var(--red-bg); }
.segment-chg.flat { color: var(--muted); background: var(--surface-3); }
.segment-name  { font-size: 0.9rem; font-weight: 800; color: var(--ink); margin-bottom: 2px; }
.segment-mcap  { font-size: 0.78rem; font-family: var(--font-mono); color: var(--orange); font-weight: 700; margin-bottom: 4px; }
.segment-meta  { font-size: 0.68rem; color: var(--muted); margin-bottom: 8px; }
.segment-bar   { height: 3px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.segment-bar-fill { height: 100%; border-radius: 999px; transition: width 600ms ease; }

/* ══════════════════════════════════════
   SECTOR OVERVIEW STRIP
   ══════════════════════════════════════ */
.sector-strip-wrap {
  padding: 14px clamp(12px,3vw,48px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.sector-strip-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.sector-strip {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
}
.sector-strip::-webkit-scrollbar { display: none; }
.sector-card {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 130px; padding: 10px 14px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  transition: border-color 140ms, background 140ms;
  flex-shrink: 0;
}
.sector-card:hover,
.sector-card.active { border-color: var(--orange); background: var(--surface-2); }
.sector-card-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sector-icon { font-size: 0.9rem; }
.sector-chg {
  font-size: 0.78rem; font-weight: 800;
  font-family: var(--font-mono); padding: 1px 6px;
  border-radius: 3px;
}
.sector-chg.up   { color: var(--green); background: var(--green-bg); }
.sector-chg.down { color: var(--red);   background: var(--red-bg); }
.sector-chg.flat { color: var(--muted); background: var(--surface-3); }
.sector-name { font-size: 0.75rem; font-weight: 700; color: var(--ink-2); }
.sector-meta { font-size: 0.65rem; color: var(--muted); }
.sector-breadth { height: 3px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.sector-breadth-fill { height: 100%; border-radius: 999px; transition: width 600ms ease; }

/* ══════════════════════════════════════
   STOCKS TABLE SECTION
   ══════════════════════════════════════ */
.table-section { padding: 0 clamp(12px,3vw,48px); }
.table-controls {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  position: sticky; top: var(--topbar-h); z-index: 10;
  background: var(--bg);
}
.sector-filters {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; scrollbar-width: none; flex: 1;
}
.sector-filters::-webkit-scrollbar { display: none; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--muted); font-size: 0.76rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: all 140ms;
}
.filter-pill:hover  { border-color: var(--orange); color: var(--orange); }
.filter-pill.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 800; }
.table-toolbar {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.table-toolbar select {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink); font-size: 0.76rem;
  outline: none; cursor: pointer;
}
.table-toolbar select:focus { border-color: var(--orange); }
.stock-count { font-size: 0.72rem; color: var(--muted); font-family: var(--font-mono); white-space: nowrap; }

/* The table */
.stocks-table-wrap { overflow-x: auto; }
.stocks-table { width: 100%; min-width: 820px; border-collapse: collapse; }
.stocks-table th {
  padding: 10px 12px; text-align: right;
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 2px solid var(--orange);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.stocks-table th:hover { color: var(--ink); }
.stocks-table th.sorted { color: var(--orange); }
.stocks-table th:nth-child(1),
.stocks-table th:nth-child(2) { text-align: left; }
.stocks-table td {
  padding: 11px 12px; text-align: right;
  font-size: 0.84rem; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-family: var(--font-mono); color: var(--ink-2);
}
.stocks-table td:nth-child(1),
.stocks-table td:nth-child(2) { text-align: left; font-family: var(--font-ui); }
.stocks-table tbody tr { background: var(--bg); transition: background 80ms; cursor: pointer; }
.stocks-table tbody tr:hover { background: var(--surface); }
.rank-col { color: var(--muted); font-size: 0.78rem; padding-right: 4px; }
.watch-star {
  font-size: 0.85rem; cursor: pointer; color: var(--faint);
  transition: color 120ms; user-select: none; margin-right: 6px;
}
.watch-star:hover,.watch-star.active { color: var(--amber); }
.price-col { color: var(--ink); font-weight: 600; }

/* Asset cell */
.asset-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.asset-img  { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }
.asset-mark {
  width: 24px; height: 24px; border-radius: 4px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--orange);
  font-size: 0.6rem; font-weight: 900; font-family: var(--font-ui);
}
.asset-name  { font-size: 0.84rem; font-weight: 700; color: var(--ink); font-family: var(--font-ui); }
.asset-sym   { font-size: 0.72rem; color: var(--muted); font-family: var(--font-mono); }
.asset-link  { text-decoration: none; color: inherit; }
.asset-link:hover .asset-name { color: var(--orange); }

/* Change pills (CMC-style) */
.chg {
  display: inline-flex; align-items: center;
  min-width: 72px; padding: 3px 8px;
  border-radius: 4px; font-size: 0.78rem;
  font-weight: 700; font-family: var(--font-mono);
  justify-content: center;
}
.chg.up   { color: var(--green); background: var(--green-bg); }
.chg.down { color: var(--red);   background: var(--red-bg); }
.chg.flat { color: var(--muted); background: var(--surface-3); }

/* Market cap tier badge */
.cap-tier {
  display: inline-block; font-size: 0.58rem; font-weight: 800;
  padding: 1px 5px; border-radius: 3px; margin-left: 5px;
  font-family: var(--font-ui); vertical-align: middle;
}
.cap-mega  { background: rgba(240,185,11,0.18); color: var(--amber); }
.cap-large { background: rgba(88,166,255,0.14); color: var(--blue); }
.cap-mid   { background: var(--surface-3);      color: var(--muted); }

/* Sector pill in table */
.sec-pill {
  font-size: 0.65rem; font-weight: 600;
  padding: 2px 7px; border-radius: 3px;
  background: var(--surface-3); color: var(--muted);
  font-family: var(--font-ui);
}

/* Empty/placeholder row */
.empty-row td { text-align: center; color: var(--muted); padding: 32px 12px; font-family: var(--font-ui); }

/* up/down text */
.up   { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--muted); }

/* ══════════════════════════════════════
   NEWS TICKER (compact strip)
   ══════════════════════════════════════ */
.news-ticker-wrap {
  display: flex; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--line);
  height: 36px; overflow: hidden;
  padding: 0 clamp(12px,3vw,48px) 0 0;
}
.news-ticker-label {
  flex-shrink: 0;
  background: var(--orange); color: #fff;
  font-size: 0.62rem; font-weight: 900; letter-spacing: 0.1em;
  padding: 0 12px; height: 100%;
  display: flex; align-items: center;
  margin-right: 14px;
}
.news-ticker {
  display: flex; align-items: center; gap: 0;
  overflow-x: auto; scrollbar-width: none;
  flex: 1; height: 100%;
  white-space: nowrap;
}
.news-ticker::-webkit-scrollbar { display: none; }
.news-ticker-loading { font-size: 0.75rem; color: var(--muted); padding-left: 4px; }
.ticker-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 16px 0 0; height: 100%;
  text-decoration: none; color: inherit;
  flex-shrink: 0;
  transition: color 120ms;
}
.ticker-item:hover .ticker-title { color: var(--orange); }
.ticker-source {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--orange);
  background: var(--orange-dim); padding: 1px 5px; border-radius: 3px;
  flex-shrink: 0;
}
.ticker-title {
  font-size: 0.76rem; color: var(--ink-2);
  max-width: 340px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  transition: color 120ms;
}
.ticker-age {
  font-size: 0.65rem; color: var(--muted);
  font-family: var(--font-mono); flex-shrink: 0;
}
.ticker-sep {
  color: var(--faint); padding: 0 8px; font-size: 0.8rem; flex-shrink: 0;
}

/* ══════════════════════════════════════
   TOAST
   ══════════════════════════════════════ */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  max-width: min(360px,calc(100vw - 32px));
  padding: 10px 16px; border-radius: var(--radius);
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--line-2); border-left: 3px solid var(--orange);
  font-size: 0.8rem; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(6px);
  transition: opacity 160ms, transform 160ms; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ══════════════════════════════════════
   ASSET DETAIL PAGE
   ══════════════════════════════════════ */
.detail-main { padding: 0 clamp(12px,3vw,48px) 48px; display: grid; gap: 16px; margin-top: 16px; }
.asset-hero {
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between;
}
.asset-hero-loading { color: var(--muted); font-size: 0.9rem; }
.asset-hero-identity { display: flex; align-items: center; gap: 16px; }
.detail-logo {
  width: 56px; height: 56px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  object-fit: contain; padding: 6px; flex-shrink: 0;
}
.detail-logo-fallback {
  display: grid; place-items: center;
  color: var(--orange); font-weight: 900; font-size: 1.1rem;
}
.eyebrow { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.hero-symbol { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono); }
.asset-price-card { text-align: right; }
.asset-price-card span { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: block; margin-bottom: 4px; }
.asset-price-card strong { font-size: 2rem; font-weight: 900; font-family: var(--font-mono); letter-spacing: -0.04em; display: block; }
.asset-price-card em { font-style: normal; font-size: 0.9rem; font-family: var(--font-mono); }
.asset-price-card small { display: block; margin-top: 4px; }

.detail-topbar { justify-content: space-between; gap: 12px; padding: 0 clamp(12px,3vw,48px); }
.detail-topbar .brand span { font-size: 0.75rem; color: var(--muted); display: block; }
.nav-pills { display: flex; gap: 4px; }
.nav-pills a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 0.76rem; font-weight: 600; color: var(--muted); text-decoration: none; transition: all 120ms; }
.nav-pills a:hover { border-color: var(--orange); color: var(--orange); }
.actions { display: flex; gap: 6px; }
.icon-button {
  width: 34px; height: 34px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--ink-2); cursor: pointer; display: grid; place-items: center;
  font-size: 0.9rem; transition: all 120ms;
}
.icon-button:hover { background: var(--surface-3); border-color: var(--orange); color: var(--orange); }

/* Detail grid: chart + metrics */
.detail-grid { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(280px,.6fr); gap: 16px; }
.detail-card {
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 16px;
}
.detail-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.chart-card { min-height: 440px; display: flex; flex-direction: column; }
.tradingview-frame-wrap { flex: 1; border-radius: 4px; overflow: hidden; position: relative; min-height: 380px; }
#tradingViewFrame { display: block; width: 100%; height: 100%; min-height: 380px; border: 0; }

/* Chart controls */
.segmented-control { display: flex; gap: 3px; }
.segment {
  padding: 3px 10px; border-radius: 3px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--muted); font-size: 0.72rem; font-weight: 700;
  cursor: pointer; transition: all 120ms;
}
.segment:hover  { border-color: var(--orange); color: var(--orange); }
.segment.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--muted); font-size: 0.72rem; font-weight: 600;
  text-decoration: none; white-space: nowrap; transition: all 120ms;
}
.pill:hover { border-color: var(--orange); color: var(--orange); }

/* Fullscreen overlay */
.tv-fullscreen {
  position: fixed; inset: 0; z-index: 1000;
  background: #000; display: none; flex-direction: column;
}
.tv-fullscreen.open { display: flex; }
.tv-fs-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.tv-fs-bar span { font-weight: 700; font-size: 0.88rem; color: var(--ink); }
.tv-fs-close {
  background: var(--surface-3); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 5px 14px;
  color: var(--ink); cursor: pointer; font-size: 0.82rem; font-weight: 700;
  transition: background 120ms;
}
.tv-fs-close:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
#tvFrameFS { flex: 1; border: 0; width: 100%; height: 100%; }

/* Stats rows */
.detail-metrics { display: flex; flex-direction: column; }
.detail-metric {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--line); gap: 10px;
}
.detail-metric:last-child { border-bottom: none; }
.detail-metric > span { font-size: 0.74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-metric > strong { font-size: 0.84rem; font-family: var(--font-mono); color: var(--ink-2); text-align: right; }
.signal-badge { font-size: 0.7rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.signal-badge.bullish { background: var(--green-bg); color: var(--green); }
.signal-badge.bearish { background: var(--red-bg);   color: var(--red); }
.signal-badge.neutral { background: var(--surface-3); color: var(--muted); }

/* Analysis copy */
.analysis-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.analysis-copy { font-size: 0.8rem; color: var(--muted); line-height: 1.7; margin-top: 10px; }

/* ══════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════ */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 16px 0 24px;
  flex-wrap: wrap;
}
.pg-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-2);
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: all 120ms; display: inline-flex; align-items: center; justify-content: center;
}
.pg-btn:hover:not(.pg-disabled):not(.pg-active) {
  border-color: var(--orange); color: var(--orange); background: var(--surface-2);
}
.pg-btn.pg-active {
  background: var(--orange); border-color: var(--orange);
  color: #fff; font-weight: 800;
}
.pg-btn.pg-disabled { opacity: 0.35; cursor: default; }
.pg-nav { padding: 0 14px; font-size: 0.78rem; }
.pg-ellipsis { color: var(--muted); font-size: 0.8rem; padding: 0 4px; line-height: 36px; }

/* ══════════════════════════════════════
   PORTFOLIO & WATCHLIST PAGES
   ══════════════════════════════════════ */
.page-content { padding: 20px clamp(12px,3vw,48px) 48px; display: grid; gap: 16px; }
.portfolio-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.p-stat {
  background: var(--surface); border: 1px solid var(--line-2);
  border-top: 2px solid var(--orange); border-radius: var(--radius); padding: 14px;
}
.p-stat-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--orange); margin-bottom: 6px; }
.p-stat-val   { font-size: 1.5rem; font-family: var(--font-mono); font-weight: 800; }
.p-stat-sub   { font-size: 0.78rem; font-family: var(--font-mono); margin-top: 3px; }

.add-form {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 16px;
}
.form-field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 120px; }
.form-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--orange); }
.form-field input, .form-field select {
  height: 34px; border: 1px solid var(--line-2);
  border-radius: var(--radius); background: var(--surface-2);
  color: var(--ink); padding: 0 10px; font-size: 0.82rem; outline: none; width: 100%;
}
.form-field input:focus, .form-field select:focus { border-color: var(--orange); }
.btn-add {
  height: 34px; min-width: 110px; border: 1px solid var(--orange);
  border-radius: var(--radius); background: var(--orange);
  color: #fff; font-weight: 800; font-size: 0.78rem;
  letter-spacing: 0.04em; cursor: pointer;
  transition: background 120ms;
}
.btn-add:hover { background: #e55a28; }
.btn-remove {
  border: 1px solid var(--line-2); border-radius: 3px; padding: 3px 8px;
  background: transparent; color: var(--red); font-size: 0.72rem;
  font-weight: 700; cursor: pointer; transition: background 120ms;
}
.btn-remove:hover { background: var(--red-bg); border-color: var(--red); }

.data-table-wrap {
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); overflow: hidden;
}
.data-table-wrap table { width: 100%; min-width: 680px; border-collapse: collapse; }
.data-table-wrap th {
  padding: 10px 12px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line-2);
  background: var(--surface-2); text-align: right; white-space: nowrap;
}
.data-table-wrap th:nth-child(1),.data-table-wrap th:nth-child(2) { text-align: left; }
.data-table-wrap td {
  padding: 10px 12px; font-size: 0.82rem; font-family: var(--font-mono);
  border-bottom: 1px solid var(--line); text-align: right; color: var(--ink-2);
}
.data-table-wrap tr:last-child td { border-bottom: none; }
.data-table-wrap td:nth-child(1),.data-table-wrap td:nth-child(2) { text-align: left; font-family: var(--font-ui); }
.data-table-wrap tfoot td { background: var(--surface-2); font-weight: 900; border-top: 2px solid var(--line-2); }

.chart-box {
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 16px;
}
.chart-box canvas { max-height: 240px; width: 100%; }
.empty-state { padding: 40px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; font-size: 1.1rem; color: var(--ink); margin-bottom: 8px; }

/* ══════════════════════════════════════
   LOGOUT BUTTON
   ══════════════════════════════════════ */
.logout-btn {
  font-size: 1rem;
  opacity: 0.75;
}
.logout-btn:hover {
  opacity: 1;
  color: var(--red) !important;
  border-color: var(--red) !important;
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 1100px) {
  .detail-grid   { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  .portfolio-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .nav-links        { display: none; }
  .search-box input { width: 140px; }
  .macro-summary    { height: auto; }
  .portfolio-stats  { grid-template-columns: 1fr; }
  .add-form         { flex-direction: column; }
  .segment-strip    { flex-wrap: nowrap; overflow-x: auto; }
  .segment-card     { min-width: 160px; max-width: none; }
}
@media (max-width: 480px) {
  .page-title   { font-size: 1.2rem; }
  .search-box   { display: none; }
  .gs-inner     { font-size: 0.65rem; }
}
