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

:root {
  --bg:          #0a1120;
  --bg2:         #0e1828;
  --bg3:         #131e30;
  --border:      #1a2d42;
  --text:        #f1f5f9;
  --text-muted:  #64748b;
  --accent:      #10b981;
  --accent2:     #34d399;
  --bull:        #10b981;
  --bear:        #f87171;
  --warn:        #f59e0b;
  --radius:      11px;
  --sidebar-w:   252px;
  --topnav-h:    64px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* ══════════════════════════════════════════════════════════════════════════
   TOP NAV
   ══════════════════════════════════════════════════════════════════════════ */
.topnav {
  height: var(--topnav-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}

.topnav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.4px;
  flex-shrink: 0;
  margin-right: 28px;
}
.topnav-logo svg { flex-shrink: 0; }

.topnav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.topnav-link {
  padding: 6px 16px;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.topnav-link:hover  { background: var(--bg3); color: var(--text); }
.topnav-link.active { background: var(--accent); color: #fff; font-weight: 700; }

.topnav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
.lang-btn {
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-muted);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:hover  { color: var(--text); }
.lang-btn.active { background: var(--accent); color: #fff; }

/* Data timestamp + refresh button */
#nav-data-ts-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
#nav-data-ts-wrap.hidden { display: none; }
#nav-data-ts {
  font-weight: 600;
  color: var(--text);
}

/* Stale data warning — data older than threshold */
#nav-data-ts-wrap.stale { color: #f59e0b; }
#nav-data-ts-wrap.stale #nav-data-ts { color: #f59e0b; }
#nav-data-ts-wrap.stale svg {
  stroke: #f59e0b;
  animation: stale-pulse 2s ease-in-out infinite;
}
@keyframes stale-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* Stale badge on refresh button (visible on mobile) */
#refresh-btn { position: relative; }
#refresh-btn.stale::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid var(--bg2);
}

/* CSS tooltip via data-tooltip attribute */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  right: var(--tooltip-right, 0);
  left:  var(--tooltip-left,  auto);
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  width: max-content;
  max-width: min(260px, calc(100vw - 24px));
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(0);
}

#refresh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
#refresh-btn:hover {
  background: rgba(16,185,129,0.1);
  border-color: var(--accent);
  color: var(--accent);
}
#refresh-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════════
   PAGE BODY  (sidebar + main, below the topnav)
   ══════════════════════════════════════════════════════════════════════════ */
.page-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: var(--topnav-h);
  height: calc(100vh - var(--topnav-h));
  overflow-y: auto;
  flex-shrink: 0;
}

/* ── Market pills ────────────────────────────────────────────────────────── */
.market-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.market-pill {
  flex: 1 1 auto;
  min-width: calc(33% - 6px);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  padding: 7px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.market-pill:hover  { border-color: var(--accent); color: var(--text); }
.market-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 12px rgba(16,185,129,0.25); }

/* ── Form elements ───────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-row { display: flex; gap: 8px; }

#ticker-input, .filter-input {
  flex: 1;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#ticker-input {
  font-family: "SF Mono", "Fira Code", monospace;
  text-transform: uppercase;
}
#ticker-input::placeholder { text-transform: none; color: var(--text-muted); font-family: inherit; }
.filter-input::placeholder  { color: var(--text-muted); }
#ticker-input:focus, .filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

#search-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  padding: 0 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(16,185,129,0.3);
}
#search-btn:hover { background: var(--accent2); }

/* ── Example tickers ─────────────────────────────────────────────────────── */
.example-tickers { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ex-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent2);
  padding: 3px 9px;
  font-size: 11px;
  font-family: "SF Mono", monospace;
  cursor: pointer;
  transition: all 0.15s;
}
.ex-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }

/* ── Period buttons ──────────────────────────────────────────────────────── */
.period-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.period-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.period-btn:hover  { border-color: var(--accent); color: var(--text); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 10px rgba(16,185,129,0.2); }

