/* Interactive web report (dashboard) — loaded on /reports/:token and on the
   owner's /audit/:id/report. Reuses app.css design tokens so growthai (blue)
   and insightpath (violet) theme automatically. The PDF template is untouched.

   Layout intent: a dense analytics console (metric band → charts → data
   tables) rather than a stack of prose cards. Everything below is scoped
   under .rd so it can never leak into the marketing pages. */

.rd {
  /* Local semantic palette — the pillar/position/severity colours are shared
     by markup, charts and badges, so they live in one place. */
  --rd-good:  #16a34a;
  --rd-warn:  #ea580c;
  --rd-bad:   #dc2626;
  --rd-flat:  #64748b;
  --rd-line:  var(--border);
  --rd-surface: var(--card, #fff);
  /* Site header is sticky (≈58px); the tab bar parks just under it. */
  --rd-sticky-top: 58px;

  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 20px 72px;
}

/* Report status badges are semantic states, not just decorative labels. The
   dashboard uses the same OK / Issue / Notice vocabulary as the PDF table. */
.rd .tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.rd .tag.verified { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.rd .tag.issue { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.rd .tag.notice { color: #92400e; border-color: #fde68a; background: #fffbeb; }

/* ── Top bar ────────────────────────────────────────────────────────── */
.rd-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
  padding: 22px 26px;
  background: var(--rd-surface);
  border: 1px solid var(--rd-line);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));
}
.rd-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
}
.rd-eyebrow::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.rd-domain {
  margin: 0;
  font-family: var(--font-display, inherit);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--ink);
  word-break: break-word;
}
.rd-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
}
.rd-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary, #334155);
  background: var(--bg);
  border: 1px solid var(--rd-line);
  border-radius: 999px;
}
.rd-chip svg { opacity: .6; }

.rd-top-right {
  display: flex;
  align-items: center;
  gap: 22px;
}

