/* audits_html's own rules, every one scoped to its root (div.au-root).
 * Band colours are this screen's: darker than the shared status tokens so a
 * 12px label on its tint stays readable in both themes. */

.au-root {
  --au-band-ex: #15803d; --au-band-ex-bg: #dcfce7;
  --au-band-good: #0e7490; --au-band-good-bg: #cffafe;
  --au-band-ni: #b45309; --au-band-ni-bg: #fef3c7;
  --au-band-ar: #b91c1c; --au-band-ar-bg: #fee2e2;
  --au-band-ns: var(--ch-pill-cancelled-text); --au-band-ns-bg: var(--ch-pill-cancelled-bg);
}
[data-theme="dark"] .au-root {
  --au-band-ex: #4ade80; --au-band-ex-bg: #14532d;
  --au-band-good: #67e8f9; --au-band-good-bg: #164e63;
  --au-band-ni: #fbbf24; --au-band-ni-bg: #78350f;
  --au-band-ar: #fca5a5; --au-band-ar-bg: #7f1d1d;
}

:where(.au-root) [hidden] { display: none !important; }

:where(.au-root) .au-page {
  padding: var(--ch-space-lg);
  max-width: 1320px;
  margin: 0 auto;
  font-family: var(--ch-font-primary);
  color: var(--ch-text-primary);
}

:where(.au-root) .au-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ch-space-md);
  margin-bottom: var(--ch-space-lg);
}
:where(.au-root) .au-title { font-size: 28px; font-weight: 600; margin: 0; }
:where(.au-root) .au-header-side { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
:where(.au-root) .au-due { font-size: 14px; color: var(--ch-text-secondary); }
:where(.au-root) .au-due b { color: var(--ch-text-primary); }

:where(.au-root) .au-select {
  min-height: 44px;
  max-width: 300px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ch-text-primary);
  background: var(--ch-bg-input);
  border: 2px solid var(--ch-border);
  border-radius: var(--ch-radius-md);
}
:where(.au-root) .au-select:focus-visible,
:where(.au-root) .au-btn:focus-visible,
:where(.au-root) .au-tl-item:focus-visible {
  outline: 2px solid var(--ch-border-focus);
  outline-offset: 2px;
}

:where(.au-root) .au-btn {
  min-height: 44px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--ch-radius-md);
  border: 1px solid var(--ch-border);
  background: var(--ch-bg-card);
  color: var(--ch-text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
:where(.au-root) .au-btn:hover:not(:disabled) { background: var(--ch-bg-secondary); color: var(--ch-text-primary); }
:where(.au-root) .au-btn--primary {
  background: var(--ch-accent-primary);
  border-color: var(--ch-accent-primary);
  color: var(--px-ink-on-bright);
}
:where(.au-root) .au-btn--primary:hover:not(:disabled) { background: var(--ch-accent-primary-hover); color: var(--px-ink-on-bright); }
:where(.au-root) .au-btn:disabled {
  background: var(--px-bg-disabled);
  color: var(--px-text-disabled);
  border-color: var(--px-border-disabled);
  cursor: not-allowed;
}

:where(.au-root) .au-card {
  background: var(--ch-bg-card);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-lg);
  box-shadow: var(--ch-shadow-sm);
}
:where(.au-root) .au-muted { color: var(--ch-text-muted); }
:where(.au-root) .au-small { font-size: 12px; }
:where(.au-root) .au-sec-title { font-size: 16px; font-weight: 600; margin: 0 0 10px; }

/* ---- states ---- */
:where(.au-root) .au-gate {
  padding: var(--ch-space-xl) var(--ch-space-lg);
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--ch-text-secondary);
}
:where(.au-root) .au-empty,
:where(.au-root) .au-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ch-space-sm);
  padding: 64px var(--ch-space-lg);
  text-align: center;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ch-text-muted);
}
:where(.au-root) .au-error { color: var(--ch-danger); }
:where(.au-root) .au-empty-icon { font-size: 48px; opacity: 0.5; }
:where(.au-root) .au-access {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ch-danger-bg);
  color: var(--ch-danger-text);
  border-left: 3px solid var(--ch-danger-border);
  border-radius: 0 var(--ch-radius-md) var(--ch-radius-md) 0;
}
:where(.au-root) .au-skel-ring { width: 150px; height: 150px; border-radius: 50%; }
:where(.au-root) .au-skel-line { height: 16px; width: 80%; margin-bottom: 10px; }
:where(.au-root) .au-skel-line--wide { height: 22px; width: 60%; }
:where(.au-root) .au-skel-pane { padding: 16px; }
:where(.au-root) .au-skel-row { height: 48px; margin: 8px 0; }

/* ---- band pills, score colours ---- */
:where(.au-root) .au-band {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--ch-radius-full);
  white-space: nowrap;
}
:where(.au-root) .au-band--excellent { background: var(--au-band-ex-bg); color: var(--au-band-ex); }
:where(.au-root) .au-band--good { background: var(--au-band-good-bg); color: var(--au-band-good); }
:where(.au-root) .au-band--needs_improvement { background: var(--au-band-ni-bg); color: var(--au-band-ni); }
:where(.au-root) .au-band--action_required { background: var(--au-band-ar-bg); color: var(--au-band-ar); }
:where(.au-root) .au-band--not_scored { background: var(--au-band-ns-bg); color: var(--au-band-ns); }
:where(.au-root) .au-score--excellent { color: var(--au-band-ex); }
:where(.au-root) .au-score--good { color: var(--au-band-good); }
:where(.au-root) .au-score--needs_improvement { color: var(--au-band-ni); }
:where(.au-root) .au-score--action_required { color: var(--au-band-ar); }
:where(.au-root) .au-score--not_scored { color: var(--au-band-ns); }
:where(.au-root) .au-updated {
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  color: var(--ch-accent-primary-text);
  background: var(--ch-accent-secondary);
  padding: 2px 8px;
  border-radius: var(--ch-radius-full);
  white-space: nowrap;
}

