/* ============================================================================
   Technical Audit — dedicated view (Commit E). Frontend only.
   All colours via tokens; accent family #6D28D9 only. No dark mode.
   Dynamic bar widths / donut arcs / trend points are set inline via JS .style
   (the documented dynamic-value exception) — never hardcoded here.
   ============================================================================ */

#view-audit { padding: 0; }
/* Consistent 24px vertical rhythm between every top-level block — one container-gap rule each, never
   per-element margins. .au-wrap spaces control bar / progress banner / results; #audit-results spaces
   its own children (banners, overview grid, each section card). A hidden progress banner (display:none)
   collapses its gap automatically. */
.au-wrap { display: flex; flex-direction: column; gap: 24px; max-width: 1240px; margin: 0 auto; }
#audit-results { display: flex; flex-direction: column; gap: 24px; }

/* One consistent card: 16px radius, hairline border, soft shadow, roomy padding. */
.au-card {
  border: 1px solid var(--border); border-radius: 16px; background: var(--bg);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}

/* Section header — small accent icon-chip + title + muted subtitle. Own breathing room: the card's
   20px top padding + this 14px top margin ≈ the mockup's 34px above the title; 14px below it. */
.au-sec-head { display: flex; align-items: center; gap: 11px; margin: 14px 0 14px; }
.au-sec-head__chip {
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 8px;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.au-sec-head__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.au-sec-head__title { font-size: 14.5px; font-weight: 700; color: var(--text); line-height: 1.2; }
.au-sec-head__sub { font-size: 12px; color: var(--text-muted); }
/* Overview mini-cards: header flush to the card top (skip the section 14px top margin). */
.au-summary .au-sec-head { margin-top: 0; }

/* Bigger section-group head (h2 + subtitle) — the mockup "sect-title" pattern. */
.au-sect-head { margin: 14px 0 14px; }
.au-sect-head__title { font-size: 16px; font-weight: 750; color: var(--text); line-height: 1.2; margin: 0; }
.au-sect-head__sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* Section nav — pill chips under the head row. */
.au-secnav { display: flex; flex-wrap: wrap; gap: 8px; }
.au-secnav__chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; padding: 6px 13px; border-radius: 999px; cursor: pointer;
}
.au-secnav__chip:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent-light); }

/* Provenance footnotes — mono, muted (CWV section + results honesty footer). */
.au-cwv__foot,
.au-foot {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px; line-height: 1.55; color: var(--text-muted);
}
.au-cwv__foot { margin-top: 14px; }
.au-foot { padding: 4px 2px 8px; }

/* Verdict-coloured value text (Google CWV bands / health bands). */
.au-val--good { color: var(--success); }
.au-val--mid  { color: var(--warning); }
.au-val--bad  { color: var(--danger); }
.au-val--nm   { color: var(--text-muted); }

/* ---- Empty / gate states -------------------------------------------------- */
.au-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 64px 24px;
  border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle);
}
.au-empty__icon { font-size: 34px; line-height: 1; }
.au-empty__title { font-size: 16px; font-weight: 650; color: var(--text); }
.au-empty__text { font-size: 13px; color: var(--text-secondary); max-width: 420px; }
.au-empty__actions { margin-top: 8px; }

/* ---- Control bar (one card) ----------------------------------------------- */
.au-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--bg); box-shadow: var(--shadow-sm);
}
.au-scope-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-muted); border-radius: var(--radius-md); }
.au-seg-btn {
  border: 0; background: transparent; color: var(--text-secondary);
  font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 6px; cursor: pointer;
}
.au-seg-btn.is-active { background: var(--accent-light); color: var(--accent); }
.au-seg-btn:disabled { cursor: not-allowed; opacity: .55; }

.au-btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--text);
  background: var(--text); color: #fff; font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: var(--radius-md); cursor: pointer;
}
.au-btn:hover { background: #000; }
.au-btn:disabled { opacity: .6; cursor: not-allowed; }
.au-btn.is-loading { position: relative; color: transparent; }
.au-btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%;
  animation: au-spin .7s linear infinite;
}
@keyframes au-spin { to { transform: rotate(360deg); } }

