/* REVIEW-UI (external review b.txt): dark-mode fixes. Loaded after every shared stylesheet.
   Module palettes (--ppe-*, --ac-*, --bgr-*, --li-*, --dq-*, --ins-*, --hn-*, --pds-*) are defined light-only in
   their module files, so any text/surface that reads them stayed light-on-light or dark-on-dark in dark mode.
   Fix at the token, not per element. Values are the app's own dark palette (see :root[data-theme="dark"] in app.css). */
:root[data-theme="dark"] {
  --ppe-ink:#e5e7eb; --ppe-muted:#9ca3af; --ppe-line:#2b3545; --ppe-bg:#0b0f16; --ppe-card:#111827;
  --ac-ink:#e5e7eb; --ac-muted:#9ca3af; --ac-line:#2b3545; --ac-bg:#0b0f16; --ac-card:#111827;
  --bgr-ink:#e5e7eb; --bgr-muted:#9ca3af; --bgr-border:#2b3545; --bgr-bg:#0b0f16; --bgr-card:#111827;
  --li-ink:#e5e7eb; --li-muted:#9ca3af; --li-border:#2b3545; --li-line:#2b3545; --li-bg:#0b0f16; --li-card:#111827; --li-soft:#121a28;
  --ins-bg:#0b0f16; --ins-line:#2b3545; --ins-text:#e5e7eb; --ins-muted:#9ca3af; --ins-card:#111827;
  --hn-bg:#0b0f16; --hn-card:#111827; --hn-line:#2b3545; --hn-text:#e5e7eb; --hn-muted:#9ca3af; --hn-soft:#121a28;
  --hnx-border:#2b3545; --hnx-soft:#121a28; --hn-border:#2b3545; --hn-soft-bg:#121a28;
  --pds-dark:#e5e7eb; --pds-muted:#9ca3af; --pds-line:#2b3545; --pds-bg:#0b0f16; --pds-card:#111827;
}
:root[data-theme="dark"] .dq-page { --dq-bg:#0b0f16; --dq-border:#2b3545; --dq-text:#e5e7eb; --dq-muted:#9ca3af; }

/* B2 + B1: Nexus transcript row. Icon glyphs sat off-centre in their 26px boxes in both themes (UA button padding + glyph
   baseline); in dark mode the row kept a white panel and near-black title text. */
#nexus-v4-presence .nxv4-transcript-actions { align-items: center; flex: 0 0 auto; }
#nexus-v4-presence .nxv4-transcript-actions button {
  display: inline-grid; place-items: center; padding: 0; line-height: 1; font-size: 14px; flex: 0 0 26px; box-sizing: border-box;
}
:root[data-theme="dark"] #nexus-v4-presence .nxv4-transcript-panel { background: #1a1a1a !important; }
:root[data-theme="dark"] #nexus-v4-presence .nxv4-transcript-title { background: transparent !important; }
:root[data-theme="dark"] #nexus-v4-presence .nxv4-transcript-title strong { color: #e5e7eb; }
:root[data-theme="dark"] #nexus-v4-presence .nxv4-transcript-title span { color: #9ca3af; }
:root[data-theme="dark"] #nexus-v4-presence .nxv4-transcript-actions button { background: #232323 !important; color: #cbd5e1; border-color: #3a3a3a; }

