*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

:root {
  --bg: #080c14; --surface: #111827; --border: rgba(255,255,255,0.06);
  --text: #edf2f9; --text-secondary: #9ca8b8; --text-muted: #6a7586;
  --accent: #2dd4bf; --accent-strong: #14b8a6;
  --accent-glow: rgba(45,212,191,0.18); --accent-soft: rgba(45,212,191,0.08);
  --warn: #f59e0b; --danger: #ef4444; --ok: #22c55e;
  --radius: 12px; --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: system-ui, -apple-system, sans-serif;
}

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

header {
  text-align: center; padding: 4rem 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(45,212,191,0.06) 0%, transparent 100%);
}
header h1 { font-size: 2.2rem; font-weight: 700; margin-bottom: 0.6rem; }
header .subtitle { color: var(--text-secondary); max-width: 620px; margin: 0 auto; font-size: 1rem; }

main { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Scan button ──────────────────────────────────────────── */
.scan-section { text-align: center; margin-bottom: 2rem; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.9rem 2rem; font-size: 1.05rem; font-weight: 600;
  background: var(--accent-strong); color: #021a16;
  border: none; border-radius: var(--radius);
  cursor: pointer; transition: all 0.25s ease;
  box-shadow: 0 4px 20px var(--accent-glow);
  font-family: var(--sans);
}
.btn-primary:hover { background: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 28px var(--accent-glow); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.status-text { display: block; margin-top: 0.75rem; color: var(--text-muted); font-size: 0.9rem; min-height: 1.4em; }

/* ── Results ───────────────────────────────────────────────── */
.results-section { display: flex; flex-direction: column; gap: 1.25rem; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.8rem;
}
.card h2 { font-size: 1.15rem; margin-bottom: 1rem; }

.summary { color: var(--text-secondary); font-size: 0.93rem; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

/* ── Badges ────────────────────────────────────────────────── */
.confidence-badge, .risk-badge {
  display: inline-block; padding: 0.2rem 0.7rem; border-radius: 6px;
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.75rem;
}
.confidence-badge.high { background: rgba(34,197,94,0.15); color: var(--ok); }
.confidence-badge.low { background: rgba(245,158,11,0.15); color: var(--warn); }
.confidence-badge.insufficient_data { background: rgba(156,163,175,0.1); color: var(--text-muted); }

.risk-badge.high { background: rgba(239,68,68,0.15); color: var(--danger); }
.risk-badge.medium { background: rgba(245,158,11,0.15); color: var(--warn); }
.risk-badge.low { background: rgba(34,197,94,0.15); color: var(--ok); }

/* ── Inferences / Findings ──────────────────────────────────── */
.inferences, .findings, .implications, .recommendations {
  display: flex; flex-direction: column; gap: 0.6rem;
}
.inference-item, .finding-item {
  padding: 0.7rem 1rem; border-radius: 8px; font-size: 0.9rem;
  border: 1px solid var(--border); background: rgba(255,255,255,0.02);
}
.inference-item .label, .finding-item .label { font-weight: 600; color: var(--text); margin-bottom: 0.2rem; }
.inference-item .detail, .finding-item .detail { color: var(--text-muted); font-size: 0.85rem; }
.inference-item .implication, .finding-item .rec { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.3rem; font-style: italic; }

.finding-item.severity-high { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.05); }
.finding-item.severity-warning { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.04); }
.finding-item.severity-info { border-color: rgba(45,212,191,0.15); }
.finding-item.severity-ok { border-color: rgba(34,197,94,0.15); }

/* ── Bands ──────────────────────────────────────────────────── */
.bands { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.band-item {
  flex: 1; min-width: 120px; text-align: center;
  padding: 0.8rem; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.band-item .band-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; }
.band-item .band-count { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.band-item .band-pct { font-size: 0.8rem; color: var(--text-secondary); }

/* ── Profile table ──────────────────────────────────────────── */
.profile-table { width: 100%; border-collapse: collapse; margin-bottom: 0.75rem; }
.profile-table td { padding: 0.4rem 0.8rem; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.profile-table td:first-child { color: var(--text-muted); width: 40%; }
.profile-table td:last-child { color: var(--text); font-weight: 500; }

/* ── Raw data ───────────────────────────────────────────────── */
.raw-section { margin-top: 1.5rem; }
.raw-section summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; }
.raw-section pre { margin-top: 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow-x: auto; font-family: var(--mono); font-size: 0.78rem; color: var(--text-secondary); max-height: 400px; overflow-y: auto; }

/* ── Bridge indicator ─────────────────────────────────────────── */
.bridge-indicator {
  margin-top: 0.6rem; font-size: 0.85rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.8rem; border-radius: 20px;
  border: 1px solid var(--border);
}
.bridge-checking { color: var(--text-muted); background: rgba(255,255,255,0.02); }
.bridge-active { color: #22c55e; background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.2); }
.bridge-inactive { color: var(--text-muted); background: rgba(255,255,255,0.02); }

/* ── Source badge ─────────────────────────────────────────────── */
.source-badge {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  padding: 0.15rem 0.55rem; border-radius: 4px; margin-left: 0.6rem;
  vertical-align: middle; text-transform: uppercase; letter-spacing: 0.04em;
}
.source-rich { color: #22c55e; background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.25); }
.source-basic { color: var(--text-muted); background: rgba(255,255,255,0.04); border: 1px solid var(--border); }

/* ── Footer ──────────────────────────────────────────────────── */
footer { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.82rem; border-top: 1px solid var(--border); margin-top: 2rem; }

/* ── Loading spinner ─────────────────────────────────────────── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--text-muted); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 0.4rem; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  header h1 { font-size: 1.6rem; }
  header { padding: 3rem 1rem 1.5rem; }
  main { padding: 1.5rem 1rem; }
  .card { padding: 1.2rem; }
  .bands { flex-direction: column; }
}