:root {
  --bg: #0a0a0f;
  --bg-elev: #12121a;
  --bg-elev-2: #1a1a24;
  --bg-elev-3: #22222e;
  --fg: #e4e4ec;
  --muted: #7a7a88;
  --border: #2a2a34;
  --accent: #6c8aff;
  --accent-dim: #4a62cc;
  --grade-a: #3dd68c;
  --grade-b: #6c8aff;
  --grade-bp: #8da4ff;
  --grade-c: #ffca62;
  --grade-d: #ff8c5a;
  --grade-f: #f06292;
  --grade-na: #7a7a88;
  --radius: 8px;
  --radius-lg: 12px;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.logo .icon { font-size: 20px; }
.logo span { color: var(--accent); }

nav { display: flex; gap: 4px; }
nav a {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
nav a:hover, nav a.active {
  color: var(--fg);
  background: var(--bg-elev-2);
  text-decoration: none;
}

/* ── Container ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Audit Input ── */
.audit-form {
  display: flex;
  gap: 12px;
  max-width: 700px;
  margin: 0 auto 32px;
}
.audit-input {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 15px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.15s;
}
.audit-input:focus { border-color: var(--accent); }
.audit-input::placeholder { color: var(--muted); }

.btn {
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-dim); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
}
.btn-ghost:hover { background: var(--bg-elev-2); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 48px 0 16px;
}
.hero h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 12px;
}
.hero h1 span { color: var(--accent); }
.hero p {
  color: var(--muted);
  font-size: 16px;
  max-width: 560px;
  margin: 0 auto 32px;
}

/* ── Grade Badge ── */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 800;
  font-family: var(--font-mono);
  border: 3px solid;
}
.grade-badge.sm { width: 36px; height: 36px; font-size: 14px; border-width: 2px; }
.grade-badge.xs { width: 28px; height: 28px; font-size: 11px; border-width: 2px; }
.grade-A { color: var(--grade-a); border-color: var(--grade-a); background: rgba(61,214,140,0.1); }
.grade-Bp { color: var(--grade-bp); border-color: var(--grade-bp); background: rgba(141,164,255,0.1); }
.grade-B { color: var(--grade-b); border-color: var(--grade-b); background: rgba(108,138,255,0.1); }
.grade-C { color: var(--grade-c); border-color: var(--grade-c); background: rgba(255,202,98,0.1); }
.grade-D { color: var(--grade-d); border-color: var(--grade-d); background: rgba(255,140,90,0.1); }
.grade-F { color: var(--grade-f); border-color: var(--grade-f); background: rgba(240,98,146,0.1); }
.grade-NA { color: var(--grade-na); border-color: var(--grade-na); background: rgba(122,122,136,0.1); }

/* ── Result Card ── */
.result-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}
.result-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}
.result-meta { flex: 1; }
.result-meta h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}
.result-meta .url {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
}
.result-score {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Breakdown Table ── */
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.breakdown-table th,
.breakdown-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.breakdown-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.check-pass { color: var(--grade-a); }
.check-fail { color: var(--grade-f); }

/* ── Provider Row ── */
.provider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: background 0.15s;
}
.provider-row:hover { background: var(--bg-elev-2); }
.provider-info { flex: 1; }
.provider-name { font-weight: 600; font-size: 14px; }
.provider-desc { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── Alternatives Section ── */
.alternatives-section { margin-top: 24px; }
.alternatives-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--grade-a);
}
.alt-for {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

/* ── Section Headers ── */
.section-header {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Recent List ── */
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.recent-item:hover { background: var(--bg-elev-2); text-decoration: none; }
.recent-domain { font-family: var(--font-mono); font-size: 13px; flex: 1; }
.recent-providers { color: var(--muted); font-size: 12px; }
.recent-time { color: var(--muted); font-size: 11px; }

/* ── HN Stories ── */
.hn-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.hn-points {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  min-width: 44px;
  text-align: right;
}
.hn-title { font-size: 14px; flex: 1; }
.hn-meta { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 36px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}
.stat-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.grade-bar-chart { margin-top: 24px; }
.grade-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.grade-bar-label {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  min-width: 32px;
  text-align: right;
}
.grade-bar {
  height: 28px;
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.4s ease;
}
.grade-bar-count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

/* ── Provider Table ── */
.provider-table {
  width: 100%;
  border-collapse: collapse;
}
.provider-table th,
.provider-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.provider-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 56px;
  background: var(--bg);
}
.provider-table tr:hover td { background: var(--bg-elev); }

/* ── Share ── */
.share-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}
.share-url {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--accent);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Loading ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  text-align: center;
  padding: 48px 0;
  color: var(--muted);
}
.loading-state .spinner { width: 32px; height: 32px; margin-bottom: 16px; }

.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--muted);
}

/* ── Detected Provider Tag ── */
.detected-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  margin-right: 6px;
  margin-bottom: 6px;
}

/* ── Two Column Layout ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}
.two-col .main-col { min-width: 0; }
.two-col .side-col { min-width: 0; }

/* ── Responsive ── */
@media (max-width: 840px) {
  .two-col { grid-template-columns: 1fr; }
  .audit-form { flex-direction: column; }
  .result-header { flex-direction: column; text-align: center; }
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 12px 0; gap: 8px; }
  nav { flex-wrap: wrap; }
}