.au-btn--ghost {
  background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border);
}
.au-btn--ghost:disabled { color: var(--text-muted); }
.au-controls__spacer { flex: 1 1 auto; }
.au-lastrun { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.au-lastrun strong { color: var(--text); font-weight: 600; }

/* ---- Progress / banners --------------------------------------------------- */
.au-progress {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 14px;
  border: 1px solid transparent; border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
}
/* The attribute alone is defeated by display:flex above; this makes hidden actually hide (stale-banner fix). */
.au-progress[hidden] { display: none; }
.au-progress--running { background: var(--accent-light); border-color: var(--accent-light); color: var(--accent-hover); }
.au-progress--success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.au-progress--error   { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.au-progress__text { flex: 0 1 auto; }
.au-progress__elapsed { margin-left: auto; font-variant-numeric: tabular-nums; opacity: .85; }
.au-progress__icon {
  width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: #fff;
}
.au-progress--success .au-progress__icon { background: var(--success); }
.au-progress--error .au-progress__icon { background: var(--danger); }
.au-progress__dismiss { margin-left: auto; background: transparent; border: 0; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.au-progress__bar { flex: 1 1 100%; height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.au-progress__bar[hidden] { display: none; }
.au-progress__bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.au-progress__spin {
  width: 15px; height: 15px; border: 2px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: au-spin .7s linear infinite; flex: 0 0 auto;
}
.au-banner {
  padding: 10px 14px; border-radius: var(--radius-md); font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border);
}
.au-banner--trunc { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.au-banner--error { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* ---- Overview grid (12-col like the mockup) ------------------------------- */
.au-card__title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin-bottom: 12px; }
.au-metric--full { grid-column: 1 / -1; }
.au-summary { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.au-col--score  { grid-column: span 4; }
.au-col--checks { grid-column: span 3; }
.au-col--donut  { grid-column: span 5; }
.au-col--trend  { grid-column: 1 / -1; }
@media (max-width: 1080px) {
  .au-col--score, .au-col--checks, .au-col--donut { grid-column: span 6; }
}
@media (max-width: 640px) {
  .au-col--score, .au-col--checks, .au-col--donut { grid-column: 1 / -1; }
}

/* Health score gauge + verdict + knob */
.au-score__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.au-score__num { font-size: 42px; font-weight: 760; line-height: 1; color: var(--text); }
.au-score__num small { font-size: 16px; color: var(--text-muted); font-weight: 600; }
.au-score__verdict { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 14px; font-weight: 700; }
.au-score__sub { font-size: 11px; font-weight: 500; color: var(--text-muted); margin-top: 3px; }
.au-score__bar {
  position: relative; height: 8px; margin-top: 18px; border-radius: 999px;
  background: linear-gradient(90deg, var(--danger) 0%, var(--warning) 50%, var(--success) 100%);
}
.au-score__knob {
  position: absolute; top: 50%; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-md);
  transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center;
}
.au-score__knob-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
/* Null health score — muted, normal-size dash + reason (no giant dash, no gradient bar, no knob). */
.au-score__empty { display: flex; align-items: baseline; gap: 10px; }
.au-score__empty-dash { font-size: 22px; font-weight: 700; color: var(--text-muted); line-height: 1; }
.au-score__empty-note { font-size: 12px; color: var(--text-muted); }

/* Checks — stacked rows: big coloured number + uppercase mono caption */
.au-counts { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.au-count { display: flex; align-items: baseline; gap: 10px; }
.au-count__num { font-size: 26px; font-weight: 760; line-height: 1; font-variant-numeric: tabular-nums; }
.au-count__cap { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.au-count--crit .au-count__num { color: var(--danger); }
.au-count--gap  .au-count__num { color: var(--warning); }
.au-count--pass .au-count__num { color: var(--success); }

/* Donut with centred page-count overlay + pct legend */
.au-donut-wrap { display: flex; align-items: center; gap: 18px; }
.au-donut__ring { position: relative; width: 80px; height: 80px; flex: 0 0 auto; }
.au-donut { display: block; }
.au-donut__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.au-donut__count { font-size: 18px; font-weight: 760; color: var(--text); line-height: 1; }
.au-donut__unit { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: 1px; }
.au-legend { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }
.au-legend__row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.au-legend__sw { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.au-legend__label { flex: 1 1 auto; }
.au-legend__val { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.au-legend__pct { min-width: 38px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.au-arc { fill: none; stroke-width: 12; }
.au-arc--success { stroke: var(--success); }
.au-arc--broken  { stroke: var(--danger); }
.au-arc--blocked { stroke: var(--warning); }
.au-sw--success { background: var(--success); }
.au-sw--broken  { background: var(--danger); }
.au-sw--blocked { background: var(--warning); }

/* Trend */
/* Trend chart: SVG line (constant 3px via non-scaling-stroke) + HTML dots/labels positioned over it
   (distortion-free, unlike circles under preserveAspectRatio="none"). Y-domain padded/clamped in JS. */
.au-trend__plot { position: relative; height: 88px; }
.au-trend__svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.au-trend__line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.au-trend__dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); transform: translate(-50%, 50%); box-shadow: var(--shadow-sm); }
.au-trend__labels { display: flex; justify-content: space-between; gap: 4px; margin-top: 10px; }
.au-trend__lab { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.au-trend__note { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 8px; }

/* ---- CWV ------------------------------------------------------------------ */
.au-cwv__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 14px; }
.au-cwv__head .au-sec-head { margin: 0; }   /* rhythm lives on the flex head; keep the title aligned with the toggle */
.au-cwv__toggle { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-muted); border-radius: var(--radius-md); }
.au-cwv__metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 780px) { .au-cwv__metrics { grid-template-columns: repeat(2, 1fr); } }
.au-cwv__grouptitle { font-size: 11.5px; font-weight: 650; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; margin: 16px 0 10px; }
.au-metric { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; background: var(--bg-subtle); }
.au-metric__label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.au-metric__val { font-size: 19px; font-weight: 750; color: var(--text); margin-top: 3px; }

/* Threshold bar — three fixed 45/30/25 segments with a value-positioned marker + captions. */
.au-thbar { position: relative; display: flex; height: 6px; margin-top: 12px; }
.au-thbar__seg { height: 6px; }
.au-thbar__seg--good { flex: 0 0 45%; background: var(--success); border-radius: 999px 0 0 999px; }
.au-thbar__seg--mid  { flex: 0 0 30%; background: var(--warning); }
.au-thbar__seg--bad  { flex: 0 0 25%; background: var(--danger); border-radius: 0 999px 999px 0; }
.au-thbar__marker {
  position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--text); box-shadow: var(--shadow-sm);
  transform: translate(-50%, -50%);
}
.au-thbar__caps { display: flex; justify-content: space-between; margin-top: 6px; font-size: 9.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.au-nm {
  display: flex; flex-direction: column; gap: 4px; padding: 16px;
  border: 1px dashed var(--border); border-radius: var(--radius-md); background: var(--bg-subtle); text-align: center;
}
.au-nm__title { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.au-nm__reason { font-size: 12px; color: var(--text-muted); }
.au-note { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }

/* ---- Verdict pills -------------------------------------------------------- */
.au-pill { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.au-pill--pass { background: var(--success-bg); color: var(--success); }
.au-pill--warn { background: var(--warning-bg); color: var(--warning); }
.au-pill--fail { background: var(--danger-bg); color: var(--danger); }
.au-pill--nm   { background: var(--bg-muted); color: var(--text-muted); }
.au-pill--info { background: var(--accent-light); color: var(--accent-hover); }

/* ---- Check rows (site + on-page) ----------------------------------------- */
.au-rows { display: flex; flex-direction: column; }
.au-row { border-bottom: 1px solid var(--border); padding: 11px 2px; }
.au-row:last-child { border-bottom: 0; }
.au-row__head { display: flex; align-items: center; gap: 12px; cursor: default; }
.au-row--exp .au-row__head { cursor: pointer; }
.au-row__label { font-size: 13px; color: var(--text); font-weight: 550; flex: 0 0 auto; min-width: 180px; }
.au-row__bar-wrap { flex: 1 1 auto; height: 7px; border-radius: 999px; background: var(--bg-muted); overflow: hidden; min-width: 80px; }
.au-row__bar { height: 100%; border-radius: 999px; background: var(--accent); }
.au-row__bar--fail { background: var(--danger); }
.au-row__bar--warn { background: var(--warning); }
.au-row__meta { font-size: 12px; color: var(--text-secondary); white-space: nowrap; flex: 0 0 auto; min-width: 92px; text-align: right; }
.au-row__caret { font-size: 10px; color: var(--text-muted); width: 12px; flex: 0 0 auto; transition: transform .15s; }
.au-row.is-open .au-row__caret { transform: rotate(90deg); }
.au-row__detail { display: none; padding: 10px 0 4px 24px; }
.au-row.is-open .au-row__detail { display: block; }
.au-row__kv { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 4px; }
.au-row__kv b { color: var(--text); font-weight: 600; }
.au-row__pages { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.au-row__page { font-size: 12px; color: var(--text-secondary); word-break: break-all; }
.au-row__more { font-size: 12px; color: var(--accent); margin-top: 4px; }

/* ---- Tables --------------------------------------------------------------- */
.au-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.au-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.au-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.au-table tr:last-child td { border-bottom: 0; }
.au-table td.au-num { text-align: right; font-variant-numeric: tabular-nums; }
.au-table__url { color: var(--accent); word-break: break-all; }
.au-status-ok  { color: var(--success); font-weight: 600; }
.au-status-bad { color: var(--danger); font-weight: 600; }
.au-muted { color: var(--text-muted); }

/* ---- Action plan ---------------------------------------------------------- */
.au-plan { display: flex; flex-direction: column; gap: 8px; }
.au-plan__item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-subtle); }
.au-plan__rank { font-size: 12px; font-weight: 700; color: var(--text-muted); width: 22px; flex: 0 0 auto; }
.au-plan__label { font-size: 13px; color: var(--text); font-weight: 550; flex: 1 1 auto; }
.au-plan__count { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

.au-section-title { font-size: 14px; font-weight: 700; color: var(--text); margin: 4px 0 2px; }
