:root {
  --bg: #0b0e14;
  --panel: #131722;
  --panel-2: #1a1f2e;
  --border: #272e3f;
  --text: #e8ecf4;
  --text-dim: #93a0b8;
  --accent: #4f8cff;
  --good: #2ecc71;
  --warning: #f5a623;
  --critical: #ff4d5e;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.topbar {
  text-align: center;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
}

.brand-mark {
  color: var(--accent);
  font-size: 26px;
}

.tagline {
  color: var(--text-dim);
  margin-top: 6px;
  font-size: 15px;
}

.search-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

#audit-form {
  display: flex;
  gap: 10px;
}

#url-input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

#url-input:focus {
  border-color: var(--accent);
}

#audit-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

#audit-btn:hover { opacity: .9; }
#audit-btn:disabled { opacity: .5; cursor: not-allowed; }

.error-box {
  margin-top: 14px;
  background: rgba(255, 77, 94, 0.1);
  border: 1px solid rgba(255, 77, 94, 0.4);
  color: #ffb3ba;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.hidden { display: none !important; }

.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-dim);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- score hero ---- */
.score-hero {
  display: flex;
  gap: 28px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.score-dial {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

.dial-svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.dial-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.dial-fill {
  fill: none;
  stroke: var(--critical);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 1s ease, stroke 0.3s;
}

.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dial-score { font-size: 34px; font-weight: 800; line-height: 1; }
.dial-grade { font-size: 14px; color: var(--text-dim); margin-top: 4px; font-weight: 600; }

.score-summary { flex: 1; min-width: 260px; }
.score-summary h2 { margin: 0 0 6px; font-size: 22px; word-break: break-word; }
.score-headline { color: var(--text-dim); margin: 0 0 14px; font-size: 15px; }

.pill-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

.pill {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.pill strong { margin-right: 4px; }
.pill-critical { color: var(--critical); border-color: rgba(255,77,94,0.4); }
.pill-warning { color: var(--warning); border-color: rgba(245,166,35,0.4); }
.pill-good { color: var(--good); border-color: rgba(46,204,113,0.4); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- sections ---- */
.section-block { margin-bottom: 32px; }
.section-title { font-size: 19px; margin: 0 0 4px; }
.section-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 16px; }

.issue-list { display: flex; flex-direction: column; gap: 12px; }

.issue-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--critical);
  border-radius: 10px;
  padding: 16px 18px;
}

.issue-card.warning { border-left-color: var(--warning); }

.issue-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.issue-title { font-weight: 700; font-size: 15px; }

.issue-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.issue-badge.critical { background: rgba(255,77,94,0.15); color: var(--critical); }
.issue-badge.warning { background: rgba(245,166,35,0.15); color: var(--warning); }

.issue-detail { color: var(--text-dim); font-size: 14px; margin: 4px 0; }

.issue-impact {
  font-size: 14px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.issue-impact-label {
  font-weight: 700;
  color: var(--text);
  margin-right: 4px;
}

.issue-fix {
  font-size: 13px;
  color: var(--accent);
  margin-top: 6px;
}

/* ---- category grid ---- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.category-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
}

.category-card-title { font-weight: 700; font-size: 15px; }

.category-score {
  font-weight: 800;
  font-size: 15px;
}

.bar-track {
  height: 6px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}

.check-row:first-of-type { border-top: none; }

.check-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
}

.check-icon.good { background: rgba(46,204,113,0.18); color: var(--good); }
.check-icon.warning { background: rgba(245,166,35,0.18); color: var(--warning); }
.check-icon.critical { background: rgba(255,77,94,0.18); color: var(--critical); }
.check-icon.info { background: rgba(147,160,184,0.18); color: var(--text-dim); }

.check-body { flex: 1; }
.check-title { font-weight: 600; }
.check-detail { color: var(--text-dim); margin-top: 1px; }

.report-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 20px;
}

@media (max-width: 560px) {
  #audit-form { flex-direction: column; }
  .score-hero { flex-direction: column; text-align: center; }
  .pill-row { justify-content: center; }
}

@media print {
  body { background: white; color: #111; }
  .search-panel, #print-btn { display: none !important; }
  .issue-card, .category-card, .score-hero { border-color: #ccc !important; background: #fff !important; }
  .issue-detail, .section-sub, .check-detail, .tagline { color: #444 !important; }
}