/* B9: Audit annual-plan donut — inner disc was literal `white` and the track #e5e7eb (value uses var(), skipped by the generator). */
:root[data-theme="dark"] .ac-donut { background: conic-gradient(var(--ac-red) calc(var(--p) * 1%), #2b3545 0) !important; }
:root[data-theme="dark"] .ac-donut:before { background: #111827 !important; }
:root[data-theme="dark"] .ac-donut b { color: #e5e7eb; }

/* B7: IEMP card titles use --hnx-blue (#06346b navy, 1.4:1 on the dark card); the same token also paints dark hero gradients, so retarget the text only. */
:root[data-theme="dark"] .iemp-centre-card h2,
:root[data-theme="dark"] .iemp-principles strong,
:root[data-theme="dark"] .hnx-summary-card strong { color: #9db7e6; }

/* B8: Insight Studio catalogue search. In dark mode the sitewide `input { background:#1a1a1a !important; border; radius }` rule turned the
   inner <input> into a second, taller box that poked outside its bordered wrapper. The wrapper owns the chrome; the input is bare. */
:root[data-theme="dark"] .catalogue-search input,
:root[data-theme="dark"] .field-search input,
:root[data-theme="dark"] .global-search input {
  background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  padding: 0 !important; height: 100% !important; min-height: 0 !important; min-width: 0; outline: 0;
}

/* B9b: Audit risk heat map. The generator darkened only h1/h3 (pale fills) and forced light text onto every cell, so cells were a mix of
   near-black and pastel with 1.3:1 numbers. The heat colours are semantic: keep the light-mode fills and give every cell dark text. */
:root[data-theme="dark"] .ac-heat .h1 { background: #dff5dd !important; }
:root[data-theme="dark"] .ac-heat .h2 { background: #b9eab5 !important; }
:root[data-theme="dark"] .ac-heat .h3 { background: #fff1a8 !important; }
:root[data-theme="dark"] .ac-heat .h4 { background: #ffc169 !important; }
:root[data-theme="dark"] .ac-heat .h5 { background: #f66f6f !important; }
:root[data-theme="dark"] .ac-heat span { color: #111827 !important; }

/* Links that take a brand/blue accent below 4.5:1 on dark cards. */
:root[data-theme="dark"] .ac-card a:not([class]),
:root[data-theme="dark"] .dq-link { color: #ff7a86; }
:root[data-theme="dark"] .dq-link { color: #8fb4ff; }
:root[data-theme="dark"] a[style*="color:#2563eb"] { color: #8fb4ff !important; }

/* B11c: Policy & Control Library command centre keeps its own shell-scoped light palette (--text/--card/--line redefine the global dark tokens). */
:root[data-theme="dark"] .pcv4-shell,
:root[data-theme="dark"] .pcv5-shell {
  --bg: #0b0f16; --card: #111827; --line: #2b3545; --line2: #374357; --text: #e5e7eb; --muted: #9ca3af; --muted2: #b3bbc7;
}

/* b.txt #4/#6: on narrow screens the template-switch pill (112x28) sat over dashboard cards. Collapse it to its dot; the label stays
   available to assistive tech (aria-label) and the switch still announces what changed. */
@media (max-width: 900px) {
  .hh-theme-toggle { padding: 7px; gap: 0; }
  .hh-theme-toggle #hhThemeToggleLabel,
  .hh-theme-toggle .hh-theme-prefix { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 600px) { .hh-theme-note { bottom: 96px; } }

/* B1: the header wordmark is a transparent PNG whose lettering is near-black (mean opaque-pixel luminance 37/255): on the dark topbar
   (#0b0f16) it measured 1.2:1 and "HeirsNexus" vanished beside the orb. Seat the full-width logo on a light plate in dark mode. */
:root[data-theme="dark"] .heirsnexus-header-logo:not(.heirsnexus-header-logo--compact) {
  background: #eef1f6; border-radius: 10px; padding: 3px 10px; box-sizing: content-box;
}

/* B11d: the Licence Overview line chart is generated SVG with literal light-theme paint (white background rect, near-black total line,
   pale grid), so it stayed a white slab on the dark card. Presentation attributes lose to CSS, so retarget by attribute. */
:root[data-theme="dark"] .li-shell svg rect[fill="#fff"] { fill: transparent; }
:root[data-theme="dark"] .li-shell svg path[stroke="#111827"] { stroke: #e5e7eb; }
:root[data-theme="dark"] .li-shell svg line[stroke="#e8edf4"] { stroke: #2b3545; }

/* B11e: Policy & Control score rings/gauges use `radial-gradient(#fff ...)` + `conic-gradient(var(--green) ..., #e5e7eb ...)` - values that
   contain var() are skipped by the generated overrides, so the centre stayed a white disc with light text. */
:root[data-theme="dark"] .pcv5-ring { background: radial-gradient(circle at center, #111827 0 52%, transparent 53%), conic-gradient(var(--green) 0 302deg, #2b3545 302deg) !important; color: #e5e7eb; }
:root[data-theme="dark"] .pcv5-health { background: radial-gradient(circle at center, #111827 0 52%, transparent 53%), conic-gradient(var(--green) 0 280deg, #2b3545 280deg) !important; }
:root[data-theme="dark"] .pc-score-ring { background: conic-gradient(var(--hn-green) 0 302deg, #2b3545 302deg 360deg) !important; color: #e5e7eb; }
:root[data-theme="dark"] .pc-health-gauge { background: radial-gradient(circle at center, #111827 0 52%, transparent 53%), conic-gradient(var(--hn-green) 0 280deg, #2b3545 280deg) !important; }
