/*
 * Report base stylesheet — shared design system for every rendered /reports/*.html companion.
 *
 * Inlined verbatim into the generated, self-contained HTML by script-report-html-render.js, so it
 * must not reference external fonts, images or stylesheets. Layout is card-first (not table-first)
 * so the same markup reads well from a 360px phone up to a wide desktop without a separate mobile
 * variant. Colors live as tokens on :root and are redefined for dark mode plus an explicit
 * [data-theme] override, so the in-page theme toggle wins over the OS setting in both directions.
 */

/* ---------- tokens ---------- */
:root {
  /* Widest the report content ever gets, centred within whatever space is available. */
  --layout-max: 1440px;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #fafbfc;
  --text: #171a1f;
  --muted: #5d6472;
  --border: #e2e6eb;
  --border-strong: #cbd2db;
  /* brand primary — app-nebenzeit angular/projects/app-nebenzeit/src/styles/variables.scss --ion-color-primary */
  --accent: #05427f;
  --accent-soft: #e1e9f1;
  --accent-contrast: #ffffff;
  --danger: #cf3b23;
  --danger-soft: #fdecea;
  --warn: #b57608;
  --warn-soft: #fdf3e0;
  --ok: #23824f;
  --ok-soft: #e6f6ed;
  --info: #05427f;
  --info-soft: #e1e9f1;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 4px 12px rgba(16, 20, 28, .04);
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121419;
    --panel: #1a1d24;
    --panel-soft: #21252e;
    --text: #e7eaee;
    --muted: #98a0ad;
    --border: #2b303a;
    --border-strong: #3a414e;
    --accent: #4f8dd4;
    --accent-soft: #1b2938;
    --danger: #ff7d67;
    --danger-soft: #35201d;
    --warn: #e0a94a;
    --warn-soft: #33291a;
    --ok: #5fc78e;
    --ok-soft: #172b21;
    --info: #4f8dd4;
    --info-soft: #1b2938;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --bg: #121419;
  --panel: #1a1d24;
  --panel-soft: #21252e;
  --text: #e7eaee;
  --muted: #98a0ad;
  --border: #2b303a;
  --border-strong: #3a414e;
  --accent: #4f8dd4;
  --accent-soft: #1b2938;
  --danger: #ff7d67;
  --danger-soft: #35201d;
  --warn: #e0a94a;
  --warn-soft: #33291a;
  --ok: #5fc78e;
  --ok-soft: #172b21;
  --info: #4f8dd4;
  --info-soft: #1b2938;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* <dialog>.showModal() traps focus but does NOT stop the page behind it from scrolling in every browser
   — report-base.js toggles this class (refreshModalLock) whenever any <dialog> is open/closed. */
html.modal-open { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

code, kbd {
  font-family: var(--mono);
  font-size: .88em;
}

code {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .08em .35em;
  overflow-wrap: anywhere;
}

kbd {
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: .05em .4em;
  background: var(--panel-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- app frame ---------- */
/* In-flow top toolbar (fixed 2026-09-06: was `position: fixed`, permanently floating over the
 * content on every scroll position — user feedback "nicht schwebend über dem Rest"). Renders as a
 * normal full-width row above `.layout`, same as any other page-level toolbar. */
.floating-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px clamp(16px, 3vw, 28px);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.head-meta {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.head-meta b { color: var(--text); font-weight: 600; }

/* Completion badge — ✅ all decidable codes closed, ⏳ something still open. Uses the existing
   ok/warn token pairs so it inherits the dark theme without its own colour set. The icon-only
   ".is-marker" variant is what the remote-app list row puts in front of a report title. */
.completion-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.completion-badge.is-done { background: var(--ok-soft); color: var(--ok); }
.completion-badge.is-open { background: var(--warn-soft); color: var(--warn); }

.completion-badge.is-marker {
  padding: 0;
  background: none;
  font-size: inherit;
}

/* Scope/Methodik are long — collapsed by default so the sticky header stays compact */
.head-details { margin-top: 6px; font-size: 12.5px; color: var(--muted); max-width: 900px; }

.head-details summary {
  cursor: pointer;
  color: var(--accent);
  width: fit-content;
}

.head-details > div { margin-top: 6px; }

.head-details b { color: var(--text); font-weight: 600; }

.head-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: clamp(16px, 3vw, 32px);
  /* Shared with the remote app's detail back-bar so the bar and the content below it centre on the
     same axis — the bar lives in remote-app.css and would otherwise hard-code the same number. */
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
  align-items: start;
}

/* ---------- side navigation ---------- */
.side-nav {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  font-size: 13px;
}

.side-nav h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 8px;
}

.side-nav ul { list-style: none; margin: 0 0 14px; padding: 0; }

.side-nav li { margin: 0; }

.side-nav a {
  display: block;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-nav a:hover { background: var(--panel-soft); color: var(--text); }

.side-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-toggle { display: none; }

/* ---------- summary panel (report name + description + counts + filter tiles, one card) ---------- */
.summary-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px clamp(14px, 2.2vw, 20px) 14px;
  margin-bottom: var(--gap);
}

.summary-panel h2 { margin: 0; font-size: 18px; }

.summary-desc { margin: 8px 0 0; }

/* Full-width, color-coded rows (replaces the old single-line "26 Findings (F) · 7 ... · 6 ..." text,
 * user feedback 2026-09-06: "als full Zeilen mit symbol und ampel Farben, nicht als Fliestext"). */
.summary-count-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.summary-count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.scr-icon { font-size: 15px; line-height: 1; }

.summary-count-row.grp-f { background: var(--danger-soft); color: var(--danger); }
.summary-count-row.grp-e { background: var(--warn-soft); color: var(--warn); }
.summary-count-row.grp-p { background: var(--ok-soft); color: var(--ok); }
.summary-count-row.grp-info { background: var(--info-soft); color: var(--info); }

/* Total sits above the severity done/total rows (.summary-count-row) — a plain headline number, no
   border/box, distinct from the colored count rows below it. Unlike the old clickable .dash status-filter
   tiles this replaced (F-XX/2026-09-06 — removed, see renderSummaryPanel), neither is interactive, so
   both stay visible in print. */
.summary-metrics {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
}

.metric-total {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 16px;
  border-right: 1px solid var(--border);
}

.metric-total .n { font-size: 22px; font-weight: 700; line-height: 1.1; color: var(--muted); }

.metric-total .l { color: var(--muted); font-size: 11px; margin-top: 1px; white-space: nowrap; }

.progress-wrap {
  background: var(--panel);
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: none;
}

.progress-bar {
  flex: 1 1 180px;
  height: 9px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width .25s ease;
}

.progress-label { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- toolbar ---------- */
/* Plain in-flow block, deliberately not sticky/fixed (F-XX/2026-09-07, third report of the same
 * "floats around" complaint — the sticky+auto-hide/reveal logic never read as intentional to the user
 * no matter how it was tuned). User's own fallback, taken as-is: stay at the top of the document, no
 * scroll behavior at all — scrolling past it is the same as scrolling past any other section. */
.toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 0;
  margin-bottom: 4px;
  background: var(--bg);
}

.toolbar input[type="search"] {
  flex: 1 1 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

/* One full-width block per filter group (type / severity / status / undecided / reset) — see
 * renderToolbar(): keeps each group's chips wrapping only against their own kind, never against a
 * different group.
 *
 * F-XX/2026-09-07: this used to hold only up to ~768px — a `min-width: 768px` override below then let
 * `.toolbar-row` shrink to `flex: 0 1 auto; width: auto`, which packed multiple groups onto the same
 * flex line whenever they fit ("cuts the toolbar's vertical footprint"). At 1280px, that meant the
 * type/severity/status rows all rendered on one shared line, `top` identical for all three, wrapping
 * against *each other* — exactly what the comment above says this rule exists to prevent. Which groups
 * shared a line, and where the line broke, depended on viewport width and each group's current chip
 * count, so the toolbar visibly reshuffled between adjacent widths and between reports with a different
 * number of severities (user report: "die filter schwirren umher"). Full-width stacking now applies at
 * every viewport — deterministic, and the vertical space it costs on desktop is the tradeoff for a
 * toolbar that no longer reflows depending on width. */
.toolbar-row {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

/* Severity row (🔴🟡🔵🟢) and status row (🔄 Offen/⏳ Refine/🧪 Falsifiziert/✅ Behoben/➖ Akzeptiert/
 * ❌ Ignoriert): a hard 2-column grid, not a flex row — user-requested 2026-09-07, "max 2 Stück pro
 * Reihe, nicht alle 4 in einer Zeile" for severity, then explicitly extended to the status row the same
 * way ("offen/behoben noch 2er paar full breite wie severity"). Grid over flex is deliberate here, not
 * just style: with chips of uneven label length (Kritisch/Achtung/Info/"OK / Stärke"; "Falsifiziert
 * (Vorschlag)" is the longest status label) squeezed into one `flex: 1 1 0` row, `min-width: 0` shrank
 * each chip below its content's natural width — and `.chip` has `white-space: nowrap` with no
 * `overflow`/`text-overflow` handling, so the label rendered wider than its pill and visually spilled
 * into the neighboring chip (measured: "🟢 OK / Stärke3" was 111px of content in an 83px box). A
 * 2-column grid gives each chip roughly half the row — always enough room for these labels — and,
 * unlike flex-wrap, the column count never changes with viewport width, so it can't reflow into
 * 1-per-row or 4-per-row at some in-between breakpoint. Applies at every width, not just mobile: the
 * previous behavior (equal-flex only under 768px, auto-width and free to share a line with other groups
 * above it) was itself part of the inconsistency being fixed. Status can have up to 6 chips, so this
 * wraps into up to 3 rows of 2 — still deterministic, never 3-and-a-widow or all 6 crammed into one
 * line. */
.toolbar-row-grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.toolbar-row-grid2 .chip {
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}

/* "Nur unentschieden" is the only chip alone in its own row (unlike every other filter, which shares
 * its row with siblings from renderChips()/renderSeverityChips()/renderStatusChips()) — content-sized by
 * default it sat left-aligned with empty row to its right, and unlike "Filter zurücksetzen" right below
 * it (a .btn-block, already full-width) looked like an inconsistent afterthought on mobile, where every
 * other control in the toolbar spans the full row. User-requested 2026-09-07, mobile only: above the
 * 768px breakpoint the row has room to spare regardless, and stretching a single pill-shaped toggle to
 * the full container width there would look like a form field, not a filter chip. */
@media (max-width: 767px) {
  .chip-block {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
  }
}

/* Type (F/E/P) row: equal-width columns instead of content-sized chips, so a short "P 3" chip doesn't
   look tiny next to "F 8" — mobile only, user-requested 2026-09-06; the row itself now always spans full
   width (see .toolbar-row above), so this only governs the chips' own share of that width. */
@media (max-width: 767px) {
  .toolbar-row-equal .chip {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
  }
}

.btn-block {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}

.toolbar input[type="search"]:focus-visible,
.chip:focus-visible,
.btn:focus-visible,
.card-head:focus-visible,
.dbtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  /* Belt-and-braces alongside the layout fixes above: a compressed chip clips its own label instead of
     spilling text past its pill into whatever sits next to it (report-render-escaping/-consistency
     tests can't catch a visual overflow, so this stays defensive rather than relying on every chip
     row always having enough room). */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chip:hover { border-color: var(--border-strong); }

.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.chip .count { opacity: .7; margin-left: 5px; font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
}

.btn:hover { border-color: var(--border-strong); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-icon { padding: 8px 10px; line-height: 1; }

/* ---------- code cards ---------- */
.group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 22px 0 10px;
  scroll-margin-top: 160px;
}

.group-head h2 { margin: 0; font-size: 16px; }

.group-head .group-count { color: var(--muted); font-size: 13px; }

.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin-top: 160px;
}

.card.sev-krit { border-left-color: var(--danger); }
.card.sev-warn { border-left-color: var(--warn); }
.card.sev-ok { border-left-color: var(--ok); }
.card.sev-info { border-left-color: var(--info); }

.card.is-hidden { display: none; }

.card.is-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Flex column (2026-09-06: severity+ID/Status top row added) — V5/"Minimal-Fix" (2026-09-06 user choice
   among 5 rendered variants) already needed every child full-width; a plain column flex container gives
   every direct child that for free via the default `align-items: stretch`, without the grid-column
   span-hack the previous 2-column grid needed. */
.card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.card-head:hover { background: var(--panel-soft); }

/* Severity (left, next to the code — mirrors the modal's own "{severity} CODE" header) and Status
   (right) — both moved out of the .card-tags cloud onto their own top row (2026-09-06 user request). */
.card-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.card-key {
  font-weight: 700;
  font-family: var(--mono);
  font-size: 13.5px;
  white-space: nowrap;
}

/* Optional short one-line title (2026-09-06) — bold, above .card-summary, truncated with an ellipsis
   rather than wrapping; the modal's .dialog-headline shows the same text in full (renderCard()). */
.card-headline {
  display: block;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 0;
}

.card-summary {
  min-width: 0;
  margin: 2px 0 0;
}

.card-tags {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  background: var(--panel-soft);
  white-space: nowrap;
}

.tag.status-open { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.tag.status-fixed { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tag.status-refine { background: var(--info-soft); border-color: transparent; color: var(--info); }
.tag.status-ignored,
.tag.status-accepted { background: var(--panel-soft); color: var(--muted); }
/* P codes carry no decision state — the dash is a placeholder, not a status, so it stays visually quiet. */
.tag.status-none { background: transparent; border-color: var(--line); color: var(--muted); }

/* Block variant of .tag.status-* — the modal's own status readout (see renderCard()'s statusBadgeHtml),
   sitting first in .dialog-body instead of as trailing text in the <h2>. Same color-per-status mapping,
   just full-width and bigger so it reads as its own element, not a small pill among other tags. */
.status-badge {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}

.status-badge.status-open { background: var(--warn-soft); color: var(--warn); }
.status-badge.status-fixed { background: var(--ok-soft); color: var(--ok); }
.status-badge.status-refine { background: var(--info-soft); color: var(--info); }
.status-badge.status-ignored,
.status-badge.status-accepted { background: var(--panel-soft); color: var(--muted); }
.status-badge.status-none { background: var(--panel-soft); color: var(--muted); }

/* ---------- row-level quick-decision toolbar (sibling of .card-head, never nested inside it) ---------- */
.card-quick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 14px 10px;
  border-top: 1px dashed var(--border);
}

.row-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  /* left-aligned, allowed to wrap to a second line (a combined "🔁 Änderung · 🔍 Erklärung" text can get
     long) rather than being squeezed/truncated against the action buttons on the right */
  white-space: normal;
  flex: 1 1 auto;
  min-width: 0;
}

.row-badge[data-value="fix"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.row-badge[data-value="refine"] { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.row-badge[data-value="accept"] { background: var(--info-soft); color: var(--info); border-color: transparent; }
.row-badge[data-value="ignore"] { background: var(--panel-soft); color: var(--muted); border-color: var(--border-strong); }
.row-badge[data-value="change"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* F-XX/2026-09-06: was a passive <span>, hidden unless a comment already existed — now an always-visible
   button so a comment can be added from here too, not only read; .is-active still marks "has a comment",
   same visual language as before. Opens the same detail dialog in a filtered "comment-only" view (see
   .detail-modal.comment-only below) instead of a second, separate dialog — avoids two independent comment
   textareas per code drifting out of sync. Styled as a real button matching .rf-btn's box (not a bare
   emoji) but in its own color, so it reads as "open comment" and never as a fifth decision option. */
.row-comment-flag {
  /* identical box model to .rf-btn (min-width/padding/font-size/font-weight/border-width) so the two
     button kinds are exactly the same width+height side by side — only color/opacity differ */
  min-width: 30px;
  padding: 4px 0;
  border: 1px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--info);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  opacity: .6;
  cursor: pointer;
}

.row-comment-flag:hover { opacity: .85; }

.row-comment-flag.is-active { opacity: 1; background: var(--info-soft); }

/* Right-aligned group: the decision/reopen control plus the comment button sit together on the right;
   .row-badge (left, see above) takes the remaining space and wraps instead of being squeezed. */
.card-quick-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.row-decision {
  display: flex;
  gap: 4px;
}

.rf-btn {
  min-width: 30px;
  padding: 4px 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.rf-btn:hover { border-color: var(--accent); }
.rf-btn[aria-pressed="true"][data-action="fix"] { background: var(--danger); color: #fff; border-color: var(--danger); }
.rf-btn[aria-pressed="true"][data-action="refine"] { background: var(--warn); color: #fff; border-color: var(--warn); }
.rf-btn[aria-pressed="true"][data-action="accept"] { background: var(--info); color: #fff; border-color: var(--info); }
.rf-btn[aria-pressed="true"][data-action="ignore"] { background: var(--muted); color: #fff; border-color: var(--muted); }

.row-reopen-actions {
  display: flex;
  gap: 4px;
}

/* Real toggle buttons (aria-pressed), not checkboxes — same box as .rf-btn, one accent color per flag
   once active so "change/explain/reverify erwünscht" is a color+icon state, never a bare checked box. */
.rf-toggle[aria-pressed="true"][data-reopen-action="change"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.rf-toggle[aria-pressed="true"][data-reopen-action="explain"] { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.rf-toggle[aria-pressed="true"][data-reopen-action="reverify"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

/* two-column detail table (V8 report format) */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 10px 0 0;
  font-size: 14px;
}

/* F-XX/2026-09-06: was a <caption> inside .detail-table — on the mobile @media rule further down that
   converts the table to display:block, the caption sat directly above the first stacked row with only
   this rule's 6px bottom padding between them, so on narrow screens it visually ran into the first
   row's <th> label with no separating border. A real heading element outside the table (see
   renderDetailTable()) can't collapse into the table's own layout regardless of viewport width. */
/* F-XX/2026-09-07: "auffälliger" + hr-Trennung — every sectional heading (Zusammenfassung/Details/
   Aktionen/Kommentar) gets its own top divider + a bolder, higher-contrast label, so the line sits
   ABOVE the heading (separating it from the previous block) instead of between the heading and its
   content — the previous placement had the divider on .decision-row/.reopen-actions, i.e. below
   "Aktionen"'s own heading, not above it. The very first heading in the modal (Zusammenfassung, right
   after the status badge) suppresses its own divider — see .dialog-body h3:first-of-type below. */
.detail-table-heading {
  margin: 20px 0 8px;
  padding-top: 14px;
  border-top: 2px solid var(--border-strong);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text);
  font-weight: 800;
}

.dialog-body h3.detail-table-heading:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.detail-table th,
.detail-table td {
  text-align: left;
  vertical-align: top;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.detail-table tbody th {
  width: 27%;
  min-width: 128px;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel-soft);
}

.detail-table tbody tr:last-child th,
.detail-table tbody tr:last-child td { border-bottom: 0; }

.detail-table td > code { overflow-wrap: anywhere; }

/* Triggered by the row-level 💬 button (renderQuickRow) as a lightweight "read/edit just the comment"
   shortcut — reuses the same dialog/textarea as the full details view (report-base.js openModal()) so
   there is only ever one comment-box per code, just hides everything else in .dialog-body for this view. */
.detail-modal.comment-only .body-summary,
.detail-modal.comment-only .detail-table-heading,
.detail-modal.comment-only .detail-table,
.detail-modal.comment-only .related-codes,
.detail-modal.comment-only .decision-row,
.detail-modal.comment-only .reopen-actions,
.detail-modal.comment-only .refine-questions { display: none; }

/* ---------- decision controls (inside the detail modal) ---------- */
/* F-XX/2026-09-07: divider moved to .detail-table-heading (the "Aktionen" heading directly above this
   row) — no border here anymore, or the line would sit BETWEEN the heading and the buttons instead of
   above the heading itself. */
.decision-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* full-width comment field, always below the decision row — allowed on every code, incl. already-closed ones */
.comment-box {
  display: block;
  width: 100%;
  min-height: 64px;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  resize: vertical;
}

/* Same visual language as .detail-table-heading (2026-09-07 user request: every modal block —
   Zusammenfassung/Details/Aktionen/Kommentar — gets an identical, more prominent bold section label
   with its own divider above it, not below). */
.comment-box-label {
  display: block;
  margin: 20px 0 8px;
  padding-top: 14px;
  border-top: 2px solid var(--border-strong);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text);
  font-weight: 800;
}

/* ---------- interactive refine Q&A (embedded in the detail modal, plan [D12]) ---------- */
.refine-questions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.refine-questions h3 { margin: 0 0 10px; font-size: 14px; }

.refine-question {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.refine-question legend {
  padding: 0 4px;
  font-size: 13px;
}

.refine-explanation { margin: 4px 0 8px; color: var(--muted); font-size: 12.5px; }

.refine-answered-hint { color: var(--ok); font-size: 12px; font-weight: 600; }

.refine-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}

.refine-option input { margin-top: 3px; flex-shrink: 0; }

.refine-freetext-option { align-items: center; }

.refine-freetext {
  flex: 1 1 auto;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

/* closed codes (behoben/ignoriert/akzeptiert) get three independent reopen-style toggles instead of the fix/refine/accept/ignore select — a row of full-width-clickable pill toggles, one per requestable action.
   F-XX/2026-09-07: no border here anymore — the divider lives on the "Aktionen" .detail-table-heading above this row (see there). */
.reopen-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

/* Real toggle button (aria-pressed), not a checkbox — the whole pill is the click target. */
.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
}

.chip-toggle:hover { border-color: var(--accent); }

.chip-toggle[aria-pressed="true"][data-reopen-action="change"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip-toggle[aria-pressed="true"][data-reopen-action="explain"] { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.chip-toggle[aria-pressed="true"][data-reopen-action="reverify"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

/* ::after has one content slot — if more than one reopen-flag is active at once, only the last matching
   rule below wins here; the quick-row `.row-badge` (report-base.js syncCard) is the authoritative
   indicator that combines all active flags, this is only a decorative single-glyph shortcut. */
.card.is-changed .card-key::after {
  content: "🔁";
  margin-left: 6px;
  font-size: 11px;
}

.card.is-explain-requested .card-key::after {
  content: "🔍";
  margin-left: 6px;
  font-size: 11px;
}

.card.is-reverify-requested .card-key::after {
  content: "🧪";
  margin-left: 6px;
  font-size: 11px;
}

.decision-row .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.decision-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.dbtn {
  padding: 10px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-transform: capitalize;
}

.dbtn:hover { border-color: var(--accent); }
.dbtn[aria-pressed="true"].val-fix { background-color: var(--danger); color: #fff; border-color: var(--danger); }
.dbtn[aria-pressed="true"].val-refine { background-color: var(--warn); color: #fff; border-color: var(--warn); }
.dbtn[aria-pressed="true"].val-accept { background-color: var(--info); color: #fff; border-color: var(--info); }
.dbtn[aria-pressed="true"].val-ignore { background-color: var(--muted); color: #fff; border-color: var(--muted); }

.decided-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  display: none;
}

.card.is-decided .decided-dot { display: inline-block; }

.card.is-decided .card-key::after {
  content: "●";
  color: var(--accent);
  font-size: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- prose sections rendered from markdown ---------- */
.prose-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px clamp(14px, 2.4vw, 22px) 18px;
  margin-top: var(--gap);
  scroll-margin-top: 160px;
  overflow-wrap: break-word;
}

.prose-section h2 { font-size: 17px; margin: 18px 0 10px; }

.prose-section h3 { font-size: 15px; margin: 16px 0 8px; }

.prose-section p { margin: 10px 0; }

.prose-section ul,
.prose-section ol { margin: 10px 0; padding-left: 22px; }

.prose-section li { margin: 4px 0; }

.prose-section blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.prose-section blockquote p { margin: 4px 0; }

.prose-section pre {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
}

.prose-section pre code { background: none; border: 0; padding: 0; }

.prose-section hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* condensed sections (Audit-History by default) — collapsed on load, full content still in the DOM for search/print */
.section-collapse { margin: 8px 0 6px; }

.section-collapse > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
}

.section-collapse > summary::-webkit-details-marker { display: none; }

.section-collapse > summary::before { content: "▶ "; display: inline-block; transition: transform .15s ease; }

.section-collapse[open] > summary::before { transform: rotate(90deg); }

.section-collapse > summary .muted-count { color: var(--muted); font-weight: 400; margin-left: 6px; }

/* every wide block scrolls inside its own container — the page body never scrolls sideways */
.table-scroll { overflow-x: auto; margin: 12px 0; }

.table-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 420px;
}

.table-scroll th,
.table-scroll td {
  text-align: left;
  vertical-align: top;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
}

.table-scroll thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.table-scroll tbody tr:last-child td { border-bottom: 0; }

/* ---------- response panel ---------- */
.response-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px clamp(14px, 2.4vw, 22px);
  margin-top: var(--gap);
  scroll-margin-top: 160px;
}

.response-panel h2 { margin: 0 0 4px; font-size: 16px; }

.preset-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.dropdown-menu[hidden] { display: none; }

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.dropdown-item:hover { background: var(--panel-soft); }

.live-decisions {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.live-decisions:empty { margin: 0; }

.live-decisions li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  padding: 4px 8px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.live-decisions .ld-code { font-family: var(--mono); font-weight: 700; white-space: nowrap; }

.live-decisions .ld-comment { color: var(--muted); overflow-wrap: anywhere; }

.response-panel textarea {
  width: 100%;
  min-height: 108px;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  resize: vertical;
}

.response-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.empty-state {
  background: var(--panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  display: none;
}

.empty-state.is-visible { display: block; }

/* ---------- toast + help dialog ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 60;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Anchored to the top (2026-09-07 user request) instead of the UA default vertical-center — centering
   fights the mobile on-screen keyboard (which shrinks the visual viewport and re-centers the dialog
   mid-typing, e.g. while focused in .comment-box) and forces the user to scroll to reach the top of a
   tall dialog they can already see the top edge of. `bottom: auto` (dropping the UA's other inset edge)
   is required — with both top and bottom set, `margin: 0 auto` re-centers vertically in the space
   between them instead of pinning to the top. */
dialog[open] {
  position: fixed;
  top: 16px;
  bottom: auto;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 460px;
  width: min(92vw, 460px);
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(4, 6, 10, .72); }

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 { margin: 0; font-size: 15px; }

.dialog-head-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Full, untruncated headline (card shows the same text but clipped to one line — renderCard()'s
   .card-headline). `flex: 1 1 100%` forces its own line inside the wrapping .dialog-head-title instead
   of competing for space with the h2/tags on one row. */
.dialog-headline {
  flex: 1 1 100%;
  margin: 0;
  font-weight: 700;
  font-size: 14px;
}

.dialog-body { padding: 14px 18px 18px; }

.dialog-body table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.dialog-body td { padding: 5px 0; vertical-align: top; }

.dialog-body td:first-child { width: 92px; }

/* ---------- per-code detail modal (replaces the old inline accordion) ---------- */
.detail-modal {
  max-width: 760px;
  width: min(94vw, 760px);
  /* max-height/overflow now come from the top-anchored dialog[open] rule above (higher specificity than
     this class alone would win the property anyway — dropped here to avoid two conflicting values) */
}

.detail-modal .dialog-head { position: sticky; top: 0; background: var(--panel); z-index: 1; }

.detail-modal .detail-table th,
.detail-modal .detail-table td { padding: 12px 14px; }

.detail-modal .dialog-body { padding: 6px clamp(14px, 2.4vw, 22px) 20px; }

.detail-modal .body-summary { margin: 4px 0 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }

  .side-nav {
    position: static;
    max-height: none;
    order: -1;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
  }

  .side-nav[data-collapsed="true"] .nav-body { display: none; }

  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
  }

  .side-nav h2 { margin-bottom: 0; }

  .nav-body { margin-top: 10px; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }

  .toolbar { padding: 8px 0; }

  .card-head { padding: 11px 12px; }

  .metric-total {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    width: 100%;
    padding: 0 0 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .detail-table,
  .detail-table tbody,
  .detail-table tr,
  .detail-table th,
  .detail-table td { display: block; width: 100%; }

  .detail-table tr { border-bottom: 1px solid var(--border); }

  .detail-table tr:last-child { border-bottom: 0; }

  .detail-table tbody th {
    border-bottom: 0;
    padding-bottom: 2px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: transparent;
    min-width: 0;
  }

  .detail-table tbody td { padding-top: 0; border-bottom: 0; }

  .decision-row { grid-template-columns: repeat(2, 1fr); gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  .toolbar, .side-nav, .response-panel, .floating-actions, .progress-wrap, .toast, .empty-state, .card-quick { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; border-color: #999; }
  .prose-section { box-shadow: none; border-color: #999; break-inside: avoid; }
  .prose-section[data-collapsible] > summary { display: none; }
  a { color: #000; text-decoration: underline; }
  /* detail modals are normally only reachable via showModal(); force them fully visible in print output */
  dialog.detail-modal {
    display: block !important;
    position: static !important;
    max-width: none;
    width: 100%;
    max-height: none;
    overflow: visible;
    border: 1px solid #999;
    box-shadow: none;
    break-inside: avoid;
    margin: 0 0 14px;
  }
  dialog.detail-modal::backdrop { display: none; }
}