/* Score donut — SVG, server-rendered, animated on load. */
.rd-score { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rd-donut { width: 104px; height: 104px; display: block; }
.rd-donut circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.rd-donut-track { stroke: var(--border-light, #f1f5f9); }
.rd-donut-val {
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  animation: rd-donut-in 1s cubic-bezier(.22,.8,.3,1) both;
}
@keyframes rd-donut-in { from { stroke-dashoffset: 327; } }
@media (prefers-reduced-motion: reduce) { .rd-donut-val { animation: none; } }
.rd-donut-num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.rd-donut-out { font-size: 11px; font-weight: 600; fill: var(--muted); }
.rd-score-label { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; max-width: 130px; }

.rd-actions { display: flex; flex-direction: column; gap: 8px; }
.rd-export, .rd-share { display: inline-flex; align-items: center; gap: 8px; justify-content: center; white-space: nowrap; }
.btn-ghost {
  background: var(--rd-surface);
  color: var(--ink-secondary, #334155);
  border: 1px solid var(--rd-line);
}
.btn-ghost:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.rd-share.is-copied { color: var(--rd-good); border-color: var(--rd-good); background: rgba(22,163,74,.06); }

/* ── Tabs ───────────────────────────────────────────────────────────── */
.rd-tabs {
  position: sticky;
  top: var(--rd-sticky-top);
  z-index: 20;
  display: flex;
  gap: 4px;
  margin: 18px 0 4px;
  padding: 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rd-line);
}
.rd-tabs::-webkit-scrollbar { display: none; }
.rd-tabs a {
  position: relative;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.rd-tabs a:hover { color: var(--ink); }
.rd-tabs a.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Sections ───────────────────────────────────────────────────────── */
.rd-section { margin-top: 36px; scroll-margin-top: calc(var(--rd-sticky-top) + 60px); }
.rd-sec-head { margin: 0 0 14px; }
.rd-h2 {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0;
  font-size: 19px; font-weight: 700; letter-spacing: -.01em;
  color: var(--ink);
}
.rd-hint { margin: 6px 0 0; max-width: 78ch; font-size: 13px; color: var(--muted); }

/* Cards */
.rd-card {
  background: var(--rd-surface);
  border: 1px solid var(--rd-line);
  border-radius: var(--radius, 12px);
  padding: 0;
  overflow: hidden;
}
.rd-card:hover { box-shadow: none; }
.rd-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rd-line);
}
.rd-h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.rd-card-body { padding: 18px; }
.rd-card + .rd-card { margin-top: 18px; }
.rd-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* ── Metric band (Semrush-style KPI strip) ──────────────────────────── */
.rd-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--rd-surface);
  border: 1px solid var(--rd-line);
  border-radius: var(--radius, 12px);
  overflow: hidden;
  margin-bottom: 18px;
}
.rd-metric { padding: 16px 20px; border-inline-start: 1px solid var(--rd-line); }
.rd-metric:first-child { border-inline-start: 0; }
.rd-metric-label {
  display: block;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted);
}
.rd-metric-num {
  display: block; margin-top: 8px;
  font-size: 26px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.rd-metric-num.is-good { color: var(--rd-good); }
.rd-metric-num.is-warn { color: var(--rd-warn); }
.rd-metric-num.is-bad  { color: var(--rd-bad); }
.rd-metric-num.is-brand { color: var(--primary); }

/* ── Pillar bars ────────────────────────────────────────────────────── */
.rd-pillars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rd-pillar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.rd-pl-name { font-size: 13px; font-weight: 600; color: var(--ink-secondary, #334155); }
.rd-pl-val { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rd-pl-val i { font-size: 11px; font-weight: 500; color: var(--muted); font-style: normal; }
.rd-track { height: 6px; background: var(--border-light, #f1f5f9); border-radius: 999px; overflow: hidden; }
.rd-track > span { display: block; height: 100%; border-radius: 999px; transition: width .7s cubic-bezier(.22,.8,.3,1); }
.rd-radar { min-height: 250px; }
.rd-trend { min-height: 300px; }
.rd-bubble { min-height: 420px; }

/* ── Severity ───────────────────────────────────────────────────────── */
.rd-sev { display: flex; flex-direction: column; gap: 14px; }
.rd-sev-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 12px; }
.rd-sev-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-secondary, #334155); }
.rd-sev-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rd-sev-track { height: 8px; background: var(--border-light, #f1f5f9); border-radius: 999px; overflow: hidden; }
.rd-sev-bar { height: 100%; border-radius: 999px; transition: width .7s cubic-bezier(.22,.8,.3,1); }
.rd-sev-num {
  min-width: 30px; text-align: center;
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.rd-sev-total { display: flex; align-items: baseline; gap: 8px; }
.rd-sev-total b { font-size: 22px; font-weight: 800; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.rd-table-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--rd-line);
  flex-wrap: wrap;
}
.rd-search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.rd-search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.rd input.rd-filter {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--rd-line);
  border-radius: var(--radius, 10px);
  font-size: 14px; font-family: inherit;
  background: var(--bg); color: var(--ink);
}
[dir="rtl"] .rd input.rd-filter { padding: 10px 40px 10px 14px; }
.rd input.rd-filter:focus { outline: 2px solid var(--primary); outline-offset: 1px; background: var(--rd-surface); }
.rd-count { white-space: nowrap; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.rd-table-wrap { overflow-x: auto; }
.rd-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rd-table th, .rd-table td { padding: 11px 18px; text-align: start; border-bottom: 1px solid var(--border-light, #f1f5f9); }
.rd-table thead th {
  background: var(--bg);
  border-bottom: 1px solid var(--rd-line);
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.rd-table tbody tr:last-child td { border-bottom: 0; }
.rd-table tbody tr:hover { background: var(--primary-50, rgba(37,99,235,.05)); }
.rd-table .rd-num { text-align: end; font-variant-numeric: tabular-nums; }
.rd-kwcell { font-weight: 600; color: var(--ink); }
.rd-url { color: var(--muted); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.rd-dim { color: var(--muted); }
.rd-sortable { cursor: pointer; user-select: none; }
.rd-sortable::after { content: '↕'; opacity: .35; margin-inline-start: 6px; font-size: 10px; }
.rd-sortable[aria-sort="ascending"]::after { content: '↑'; opacity: 1; color: var(--primary); }
.rd-sortable[aria-sort="descending"]::after { content: '↓'; opacity: 1; color: var(--primary); }
.rd-source { margin: 12px 2px 0; max-width: 88ch; font-size: 12px; color: var(--muted); }

/* Position badge */
.rd-pos {
  display: inline-block; min-width: 30px; padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 800; text-align: center;
  font-variant-numeric: tabular-nums;
}
.rd-pos-top3 { color: #15803d; background: rgba(22,163,74,.12); }
.rd-pos-top10 { color: #c2410c; background: rgba(234,88,12,.12); }
.rd-pos-rest { color: var(--rd-flat); background: rgba(100,116,139,.12); }

/* Intent pill */
.rd-intent {
  display: inline-block; padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px; font-weight: 700;
  white-space: nowrap;
}
.rd-intent-transactional { color: #b45309; background: rgba(245,158,11,.14); }
.rd-intent-commercial    { color: #6d28d9; background: rgba(139,92,246,.14); }
.rd-intent-navigational  { color: #0369a1; background: rgba(14,165,233,.14); }
.rd-intent-informational { color: #475569; background: rgba(100,116,139,.14); }

/* Difficulty micro-bar */
.rd-kd { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.rd-kd-track { width: 46px; height: 5px; border-radius: 999px; background: var(--border-light, #f1f5f9); overflow: hidden; }
.rd-kd-track > span { display: block; height: 100%; border-radius: 999px; }
.rd-kd-val { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 22px; text-align: end; }

/* Row-limited tables ("show all") */
.rd-collapsed tbody tr.is-over { display: none; }
/* The keyword table hides rows with the `hidden` attribute (its cut is
   recomputed after each sort); make sure table display rules never win. */
.rd-table tbody tr[hidden] { display: none; }
.rd-more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--rd-line); background: var(--bg); }
.rd-more button {
  font: inherit; font-size: 13px; font-weight: 700;
  color: var(--primary); background: transparent;
  border: 1px solid var(--rd-line); border-radius: 999px;
  min-height: 44px; padding: 8px 20px; cursor: pointer;
}
.rd-more button:hover { background: var(--primary-50, rgba(37,99,235,.06)); border-color: var(--primary); }

/* Empty state */
.rd-empty { padding: 28px 18px; text-align: center; font-size: 13px; color: var(--muted); }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .rd-grid-2 { grid-template-columns: 1fr; }
  .rd-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rd-metric:nth-child(3) { border-inline-start: 0; }
  .rd-metric:nth-child(n+3) { border-top: 1px solid var(--rd-line); }
}
@media (max-width: 760px) {
  .rd { padding: 14px 14px 56px; }
  .rd-top { grid-template-columns: 1fr; gap: 20px; }
  .rd-top-right { justify-content: space-between; }
  .rd-actions { flex-direction: row; }
  .rd-domain { font-size: 24px; }
  .rd-table th, .rd-table td { padding: 10px 12px; }
  .rd input.rd-filter { font-size: 16px; }
}
@media (max-width: 460px) {
  .rd-metrics { grid-template-columns: 1fr; }
  .rd-metric { border-inline-start: 0; }
  .rd-metric + .rd-metric { border-top: 1px solid var(--rd-line); }
  .rd-top-right { flex-direction: column; align-items: stretch; gap: 16px; }
  .rd-actions { flex-direction: column; }
}

/* ── Keyboard & motion ──────────────────────────────────────────────── */
.rd a:focus-visible,
.rd button:focus-visible,
.rd th.rd-sortable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}
.rd-tabs a:focus-visible { outline-offset: -3px; }

@media (prefers-reduced-motion: reduce) {
  .rd-track > span, .rd-sev-bar { transition: none; }
}

/* RTL: logical properties handle most of it; keep numeric columns readable. */
[dir="rtl"] .rd-kd { justify-content: flex-start; }
