:root {
  color-scheme: dark;
  --bg: #071018;
  --surface: #0d1822;
  --surface-2: #13212d;
  --surface-3: #172938;
  --text: #f5f8fb;
  --muted: #8fa1b3;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #48d5a4;
  --accent-2: #4da3ff;
  --positive: #48d5a4;
  --negative: #ff6b79;
  --warning: #ffbe5c;
  --neutral: #8fa1b3;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  --radius: 20px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #edf3f7;
  --text: #13212d;
  --muted: #617486;
  --line: rgba(19, 33, 45, 0.10);
  --shadow: 0 22px 60px rgba(15, 35, 52, 0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 0%, rgba(72, 213, 164, 0.10), transparent 30%),
    radial-gradient(circle at 95% 15%, rgba(77, 163, 255, 0.09), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(18px, 4vw, 64px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04120e;
  font-weight: 900;
  letter-spacing: -0.04em;
  box-shadow: 0 10px 28px rgba(72, 213, 164, 0.22);
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.updated-at { color: var(--muted); font-size: 0.84rem; }
.icon-button, .secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-2);
  border-radius: 12px;
  transition: .2s ease;
}
.icon-button { width: 42px; height: 42px; }
.secondary-button { padding: 11px 15px; }
.icon-button:hover, .secondary-button:hover { border-color: rgba(72, 213, 164, .45); transform: translateY(-1px); }

main, footer { width: min(1500px, calc(100% - 36px)); margin-inline: auto; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 32px;
  padding: clamp(42px, 7vw, 92px) 0 34px;
}
.hero h1 { max-width: 920px; margin: 7px 0 16px; font-size: clamp(2rem, 4vw, 4.4rem); line-height: 1.04; letter-spacing: -0.055em; }
.hero p { max-width: 840px; margin: 0; color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.15rem); line-height: 1.7; }
.eyebrow { color: var(--accent) !important; font-size: .74rem !important; font-weight: 800; letter-spacing: .18em; }
.hero-badge { display: flex; align-items: center; gap: 12px; min-width: 230px; padding: 16px 18px; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.hero-badge strong, .hero-badge small { display: block; }
.hero-badge small { margin-top: 3px; color: var(--muted); }
.pulse { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 7px rgba(72,213,164,.10); }
.pulse::after { content: ""; position: absolute; inset: -6px; border: 1px solid var(--accent); border-radius: 50%; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { transform: scale(.65); opacity: .8; } 100% { transform: scale(1.45); opacity: 0; } }

.metrics-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric-card { min-height: 132px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, var(--surface), var(--surface-2)); box-shadow: var(--shadow); }
.metric-card span { display: block; color: var(--muted); font-size: .82rem; }
.metric-card strong { display: block; margin-top: 13px; font-size: clamp(1.5rem, 2.6vw, 2.2rem); letter-spacing: -.04em; }
.metric-card small { display: block; margin-top: 8px; color: var(--muted); }
.metric-card .positive { color: var(--positive); }
.metric-card .negative { color: var(--negative); }
.skeleton { position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.workspace { border: 1px solid var(--line); border-radius: 26px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); overflow-x: auto; }
.tab-button { padding: 12px 16px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; white-space: nowrap; font-weight: 700; }
.tab-button.active { color: #05140f; background: var(--accent); }
.tab-panel { display: none; padding: clamp(18px, 3vw, 34px); }
.tab-panel.active { display: block; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.panel-heading h2 { margin: 4px 0 0; font-size: clamp(1.5rem, 2.5vw, 2.25rem); letter-spacing: -.04em; }
.details-heading { align-items: center; }

.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr)); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { color: var(--muted); font-size: .78rem; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; color: var(--text); background: var(--surface); outline: none; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(72, 213, 164, .10); }
.range-field input { padding: 0; accent-color: var(--accent); }
.ticker-select { min-width: 200px; }
.table-summary { display: flex; justify-content: space-between; gap: 16px; margin: 18px 4px 10px; color: var(--muted); font-size: .83rem; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; min-width: 1020px; border-collapse: collapse; }
th, td { padding: 14px 15px; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; z-index: 2; color: var(--muted); background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; cursor: pointer; }
tbody tr { transition: background .16s ease; cursor: pointer; }
tbody tr:hover { background: rgba(72, 213, 164, .055); }
tbody tr:last-child td { border-bottom: 0; }
.ticker-cell strong { display: block; }
.ticker-cell small { color: var(--muted); }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.signal-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 74px; padding: 7px 10px; border-radius: 999px; font-size: .73rem; font-weight: 900; letter-spacing: .04em; }
.signal-buy { color: #03150e; background: var(--positive); }
.signal-hold { color: #1c1302; background: var(--warning); }
.signal-sell, .signal-avoid { color: #fff; background: var(--negative); }
.confidence-bar { width: 100px; height: 6px; margin-top: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.confidence-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; }
.empty-state { padding: 42px 20px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.hidden { display: none !important; }

.buy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.list-card, .content-card, .chart-card { border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2); overflow: hidden; }
.list-card { padding: 18px; }
.list-card-title, .card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-card-title h3, .card-heading h3 { margin: 0; }
.card-heading { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-heading span { color: var(--muted); font-size: .8rem; }
.count-pill { min-width: 30px; padding: 5px 8px; border-radius: 999px; color: #05140f; background: var(--accent); text-align: center; font-weight: 900; }
.signal-list { display: grid; gap: 10px; margin-top: 16px; }
.signal-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); cursor: pointer; }
.signal-item:hover { border-color: rgba(72, 213, 164, .5); }
.signal-item strong, .signal-item small { display: block; }
.signal-item small { margin-top: 4px; color: var(--muted); }
.signal-item b { color: var(--accent); }

.detail-loading { padding: 60px; text-align: center; color: var(--muted); }
.detail-summary { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(340px, .6fr); gap: 16px; }
.detail-callout { display: flex; justify-content: space-between; gap: 24px; min-height: 180px; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(135deg, var(--surface-2), var(--surface-3)); }
.detail-callout h3 { margin: 16px 0 9px; font-size: 1.45rem; }
.detail-callout p { margin: 0; color: var(--muted); line-height: 1.6; }
.confidence-ring { flex: 0 0 auto; display: grid; place-content: center; width: 108px; height: 108px; border-radius: 50%; background: conic-gradient(var(--accent) var(--confidence, 0%), var(--surface) 0); position: relative; }
.confidence-ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface-2); }
.confidence-ring strong, .confidence-ring small { position: relative; z-index: 1; text-align: center; }
.confidence-ring strong { font-size: 1.7rem; }
.confidence-ring small { color: var(--muted); }
.mini-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mini-metric { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); }
.mini-metric span, .mini-metric small { display: block; color: var(--muted); }
.mini-metric strong { display: block; margin: 7px 0 3px; font-size: 1.25rem; }
.chart-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .75fr); gap: 16px; margin-top: 16px; }
.chart { min-height: 370px; }
.small-chart { min-height: 280px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.risk-list { margin: 0; padding: 18px 22px 22px 40px; }
.risk-list li { margin: 9px 0; color: var(--muted); line-height: 1.5; }
.fundamentals { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; padding: 8px 20px 18px; }
.fundamentals div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.fundamentals dt { color: var(--muted); font-size: .78rem; }
.fundamentals dd { margin: 5px 0 0; font-weight: 700; }
.news-card { margin-top: 16px; }
.news-list { display: grid; }
.news-item { display: grid; grid-template-columns: 1fr auto; gap: 18px; padding: 17px 20px; border-bottom: 1px solid var(--line); text-decoration: none; }
.news-item:last-child { border-bottom: 0; }
.news-item:hover { background: rgba(72,213,164,.045); }
.news-item strong { display: block; line-height: 1.4; }
.news-item small { display: block; margin-top: 7px; color: var(--muted); }
.news-arrow { color: var(--accent); font-size: 1.25rem; }

.disclaimer { margin: 22px 0; padding: 20px 22px; border-left: 4px solid var(--warning); border-radius: 12px; background: rgba(255, 190, 92, .08); }
.disclaimer p { margin: 7px 0 0; color: var(--muted); line-height: 1.6; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0 36px; color: var(--muted); font-size: .78rem; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 340px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-3); box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .buy-grid { grid-template-columns: 1fr; }
  .detail-summary, .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  main, footer { width: min(100% - 22px, 1500px); }
  .updated-at { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 38px; }
  .hero-badge { min-width: 0; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { min-height: 112px; padding: 16px; }
  .filters { grid-template-columns: 1fr; }
  .panel-heading, .details-heading, .table-summary, footer { align-items: stretch; flex-direction: column; }
  .ticker-select { min-width: 0; }
  .detail-callout { flex-direction: column; }
  .confidence-ring { width: 92px; height: 92px; }
  .info-grid { grid-template-columns: 1fr; }
  .fundamentals { grid-template-columns: 1fr; }
  .news-item { grid-template-columns: 1fr; }
}