/* ── Quick info ──────────────────────────────────────────────────────────── */
.quick-info {
  background: linear-gradient(180deg, var(--bg3) 0%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.qi-name  { font-size: 11px; color: var(--text-muted); }
.qi-price { display: flex; align-items: center; gap: 10px; }
.qi-price span:first-child { font-size: 20px; font-weight: 800; }
.qi-meta  { font-size: 11px; color: var(--text-muted); }

/* Data-age bar — shown above the first analysis card */
.data-age-bar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.data-age-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
}
.data-age-bar.stale {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.06);
}
.data-age-bar.stale svg { stroke: #f59e0b; animation: stale-pulse 2s ease-in-out infinite; }

.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.badge.up   { background: rgba(16,185,129,0.12);  color: var(--bull); }
.badge.down { background: rgba(248,113,113,0.12);  color: var(--bear); }

/* ── Overview card (first card in analysis) ──────────────────────────────── */
.card--overview .overview-top {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

/* Left: verdict block */
.overview-verdict-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  gap: 6px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s ease, color 0.25s ease;
}
/* Subtle colour tint via currentColor on the block */
.overview-verdict-block::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0.06;
  border-radius: inherit;
  pointer-events: none;
}
.overview-verdict-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  position: relative; /* stay above ::before */
}
.overview-verdict-text {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.3px;
  line-height: 1.1;
  position: relative;
}
.overview-verdict-score {
  font-size: 13px;
  color: var(--text-muted);
  position: relative;
}
.ov-sig-counts {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
  position: relative;
}
.ov-count-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.ov-count-bull    { background: rgba(16,185,129,0.12);  color: var(--bull); }
.ov-count-neutral { background: rgba(245,158,11,0.12);  color: #f59e0b; }
.ov-count-bear    { background: rgba(248,113,113,0.12); color: var(--bear); }

/* Right: stock info + signals */
.overview-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.overview-stock-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.overview-company {
  font-size: 18px;
  font-weight: 800;
  color: var(--fg1);
  line-height: 1.2;
}
.overview-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.overview-price-block {
  text-align: right;
  flex-shrink: 0;
}
.overview-price {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--fg1);
}
.overview-price-block .badge {
  margin-top: 4px;
  display: inline-block;
}

