:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #e8e8f0;
  --text2: #8888a0;
  --text3: #5a5a70;
  --accent: #60a5fa;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --s1: #0f6e56;
  --s1bg: #042c20;
  --s1txt: #6ee7b7;
  --s2: #3b6d11;
  --s2bg: #1a2e06;
  --s2txt: #a3e635;
  --s3: #92400e;
  --s3bg: #2d1500;
  --s3txt: #fbbf24;
  --s4: #991b1b;
  --s4bg: #2d0a0a;
  --s4txt: #fca5a5;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'IBM Plex Sans', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 300;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(10,10,15,0.9);
  backdrop-filter: blur(12px);
  z-index: 100;
}
.header-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: baseline; gap: 10px; }
.logo-mark { color: var(--accent); font-size: 18px; line-height: 1; }
.logo-text { font-family: var(--font-mono); font-weight: 500; font-size: 15px; letter-spacing: -0.02em; color: var(--text); }
.logo-tag { font-size: 11px; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; }
.provider-badge {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
  border: 1px solid var(--border2); border-radius: 4px; padding: 3px 8px;
  color: var(--text3);
}

/* ── Main ── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

/* ── Hero ── */
.hero { text-align: center; margin-bottom: 3rem; }
.hero-title {
  font-family: var(--font-mono); font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 400; letter-spacing: -0.03em; margin-bottom: 0.6rem;
}
.hero-sub { font-size: 14px; color: var(--text2); margin-bottom: 2rem; }

/* ── Search ── */
.search-form { margin-bottom: 1rem; }
.search-wrap {
  display: flex; align-items: stretch;
  max-width: 520px; margin: 0 auto;
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg2);
  transition: border-color 0.2s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon {
  display: flex; align-items: center; padding: 0 14px;
  font-family: var(--font-mono); font-size: 18px; color: var(--accent);
  background: var(--bg2);
}
.search-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font-mono); font-size: 18px; font-weight: 500;
  color: var(--text); letter-spacing: 0.05em; padding: 14px 8px;
  text-transform: uppercase;
}
.search-input::placeholder { color: var(--text3); font-weight: 400; text-transform: none; }
.search-btn {
  padding: 0 24px; background: var(--accent); border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.1em; color: #0a0a0f;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.15s;
}
.search-btn:hover { background: #93c5fd; }
.search-btn:disabled { background: var(--bg3); color: var(--text3); cursor: not-allowed; }
.btn-spinner {
  width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #0a0a0f; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.quick-tickers { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; }
.qt-label { font-size: 12px; color: var(--text3); }
.qt-btn {
  font-family: var(--font-mono); font-size: 11px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  background: transparent; color: var(--text2); cursor: pointer;
  transition: all 0.15s;
}
.qt-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Error ── */
.error-banner {
  background: var(--s4bg); border: 1px solid #7f1d1d;
  color: var(--s4txt); border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; margin-bottom: 2rem;
}

/* ── Results header ── */
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 12px;
}
.ticker-display { display: flex; align-items: baseline; gap: 12px; }
.res-ticker { font-family: var(--font-mono); font-size: 24px; font-weight: 500; letter-spacing: 0.05em; }
.res-price { font-family: var(--font-mono); font-size: 22px; color: var(--text2); }
.res-chg { font-family: var(--font-mono); font-size: 15px; }
.res-chg.up { color: var(--green); }
.res-chg.down { color: var(--red); }

.stage-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-radius: 20px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.stage-badge.s1 { background: var(--s1bg); color: var(--s1txt); border-color: var(--s1); }
.stage-badge.s2 { background: var(--s2bg); color: var(--s2txt); border-color: var(--s2); }
.stage-badge.s3 { background: var(--s3bg); color: var(--s3txt); border-color: var(--s3); }
.stage-badge.s4 { background: var(--s4bg); color: var(--s4txt); border-color: var(--s4); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; }
.s1 .badge-dot { background: var(--s1txt); }
.s2 .badge-dot { background: var(--s2txt); }
.s3 .badge-dot { background: var(--s3txt); }
.s4 .badge-dot { background: var(--s4txt); }

/* ── Metrics ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 1.5rem;
}
.metric {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.metric-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3); margin-bottom: 6px; }
.metric-value { font-family: var(--font-mono); font-size: 18px; font-weight: 500; color: var(--text); }
.metric-value.up { color: var(--green); }
.metric-value.down { color: var(--red); }
.metric-sub { font-size: 11px; color: var(--text3); margin-top: 3px; font-family: var(--font-mono); }

/* ── Chart ── */
.chart-section {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  margin-bottom: 1.5rem;
}
.chart-header { margin-bottom: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.leg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.leg-line { display: block; width: 20px; height: 2px; border-radius: 2px; }
.leg-dashed {
  width: 20px; height: 2px;
  background: repeating-linear-gradient(90deg, #fbbf24 0 4px, transparent 4px 7px);
}
.chart-wrap { position: relative; width: 100%; height: 280px; }
.volume-wrap { height: 80px; margin-top: 8px; }

/* ── Stage guide ── */
.stage-guide {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 1.5rem;
}
.sg {
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  opacity: 0.4; transition: opacity 0.3s, border-color 0.3s;
}
.sg.active { opacity: 1; }
.sg-num {
  font-family: var(--font-mono); font-size: 22px; font-weight: 500;
  margin-bottom: 4px;
}
.sg-name { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.sg-desc { font-size: 12px; color: var(--text2); line-height: 1.5; }
.sg-1 { border-color: var(--s1); }
.sg-1.active { background: var(--s1bg); border-color: var(--s1txt); }
.sg-1 .sg-num { color: var(--s1txt); }
.sg-2 { border-color: var(--s2); }
.sg-2.active { background: var(--s2bg); border-color: var(--s2txt); }
.sg-2 .sg-num { color: var(--s2txt); }
.sg-3 { border-color: var(--s3); }
.sg-3.active { background: var(--s3bg); border-color: var(--s3txt); }
.sg-3 .sg-num { color: var(--s3txt); }
.sg-4 { border-color: var(--s4); }
.sg-4.active { background: var(--s4bg); border-color: var(--s4txt); }
.sg-4 .sg-num { color: var(--s4txt); }

/* ── AI ── */
.ai-section {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  margin-bottom: 2rem;
}
.ai-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text3); margin-bottom: 14px;
}
.ai-icon { color: var(--accent); font-size: 14px; }
.ai-spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--border2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.ai-body {
  font-size: 15px; line-height: 1.75; color: var(--text);
  font-weight: 300; white-space: pre-wrap;
}
.ai-cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent); margin-left: 2px;
  animation: blink 1s steps(1) infinite;
  vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

.confidence-bar {
  height: 3px; border-radius: 2px;
  background: var(--border); margin-top: 14px; overflow: hidden;
}
.confidence-fill { height: 100%; border-radius: 2px; transition: width 0.8s ease; }
.confidence-label { font-size: 11px; color: var(--text3); margin-top: 6px; font-family: var(--font-mono); }

.results-footer {
  font-size: 12px; color: var(--text3); text-align: center;
  border-top: 1px solid var(--border); padding-top: 16px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .main { padding: 2rem 1rem 3rem; }
  .stage-guide { grid-template-columns: repeat(2, 1fr); }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .res-ticker { font-size: 18px; }
  .res-price { font-size: 17px; }
}
