:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #262b36;
  --text: #e6e9ef;
  --muted: #8b93a7;
  --good: #34c759;
  --warn: #ffb020;
  --bad: #ff3b30;
  --accent: #7aa2f7;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-2: #f0f2f5;
    --border: #e1e4ea;
    --text: #1a1d23;
    --muted: #5c6577;
    --accent: #2a5bd7;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
header h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.meta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 13px; }
.meta a { color: var(--accent); text-decoration: none; }
.meta a:hover { text-decoration: underline; }
.meta button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 14px;
}
.meta button:hover { color: var(--text); border-color: var(--accent); }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }
section { margin-bottom: 32px; }
section h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.card-head .name {
  font-weight: 600;
  font-size: 16px;
}
.card-head .url {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  font-family: var(--mono);
}
.card-head .url:hover { text-decoration: underline; }

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.metric {
  background: var(--panel-2);
  border-radius: 7px;
  padding: 10px 12px;
}
.metric .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.metric .value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric .sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad  { background: var(--bad); }
.dot.off  { background: var(--muted); opacity: 0.5; }

.psi-pair {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 15px;
}
.psi-pair .tag {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.spark {
  width: 100%;
  height: 48px;
  display: block;
}
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark path.area { fill: var(--accent); opacity: 0.15; }

.trend-card { padding: 14px 16px; }
.trend-card .trend-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.trend-card .trend-sub { font-size: 11px; color: var(--muted); margin-bottom: 8px; }

#audit-list ul { margin: 0; padding-left: 18px; }
#audit-list li { margin: 4px 0; }
#audit-list a { color: var(--accent); text-decoration: none; }
#audit-list a:hover { text-decoration: underline; }

/* --- PSI block (PageSpeed stacked rows inside site card) --- */
.psi-block {
  background: var(--panel-2);
  border-radius: 7px;
  padding: 10px 12px;
}
.psi-block > .label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.psi-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  column-gap: 10px;
  align-items: center;
  padding: 3px 0;
}
.psi-row + .psi-row {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 3px;
}
.psi-strat {
  grid-row: 1 / 3;
  align-self: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.psi-values {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.psi-values.err { color: var(--bad); font-weight: 400; font-size: 13px; }
.psi-pair-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.psi-pair-inline .tag {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-left: 1px;
}
.psi-sub {
  grid-column: 2;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 2px;
}

/* --- Sparkline placeholder for <2 data points --- */
.spark-placeholder {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 0 8px;
  text-align: center;
}

/* --- Featured section (used for the SEO audits block) --- */
section.featured {
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.06), transparent 70%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 20px 22px;
}
section.featured .section-head { margin-bottom: 14px; }
section.featured h2 {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
section.featured .section-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* --- Audit cards (larger, featured tiles) --- */
#audit-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
#audit-list .sub {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}
.audit-card {
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  padding: 18px 20px;
  min-height: 130px;
  gap: 14px;
}
.audit-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(122, 162, 247, 0.15);
}
.audit-card .audit-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.audit-card .audit-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.audit-card .audit-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.audit-card .audit-name {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.3;
}
.audit-card .audit-date {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}
.audit-card .audit-cta {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  margin-top: auto;
  padding-top: 4px;
}

footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.error {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.3);
  color: var(--bad);
  padding: 12px 16px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
}
