:root {
  color-scheme: light;
  font-family: "Inter", system-ui, sans-serif;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1b1f2a;
  --muted: #5f6b7a;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --border: #e3e7ef;
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 12px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3vw, 2.75rem);
}

.subtitle {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.6;
}

.stat-card {
  min-width: 220px;
  padding: 24px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-value {
  margin: 0 0 4px;
  font-size: 2rem;
  font-weight: 700;
}

.stat-change {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent);
}

.stat-card--inline {
  padding: 16px 20px;
  min-width: 200px;
  box-shadow: none;
}

.single-stats {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.etf-select {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--text);
  background: #fff;
  min-width: 120px;
}

.etf-ticker-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.etf-ticker-input {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--text);
  background: #fff;
  min-width: 140px;
}

.etf-ticker-button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.etf-ticker-button:hover {
  background: #0f766e;
}

.etf-holdings {
  margin-top: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.etf-holdings-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.etf-holdings-meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.etf-holdings-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.etf-holding {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
}

.etf-holding-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.etf-holding-metrics {
  display: flex;
  gap: 16px;
  text-align: right;
}

.etf-holding-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
  color: var(--muted);
}

.etf-holding-metric strong {
  font-size: 0.85rem;
  color: var(--text);
}

.etf-holding-rank {
  min-width: 24px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.etf-holding-ticker {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.etf-holding-name {
  font-size: 0.85rem;
  color: var(--muted);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

.tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.tab:hover {
  color: var(--text);
}

.tab-panel {
  display: none;
  gap: 24px;
}

.tab-panel.active {
  display: grid;
}

.chart-card {
  background: var(--card);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}

.chart-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.chart-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  min-width: 220px;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.control-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.segment {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.segment.active {
  background: var(--accent);
  color: #fff;
}

.segment:hover {
  color: var(--text);
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.ticker-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 999px;
}

.ticker-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ticker-form input {
  border: none;
  background: transparent;
  font-size: 0.9rem;
  min-width: 140px;
  outline: none;
  color: var(--text);
}

.ticker-form button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.ticker-form button:hover {
  filter: brightness(0.95);
}

.chart-body {
  position: relative;
  min-height: 320px;
}

.chart-body canvas {
  width: 100% !important;
  height: 320px !important;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-weight: 500;
}

.insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.insight-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.insight-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
  color: var(--text);
}

.db-tools {
  display: block;
}

.db-card {
  background: var(--card);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.db-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.db-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.db-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.db-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.db-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--muted);
}

.db-controls input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
}

.db-action {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.db-action:hover {
  filter: brightness(0.95);
}

.db-action.danger {
  background: #ef4444;
}

.db-output {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  min-height: 140px;
  position: relative;
}

.db-status {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 12px;
}

.db-output pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.5;
}

@media (max-width: 720px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .tabs {
    width: 100%;
    flex-wrap: wrap;
  }

  .single-stats {
    justify-content: flex-start;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-controls {
    width: 100%;
    align-items: flex-start;
  }

  .control-group {
    align-items: flex-start;
  }

  .ticker-form {
    width: 100%;
    flex-wrap: wrap;
  }

  .ticker-form input {
    flex: 1;
  }

  .stat-card {
    width: 100%;
  }

  .db-controls {
    grid-template-columns: 1fr;
  }
}
