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

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --red: #dc2626;
  --orange: #ea580c;
  --amber: #d97706;
  --green: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.6;
  font-size: 15px;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  padding: 3rem 1.5rem 2.5rem;
}
.header-inner {
  max-width: 760px;
  margin: 0 auto;
}
.site-header h1 {
  margin: 0 0 .5rem;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.02em;
}
.site-header p {
  margin: 0;
  color: #94a3b8;
  font-size: .95rem;
  max-width: 540px;
  line-height: 1.6;
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}
.card h2 {
  margin: 0 0 1.1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Form ────────────────────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: .5rem;
  font-size: .9rem;
  color: #334155;
}
.input-row {
  display: flex;
  gap: .5rem;
}
#url-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .65rem 1rem;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
  color: var(--text);
}
#url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
#analyze-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .65rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
  font-family: inherit;
}
#analyze-btn:hover { background: var(--accent-hover); }
#analyze-btn:active { transform: scale(.98); }
#analyze-btn:disabled { background: #94a3b8; cursor: not-allowed; }
.form-hint {
  margin: .5rem 0 0;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Progress ────────────────────────────────────────────────────────────────── */
.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: .5rem;
  font-size: .85rem;
  font-weight: 600;
  color: #334155;
}
.progress-track {
  background: #e2e8f0;
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 99px;
  transition: width .4s ease;
  width: 0%;
}

/* ── Error ───────────────────────────────────────────────────────────────────── */
.error-card {
  border-color: #fca5a5;
  background: #fff5f5;
}
.error-card strong { color: var(--red); }
.error-card p { margin: .4rem 0 .8rem; color: #7f1d1d; font-size: .9rem; }

/* ── Scores grid ─────────────────────────────────────────────────────────────── */
.scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 560px) { .scores-grid { grid-template-columns: 1fr; } }

.score-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  text-align: center;
}
.score-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.gauge-canvas { display: block; }
.score-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin-top: -.3rem;
}
.score-grade {
  font-size: .9rem;
  font-weight: 700;
  margin-top: .1rem;
}
.score-sub {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── Stat grid ───────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.stat {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
}
.stat .s-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.stat .s-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.2;
  margin-top: .1rem;
}
.stat .s-sub { font-size: .75rem; color: #94a3b8; }

/* ── Download ────────────────────────────────────────────────────────────────── */
.download-card { text-align: center; }
.download-btns { display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap; }
.btn-download {
  display: inline-block;
  background: var(--green);
  color: #fff;
  padding: .6rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  transition: opacity .15s;
}
.btn-download:hover { opacity: .85; }
.btn-download-secondary { background: #475569; }

/* ── Recommendations ─────────────────────────────────────────────────────────── */
.rec-card {
  border-left: 4px solid #94a3b8;
  background: #f8fafc;
  border-radius: 6px;
  padding: 1rem 1.1rem;
  margin-bottom: .8rem;
}
.rec-card.critical { border-color: var(--red); background: #fff5f5; }
.rec-card.high     { border-color: var(--orange); background: #fff8f5; }
.rec-card.medium   { border-color: var(--amber); background: #fffbf0; }
.rec-card.low      { border-color: var(--accent); background: #f0f6ff; }
.rec-header { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .4rem; }
.rec-title { font-weight: 700; font-size: .92rem; flex: 1; }
.rec-detail { font-size: .85rem; color: #334155; line-height: 1.55; }
.rec-alts { margin-top: .6rem; }
.rec-alts strong { font-size: .82rem; display: block; margin-bottom: .25rem; }
.rec-alts ul { margin: 0; padding-left: 1.2rem; font-size: .83rem; }
.rec-alts li { margin: .2rem 0; }
.rec-alts a { color: var(--accent); }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table thead th {
  background: #f8fafc;
  padding: .45rem .75rem;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 700;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:not(:last-child) td { border-bottom: 1px solid #f1f5f9; }
.data-table td { padding: .4rem .75rem; vertical-align: middle; }
.text-right { text-align: right !important; }
.text-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .8rem; }

/* ── Tracker category badge ──────────────────────────────────────────────────── */
.cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  text-transform: capitalize;
}

/* ── Severity badge ──────────────────────────────────────────────────────────── */
.sev-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .68rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.sev-critical { background: var(--red); }
.sev-high     { background: var(--orange); }
.sev-medium   { background: var(--amber); }
.sev-low      { background: var(--accent); }

/* ── Progress bar (inline) ───────────────────────────────────────────────────── */
.bar-wrap { background: #e5e7eb; border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-label { font-size: .73rem; color: var(--text-muted); margin-top: 2px; }

/* ── Note box ────────────────────────────────────────────────────────────────── */
.note {
  background: #fefce8;
  border: 1px solid #fef08a;
  border-radius: 6px;
  padding: .55rem .9rem;
  font-size: .8rem;
  color: #713f12;
  margin-bottom: 1rem;
}

/* ── Badge (count pill) ──────────────────────────────────────────────────────── */
.badge {
  background: #e2e8f0;
  color: #475569;
  border-radius: 9999px;
  padding: 1px 9px;
  font-size: .75rem;
  font-weight: 700;
}

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.empty-state { text-align: center; color: var(--text-muted); padding: 1.5rem; }

.btn-secondary {
  background: transparent;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: .45rem 1rem;
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
  color: #334155;
  transition: background .15s;
}
.btn-secondary:hover { background: #f1f5f9; }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: .78rem;
  padding: 2rem 1.5rem;
  margin-top: 1rem;
}