/* ---- earlier PX Audit bar ---- */
:where(.au-root) .au-viewing {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  font-size: 13.5px;
  background: var(--ch-warning-bg);
  color: var(--px-warning-text);
  border: 1px solid var(--ch-warning-border);
  border-radius: var(--ch-radius-md);
}

/* ---- hero ---- */
:where(.au-root) .au-hero {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 22px;
  border-top: 4px solid var(--ch-accent-primary);
}
:where(.au-root) .au-ring { position: relative; width: 150px; height: 150px; }
:where(.au-root) .au-ring circle { fill: none; stroke-width: 14; }
:where(.au-root) .au-ring-track { stroke: var(--ch-bg-secondary); }
:where(.au-root) .au-ring-value { stroke-linecap: round; }
:where(.au-root) .au-stroke--excellent { stroke: var(--au-band-ex); }
:where(.au-root) .au-stroke--good { stroke: var(--au-band-good); }
:where(.au-root) .au-stroke--needs_improvement { stroke: var(--au-band-ni); }
:where(.au-root) .au-stroke--action_required { stroke: var(--au-band-ar); }
:where(.au-root) .au-stroke--not_scored { stroke: var(--au-band-ns); }
:where(.au-root) .au-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--ch-text-muted);
}
:where(.au-root) .au-ring-label b { font-size: 34px; line-height: 1; }
:where(.au-root) .au-eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ch-accent-primary-text);
}
:where(.au-root) .au-hero-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
  font-size: 24px;
  font-weight: 600;
}
:where(.au-root) .au-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13.5px;
  color: var(--ch-text-secondary);
  overflow-wrap: anywhere;
}
:where(.au-root) .au-hero-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---- inline report (cert_viewer_html shape) ---- */
:where(.au-root) .au-report { margin-top: 14px; padding: 12px; }
:where(.au-root) .au-report-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 260px;
  text-align: center;
  color: var(--ch-text-secondary);
}
:where(.au-root) .au-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--ch-border);
  border-top-color: var(--ch-accent-primary);
  border-radius: 50%;
  animation: au-spin 0.8s linear infinite;
}
@keyframes au-spin { to { transform: rotate(360deg); } }
:where(.au-root) .au-report-frame {
  display: block;
  width: 100%;
  height: 75vh;
  min-height: 480px;
  border: 0;
  border-radius: var(--ch-radius-md);
  background: var(--ch-bg-secondary);
}

/* ---- comments, action plan, history ---- */
:where(.au-root) .au-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}
:where(.au-root) .au-comments {
  margin-bottom: 20px;
  padding: 14px 16px;
  white-space: pre-line;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
:where(.au-root) .au-note {
  margin-bottom: var(--ch-space-md);
  padding: 10px 14px;
  font-size: 14px;
  background: var(--ch-info-bg);
  border: 1px solid var(--ch-info-border);
  border-radius: var(--ch-radius-md);
}
:where(.au-root) .au-actions { padding: 6px 18px; }
:where(.au-root) .au-actions-none { padding: 14px 0; }
:where(.au-root) .au-action {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--ch-border);
  overflow-wrap: anywhere;
}
:where(.au-root) .au-action:last-child { border-bottom: 0; }
:where(.au-root) .au-action-n {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  background: var(--ch-accent-secondary);
  color: var(--ch-accent-primary-text);
}
:where(.au-root) .au-action-text { font-weight: 600; white-space: pre-line; }
:where(.au-root) .au-action-finding { margin-top: 3px; font-size: 13px; white-space: pre-line; }
:where(.au-root) .au-action-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ch-text-muted);
}
:where(.au-root) .au-history { padding: 12px 12px 6px; }
:where(.au-root) .au-timeline { position: relative; padding: 4px 0 4px 26px; }
:where(.au-root) .au-timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--ch-border);
}
:where(.au-root) .au-tl-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-height: 44px;
  margin-bottom: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--ch-radius-md);
  cursor: pointer;
}
:where(.au-root) .au-tl-item:hover { background: var(--ch-bg-secondary); }
:where(.au-root) .au-tl-item--selected { border-color: var(--ch-accent-primary); background: var(--ch-accent-soft); }
:where(.au-root) .au-tl-dot {
  position: absolute;
  left: -23px;
  top: 13px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--ch-bg-card);
  background: var(--au-band-ns);
}
:where(.au-root) .au-band-edge--excellent .au-tl-dot { background: var(--au-band-ex); }
:where(.au-root) .au-band-edge--good .au-tl-dot { background: var(--au-band-good); }
:where(.au-root) .au-band-edge--needs_improvement .au-tl-dot { background: var(--au-band-ni); }
:where(.au-root) .au-band-edge--action_required .au-tl-dot { background: var(--au-band-ar); }
:where(.au-root) .au-tl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

@media (max-width: 900px) {
  :where(.au-root) .au-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  :where(.au-root) .au-hero-title,
  :where(.au-root) .au-facts { justify-content: center; }
  :where(.au-root) .au-hero-actions { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  :where(.au-root) .au-body { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  :where(.au-root) .au-page { padding: var(--ch-space-md); }
  :where(.au-root) .au-header-side,
  :where(.au-root) .au-select { width: 100%; max-width: none; }
}
