:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a2e;
  --card: #16161f;
  --border: #2a2a3d;
  --text: #e8e8f0;
  --text2: #9999b3;
  --text3: #666680;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --green: #00c853;
  --green2: #69f0ae;
  --red: #ff1744;
  --red2: #ff5252;
  --yellow: #ffab00;
  --blue: #448aff;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

[data-theme="light"] {
  --bg: #f5f5fa;
  --bg2: #eeeef5;
  --bg3: #e0e0eb;
  --card: #ffffff;
  --border: #d0d0e0;
  --text: #1a1a2e;
  --text2: #555570;
  --text3: #8888a0;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
}
.logo-text { font-size: 15px; font-weight: 400; }
.logo-text strong { font-weight: 700; }

.search-wrapper {
  flex: 1;
  max-width: 500px;
  position: relative;
}
.search-wrapper input {
  width: 100%;
  padding: 8px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-wrapper input:focus { border-color: var(--accent); }
.search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  display: none;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
}
.search-results.active { display: block; }
.search-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}
.search-item:hover { background: var(--bg3); }
.search-item-name { font-weight: 500; font-size: 14px; }
.search-item-symbol { color: var(--text2); font-size: 12px; font-family: monospace; }

.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  width: 36px; height: 36px;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

/* Hero */
.hero {
  max-width: 720px;
  margin: 120px auto 60px;
  text-align: center;
  padding: 0 24px;
}
.hero h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent2), var(--green2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  color: var(--text2);
  font-size: 16px;
  margin-bottom: 32px;
}
.hero-search {
  display: flex;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto 24px;
}
.hero-search input {
  flex: 1;
  padding: 14px 20px;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.hero-search input:focus { border-color: var(--accent); }
.hero-search button {
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.hero-search button:hover { opacity: 0.9; }

.hero-examples {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hero-examples span { color: var(--text3); font-size: 13px; }
.chip {
  padding: 6px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }

/* Loading */
.loading {
  text-align: center;
  padding: 120px 24px;
}
.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--text2); }

/* Analysis */
.analysis {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.analysis-header {
  margin-bottom: 24px;
}
.analysis-header h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}
.analysis-header .subtitle {
  color: var(--text2);
  font-size: 14px;
}
.price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 8px;
}
.price-big {
  font-size: 36px;
  font-weight: 700;
}
.price-change {
  font-size: 16px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
}
.price-change.up { background: rgba(0,200,83,0.15); color: var(--green); }
.price-change.down { background: rgba(255,23,68,0.15); color: var(--red); }

/* Score Card */
.score-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  box-shadow: var(--shadow);
}
.score-circle {
  width: 120px; height: 120px;
  position: relative;
  flex-shrink: 0;
}
.score-circle svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.score-circle .track { fill: none; stroke: var(--bg3); stroke-width: 8; }
.score-circle .progress { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.score-number {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: 800;
}
.score-label { font-size: 11px; color: var(--text2); text-align: center; margin-top: -4px; }
.score-info { flex: 1; }
.score-signal {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.score-desc { color: var(--text2); font-size: 14px; margin-bottom: 12px; }
.score-fair-value { font-size: 14px; }
.score-fair-value strong { color: var(--accent2); font-size: 18px; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-full { margin-bottom: 24px; }
.card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .score-card { flex-direction: column; text-align: center; }
  .hero h1 { font-size: 26px; }
  .navbar { flex-wrap: wrap; }
  .search-wrapper { max-width: 100%; order: 3; flex-basis: 100%; }
}

/* Metric row */
.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.metric-row:last-child { border-bottom: none; }
.metric-label { color: var(--text2); }
.metric-value { font-weight: 600; font-family: 'Inter', monospace; }
.metric-value.positive { color: var(--green); }
.metric-value.negative { color: var(--red); }

/* Breakdown bars */
.breakdown-item {
  margin-bottom: 12px;
}
.breakdown-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.breakdown-label { color: var(--text2); }
.breakdown-score { font-weight: 600; }
.breakdown-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.breakdown-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* Chart */
.chart-container {
  width: 100%;
  height: 280px;
  position: relative;
}
.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}
.chart-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.chart-tab {
  padding: 4px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
}
.chart-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Valuation table */
.val-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.val-table th {
  text-align: left;
  color: var(--text2);
  font-weight: 500;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
}
.val-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.val-table tr:last-child td { border-bottom: none; }
.val-table .highlight { color: var(--accent2); font-weight: 600; }

/* Profile */
.profile-summary {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.7;
  max-height: 120px;
  overflow: hidden;
  transition: max-height 0.3s;
}
.profile-summary.expanded { max-height: 600px; }
.profile-tags {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.tag {
  padding: 4px 10px;
  background: var(--bg3);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text2);
}

/* Narrative */
.narrative-text {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-line;
}

/* Disclaimer */
.disclaimer {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* 52w range bar */
.range-bar-container { margin: 12px 0; }
.range-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
}
.range-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  position: relative;
}
.range-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  border-radius: 3px;
}
.range-marker {
  position: absolute;
  top: -4px;
  width: 14px; height: 14px;
  background: var(--text);
  border-radius: 50%;
  border: 2px solid var(--card);
  transform: translateX(-50%);
}