/* Signal rows inside the overview */
.ov-signal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px 20px;
}
.ov-sig-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  min-width: 0;
}
.ov-sig-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ov-sig-dot.bull    { background: var(--bull); }
.ov-sig-dot.bear    { background: var(--bear); }
.ov-sig-dot.neutral { background: #f59e0b; }
.ov-sig-label {
  flex: 1;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ov-sig-val {
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

/* Returns row */
.overview-returns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.ov-ret-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.ov-ret-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.ov-ret-val {
  font-size: 15px;
  font-weight: 700;
}
.ov-ret-val.up   { color: var(--bull); }
.ov-ret-val.down { color: var(--bear); }

.returns-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 5px; margin-top: 4px; }
.ret-item { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; }
.ret-item .ret-label { font-size: 10px; color: var(--text-muted); }
.ret-item .ret-val   { font-size: 13px; font-weight: 700; }
.ret-item .ret-val.up   { color: var(--bull); }
.ret-item .ret-val.down { color: var(--bear); }

/* ── Verdict box ─────────────────────────────────────────────────────────── */
.verdict-box {
  background: linear-gradient(180deg, var(--bg3) 0%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.verdict-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.verdict-text  { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; }
.verdict-score { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Sidebar section nav ─────────────────────────────────────────────────── */
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.15s;
}
.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link:hover svg { opacity: 1; }
.nav-link:hover { background: rgba(16,185,129,0.08); color: var(--accent2); }

.sidebar-info-box {
  margin-top: auto;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Sector filter chips ─────────────────────────────────────────────────── */
.sector-filters { display: flex; flex-wrap: wrap; gap: 5px; }
.sector-chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.sector-chip:hover  { border-color: var(--accent); color: var(--accent); }
.sector-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
  overflow-y: auto;
  height: calc(100vh - var(--topnav-h));
}
.main > * + * { margin-top: 20px; }
#dashboard > * + * { margin-top: 32px; }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-title    { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.last-updated  { font-size: 11px; color: var(--text-muted); white-space: nowrap; margin-top: 4px; }

/* ── States ──────────────────────────────────────────────────────────────── */
.empty-state, .error-state, .loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 55vh;
  color: var(--text-muted);
  text-align: center;
}
.error-state p { color: var(--bear); }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--bg3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════════
   ANALYSIS CARDS
   ══════════════════════════════════════════════════════════════════════════ */
.card {
  background: linear-gradient(180deg, #131e30 0%, #0f1a2a 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  scroll-margin-top: 20px;
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.card-title-block { flex: 1; min-width: 0; }
.card h2     { font-size: 15px; font-weight: 800; margin-bottom: 5px; letter-spacing: -0.2px; }
.card-desc   { font-size: 12px; color: var(--text-muted); line-height: 1.65; }

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }

.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.tag.bull { background: rgba(16,185,129,0.12);  color: var(--bull); }
.tag.bear { background: rgba(248,113,113,0.12);  color: var(--bear); }

.stat-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}

.chart-area        { width: 100%; height: 420px; }
.chart-area--small { height: 210px; }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.tip {
  border-bottom: 1px dashed var(--text-muted);
  cursor: help;
}
.tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 280px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(16,185,129,0.1);
}
.tooltip.visible { opacity: 1; }

/* ── Signals ─────────────────────────────────────────────────────────────── */
.signals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.signal-card {
  background: linear-gradient(180deg, #131e30 0%, #0f1a2a 100%);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 3px solid transparent;
}
.signal-card.bull    { border-left-color: var(--bull); }
.signal-card.bear    { border-left-color: var(--bear); }
.signal-card.neutral { border-left-color: var(--warn); }

.signal-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); }
.signal-value { font-size: 14px; font-weight: 800; }
.signal-value.bull    { color: var(--bull); }
.signal-value.bear    { color: var(--bear); }
.signal-value.neutral { color: var(--warn); }
.signal-text          { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ── Fundamentals ────────────────────────────────────────────────────────── */
.fundamentals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.fund-group { display: flex; flex-direction: column; gap: 8px; }
.fund-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.fund-item { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.fund-key  { font-size: 12px; color: var(--text-muted); cursor: default; }
.fund-val  { font-size: 12px; font-weight: 700; color: var(--text); text-align: right; }

/* ── Further Reading ─────────────────────────────────────────────────────── */
.resources-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.resources-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.resources-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.resource-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 13px;
  text-decoration: none;
  transition: all 0.15s;
}
.resource-link:hover {
  background: rgba(16,185,129,0.08);
  border-color: var(--accent);
  color: var(--accent);
}
.resource-link svg { flex-shrink: 0; opacity: 0.7; }
.resource-link:hover svg { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════════════
   STOCKS TABLE
   ══════════════════════════════════════════════════════════════════════════ */
.table-wrapper {
  background: linear-gradient(180deg, #0e1828 0%, #0a1120 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#stocks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#stocks-table thead th {
  background: rgba(16,185,129,0.05);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
#stocks-table thead th.num { text-align: right; }
.sortable       { cursor: pointer; }
.sortable:hover { color: var(--accent); }
.sort-icon      { font-size: 10px; margin-left: 4px; color: var(--text-muted); }

#stocks-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
#stocks-table tbody tr:last-child { border-bottom: none; }
#stocks-table tbody tr:hover      { background: rgba(16,185,129,0.05); }
#stocks-table td { padding: 11px 16px; vertical-align: middle; }

.td-company { font-weight: 600; }
.td-ticker  { font-family: "SF Mono", "Fira Code", monospace; font-size: 12px; color: var(--accent2); }

.type-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 20px;
  margin-left: 7px;
  vertical-align: middle;
}
.type-badge.stock { background: rgba(16,185,129,0.12); color: var(--bull);  border: 1px solid rgba(16,185,129,0.25); }
.type-badge.etf   { background: rgba(108,142,191,0.12); color: #6c8ebf;     border: 1px solid rgba(108,142,191,0.25); }
.td-num     { text-align: right; font-variant-numeric: tabular-nums; }
.td-change  { text-align: right; font-weight: 700; white-space: nowrap; }
.td-change.up   { color: var(--bull); }
.td-change.down { color: var(--bear); }

.range-cell { min-width: 130px; }
.range-wrap { display: flex; flex-direction: column; gap: 4px; }
.range-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); }
.range-track  { position: relative; height: 4px; background: var(--bg); border-radius: 3px; overflow: visible; }
.range-fill   {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px;
  background: linear-gradient(90deg, #f87171 0%, #f59e0b 50%, #10b981 100%);
}
.range-marker {
  position: absolute; top: -3px; width: 3px; height: 10px;
  background: #fff; border-radius: 2px; transform: translateX(-50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.6);
}
.sector-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE COMPONENTS  (hamburger, sidebar drawer, overlay)
   ══════════════════════════════════════════════════════════════════════════ */

.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  order: -1;           /* stays left of logo */
}
.nav-hamburger:hover { border-color: var(--accent); color: var(--accent); }

/* filter bar shown at top of main content on mobile */
.mobile-filter-bar { display: none; }
.mobile-filter-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.mobile-filter-btn:hover { border-color: var(--accent); color: var(--accent); }

/* semi-transparent backdrop */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.mobile-overlay.active { display: block; }

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE ≤ 768px  (tablet + large phone)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  /* Compact timestamp: hide the text, keep the clock icon.
     The icon turns amber when stale — visible warning at every width. */
  #nav-data-ts { display: none; }
}

@media (max-width: 768px) {

  /* ── Topnav ─────────────────────────────────────────────────────────────── */
  .topnav { padding: 0 14px; gap: 10px; }

  .topnav-links { display: none; }
  .topnav-links.nav-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    padding: 8px 14px 14px;
    gap: 4px;
    z-index: 300;
  }
  .topnav-link { padding: 11px 14px; border-radius: 8px; }
  .topnav-link.active { background: var(--accent); color: #fff; }

  .nav-hamburger { display: flex; }

  /* Timestamp: icon-only on mobile (text already hidden at ≤1024px) */

  /* ── Sidebar → slide-in overlay ─────────────────────────────────────────── */
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topnav-h);
    height: calc(100vh - var(--topnav-h));
    width: min(var(--sidebar-w), 82vw);
    transform: translateX(-110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    overflow-y: auto;
    box-shadow: 6px 0 32px rgba(0,0,0,0.45);
    /* keep existing bg/border/padding from base styles */
  }
  .sidebar.sidebar-open { transform: translateX(0); }

  /* ── Main fills the full width ───────────────────────────────────────────── */
  .main { width: 100%; }

  /* ── Filter button visible ───────────────────────────────────────────────── */
  .mobile-filter-bar { display: block; margin-bottom: 14px; }

  /* ── Card header: stack vertically so description gets full width ───────── */
  .card-header { flex-direction: column; gap: 10px; }
  .card-desc   { max-width: 100%; }
  .legend      { justify-content: flex-start; }

  /* ── Table: drop the two least-important columns ─────────────────────────── */
  /* col 5 = Market Cap, col 6 = 52W Range */
  #stocks-table th:nth-child(5), #stocks-table td:nth-child(5),
  #stocks-table th:nth-child(6), #stocks-table td:nth-child(6) { display: none; }

  /* ── Advice cards: single column ─────────────────────────────────────────── */
  .advice-grid { grid-template-columns: 1fr; }

  /* ── Overview card: stack layout ──────────────────────────────────────────── */
  .card--overview .overview-top {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .overview-verdict-block { flex-direction: row; flex-wrap: wrap; text-align: left; align-items: center; gap: 10px; padding: 14px 16px; }
  .overview-verdict-label { width: 100%; }
  .ov-sig-counts          { margin-top: 0; }
  .overview-price-block   { text-align: left; }
  .ov-signal-grid         { grid-template-columns: 1fr; }
  .overview-returns       { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* ── Page padding ────────────────────────────────────────────────────────── */
  .main { padding: 16px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE ≤ 480px  (phone)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── Topnav: maximum compactness ─────────────────────────────────────────── */
  .topnav { padding: 0 10px; gap: 6px; }
  .topnav-logo span { display: none; }   /* avatar only, hide "BokStocks" text */
  #refresh-btn span { display: none; }   /* icon only */
  #refresh-btn { padding: 5px 8px; min-width: 0; }
  .lang-btn { padding: 3px 7px; }

  /* ── Charts: shorter on small screens ────────────────────────────────────── */
  .chart-area        { min-height: 220px !important; }
  .chart-area--small { min-height: 140px !important; }

  /* ── Table → Card layout ─────────────────────────────────────────────────── */
  #stocks-table                    { border-collapse: separate; border-spacing: 0; width: 100%; }
  #stocks-table thead              { display: none; }
  #stocks-table tbody              { display: flex; flex-direction: column; gap: 10px; }

  #stocks-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name  price"
      "tick  chng"
      "sect  sect";
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.15s;
    gap: 0;
  }
  #stocks-table tbody tr:hover { border-color: var(--accent); }

  /* reset all td defaults */
  #stocks-table td { border: none; padding: 0; }

  /* col 1 — company name */
  #stocks-table td:nth-child(1) {
    grid-area: name;
    font-size: 13px;
    font-weight: 700;
    align-self: end;
    padding-bottom: 3px;
    padding-right: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* hide the type badge inside card — sector row already shows it */
  #stocks-table td:nth-child(1) .type-badge { display: none; }

  /* col 2 — ticker */
  #stocks-table td:nth-child(2) {
    grid-area: tick;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 11px;
    color: var(--accent2);
    padding-top: 2px;
  }

  /* col 3 — price */
  #stocks-table td:nth-child(3) {
    grid-area: price;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    align-self: end;
    padding-bottom: 3px;
  }

  /* col 4 — change % */
  #stocks-table td:nth-child(4) {
    grid-area: chng;
    text-align: right;
    padding-top: 2px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* col 5 & 6 — hidden */
  #stocks-table td:nth-child(5),
  #stocks-table td:nth-child(6) { display: none; }

  /* col 7 — sector, full width with separator */
  #stocks-table td:nth-child(7) {
    grid-area: sect;
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border);
  }

  /* ── Page header ─────────────────────────────────────────────────────────── */
  .page-header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .page-title  { font-size: 18px; }

  /* ── Signals grid: 1 column ──────────────────────────────────────────────── */
  .signals-grid { grid-template-columns: 1fr; }

  /* ── Overview card: smaller font on very small phones ────────────────────── */
  .overview-company     { font-size: 16px; }
  .overview-verdict-text{ font-size: 17px; }
  .overview-price       { font-size: 18px; }
  .ov-ret-val           { font-size: 14px; }
}
