/**
 * QA Report — formal defect-report format.
 *
 * The report reads as a professional QA deliverable: strict gridline
 * tables, a washed label column, monospace data, severity as colored
 * text with a dot marker. No cards, no pills, no shadows — the tables
 * ARE the design. Severity color is semantic, never decorative.
 *
 * Scoped entirely under .qa-report with >=2-class selectors so these
 * rules win inside every host container (prime admin, prime client,
 * CRM admin). The interactive accent inherits the host's --secondary.
 * Do not rename .qa-* classes — the formatter emits them and prime's
 * purifier whitelists them.
 */

.qa-report {
    --qa-ink: #1B2430;
    --qa-muted: #5F6C7B;
    --qa-faint: #8A97A5;
    --qa-line: #D8DFE7;
    --qa-wash: #F4F6F9;
    --qa-accent: var(--secondary, #00B4D8);

    --qa-critical: #B42318;
    --qa-high: #9A5B00;
    --qa-medium: #0E7490;
    --qa-low: #1B7A45;
    --qa-info: #475467;

    --qa-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

    color: var(--qa-ink);
    font-size: 14.5px;
    line-height: 1.65;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* ── Document headings ──────────────────────────────────────────────────── */

.qa-report .qa-h1 {
    font-size: 25px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--qa-ink);
    margin: 0 0 22px 0;
    padding: 0 0 14px 0;
    border-bottom: 2px solid var(--qa-ink);
}

.qa-report .qa-h2 {
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--qa-ink);
    margin: 34px 0 12px 0;
    padding: 0 0 6px 0;
    border: none;
    border-bottom: 1px solid var(--qa-line);
}

.qa-report .qa-h1 + .qa-h2,
.qa-report .qa-h2:first-child {
    margin-top: 22px;
}

.qa-report p {
    margin: 0 0 13px 0;
}

.qa-report a {
    color: var(--qa-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.qa-report code {
    font-family: var(--qa-mono);
    font-size: 0.88em;
    color: var(--qa-ink);
    background: transparent;
    border: none;
    padding: 0;
}

/* ── Tables: the document's structural voice ────────────────────────────── */

.qa-report .qa-table-wrap {
    overflow-x: auto;
    margin: 0 0 10px 0;
}

.qa-report .qa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    background: #FFFFFF;
    border: 1px solid var(--qa-line);
}

.qa-report .qa-table th,
.qa-report .qa-table td {
    text-align: left;
    padding: 8px 12px;
    border: 1px solid var(--qa-line);
    vertical-align: top;
}

.qa-report .qa-table thead th {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--qa-muted);
    background: var(--qa-wash);
}

.qa-report .qa-table tbody tr:nth-child(even) { background: transparent; }

/* Environment: key/value spec sheet — no header row, washed label column,
   monospace values. */
.qa-report .qa-env-table { max-width: 640px; }
.qa-report .qa-env-table thead { display: none; }

.qa-report .qa-env-table td:first-child {
    width: 36%;
    background: var(--qa-wash);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qa-muted);
}

.qa-report .qa-env-table td:last-child {
    font-family: var(--qa-mono);
    font-size: 12.5px;
}

/* Issue Summary index */
.qa-report .qa-summary-table td:nth-child(2) { width: 52%; }

.qa-report .qa-sid {
    font-family: var(--qa-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--qa-ink);
    white-space: nowrap;
}

/* ── Coverage ledger (Test Coverage / Standard Checks) ──────────────────── */

.qa-report .qa-checks {
    list-style: none;
    margin: 0 0 14px 0;
    padding: 0;
    border: 1px solid var(--qa-line);
    border-bottom: none;
}

.qa-report .qa-checks > li {
    display: grid;
    grid-template-columns: 96px 1fr;
    align-items: baseline;
    gap: 0 14px;
    margin: 0;
    padding: 8px 12px;
    border-bottom: 1px solid var(--qa-line);
    font-size: 13.5px;
}

.qa-report .qa-check-status {
    grid-column: 1;
    justify-self: start;
    font-family: var(--qa-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border: 1px solid currentColor;
    border-radius: 3px;
    white-space: nowrap;
}

/* Verdict we could not read: let the sentence use the full row. */
.qa-report .qa-checks > li.qa-check-plain {
    display: block;
    color: var(--qa-ink);
}

.qa-report .qa-st-pass    { color: var(--qa-low); }
.qa-report .qa-st-fail    { color: var(--qa-critical); }
.qa-report .qa-st-blocked { color: var(--qa-high); }
.qa-report .qa-st-skipped { color: var(--qa-faint); }
.qa-report .qa-st-warn    { color: var(--qa-high); }
.qa-report .qa-st-na      { color: var(--qa-faint); }

/* Name + detail share one cell so the sentence never wraps under the chip */
.qa-report .qa-check-body {
    grid-column: 2;
    color: var(--qa-muted);
}

.qa-report .qa-check-name {
    font-weight: 600;
    color: var(--qa-ink);
}

.qa-report .qa-check-name::after {
    content: " —";
    color: var(--qa-faint);
    font-weight: 400;
}

/* ── Findings: each issue is a defect table ─────────────────────────────── */

.qa-report .qa-issue {
    position: static;
    background: #FFFFFF;
    border: 1px solid var(--qa-line);
    border-radius: 0;
    padding: 0;
    margin: 0 0 22px 0;
    box-shadow: none;
    --sev: var(--qa-info);
}

.qa-report .qa-issue:has(.qa-sev-critical) { --sev: var(--qa-critical); }
.qa-report .qa-issue:has(.qa-sev-high)     { --sev: var(--qa-high); }
.qa-report .qa-issue:has(.qa-sev-medium)   { --sev: var(--qa-medium); }
.qa-report .qa-issue:has(.qa-sev-low)      { --sev: var(--qa-low); }

/* Header band: ID cell · title · severity */
.qa-report .qa-issue-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    background: var(--qa-wash);
    border-bottom: 1px solid var(--qa-line);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--qa-ink);
    margin: 0;
    padding: 10px 14px;
}

.qa-report .qa-issue-id {
    /* Fixed basis so the divider continues the label column's rule below */
    position: static;
    box-sizing: border-box;
    flex: 0 0 134px;
    font-family: var(--qa-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--sev);
    background: transparent;
    border: none;
    border-right: 1px solid var(--qa-line);
    border-radius: 0;
    padding: 0 12px 0 0;
    line-height: 1.4;
}

.qa-report .qa-issue-name { flex: 1 1 auto; }

.qa-report .qa-issue-title .qa-badge { margin-left: auto; }

.qa-report .qa-badge {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sev);
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    white-space: nowrap;
}

.qa-report .qa-badge::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 6px;
    vertical-align: 1px;
}

/* Severity color also applies where the badge sits in a summary row */
.qa-report .qa-sev-critical { --sev: var(--qa-critical); color: var(--qa-critical); }
.qa-report .qa-sev-high     { --sev: var(--qa-high);     color: var(--qa-high); }
.qa-report .qa-sev-medium   { --sev: var(--qa-medium);   color: var(--qa-medium); }
.qa-report .qa-sev-low      { --sev: var(--qa-low);      color: var(--qa-low); }
.qa-report .qa-sev-info     { --sev: var(--qa-info);     color: var(--qa-info); }

/* Field grid: the defect form body — washed label column, gridline rows */
.qa-report .qa-fields {
    display: grid;
    grid-template-columns: 148px 1fr;
    margin: 0;
}

.qa-report .qa-fields .qa-field-label {
    background: var(--qa-wash);
    border-bottom: 1px solid var(--qa-line);
    border-right: 1px solid var(--qa-line);
    padding: 9px 14px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--qa-muted);
    line-height: 2;
}

.qa-report .qa-fields .qa-field-value {
    margin: 0;
    border-bottom: 1px solid var(--qa-line);
    padding: 9px 14px;
    font-size: 14px;
}

.qa-report .qa-fields .qa-field-label:last-of-type,
.qa-report .qa-fields .qa-field-value:last-of-type {
    border-bottom: none;
}

.qa-report .qa-field-empty { color: var(--qa-faint); }

/* Repro steps keep their numbering inside the value cell */
.qa-report .qa-fields .qa-field-value .qa-steps {
    margin: 4px 0 2px 0;
    padding-left: 20px;
}

.qa-report .qa-fields .qa-field-value .qa-steps li {
    margin-bottom: 3px;
}

.qa-report .qa-fields .qa-field-value .qa-steps li::marker {
    font-family: var(--qa-mono);
    font-size: 0.82em;
    color: var(--qa-faint);
}

/* Evidence supplied inside a field value: left-aligned, compact */
.qa-report .qa-fields .qa-field-value .qa-figure {
    margin: 6px 0 2px 0;
    text-align: left;
    border: none;
    padding: 0;
}

.qa-report .qa-fields .qa-field-value .qa-figure img { margin: 0; }
.qa-report .qa-fields .qa-field-value .qa-figcaption { text-align: left; }

/* Evidence standing alone in a finding spans the card */
.qa-report .qa-issue > .qa-figure {
    border-top: 1px solid var(--qa-line);
    margin: 0;
    padding: 16px 14px;
    max-width: none;
}

/* ── Evidence figures ───────────────────────────────────────────────────── */

.qa-report .qa-figure {
    margin: 18px 0 10px;
    text-align: center;
}

.qa-report .qa-figure img {
    display: block;
    max-width: min(300px, 100%);
    max-height: 500px;
    width: auto;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    border: 1px solid var(--qa-line);
    border-radius: 4px;
    box-shadow: none;
    cursor: zoom-in;
    background: var(--qa-wash);
}

.qa-report .qa-figcaption {
    font-family: var(--qa-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--qa-faint);
    margin-top: 8px;
}

/* ── Lists, quotes ──────────────────────────────────────────────────────── */

.qa-report ul,
.qa-report ol {
    margin: 0 0 13px 0;
    padding-left: 24px;
}

.qa-report li { margin-bottom: 5px; }

.qa-report .qa-quote {
    border-left: 2px solid var(--qa-line);
    background: transparent;
    font-style: normal;
    color: var(--qa-muted);
    margin: 16px 0;
    padding: 2px 0 2px 16px;
    border-radius: 0;
}

.qa-report hr {
    border: none;
    border-top: 1px solid var(--qa-line);
    margin: 26px 0;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .qa-report { font-size: 14px; }
    .qa-report .qa-h1 { font-size: 21px; }

    .qa-report .qa-fields { grid-template-columns: 108px 1fr; }
    .qa-report .qa-issue-id { flex-basis: 98px; }
    .qa-report .qa-fields .qa-field-label {
        padding: 8px 10px;
        font-size: 10px;
        line-height: 1.9;
    }
    .qa-report .qa-fields .qa-field-value { padding: 8px 10px; font-size: 13.5px; }

    .qa-report .qa-issue-title { padding: 9px 10px; }
    .qa-report .qa-env-table td:first-child { width: 42%; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */

@media print {
    .qa-report .qa-issue,
    .qa-report .qa-figure { break-inside: avoid; }
    .qa-report .qa-figure img { box-shadow: none; }
}

/* ── Coverage tables with a Result/Status column ────────────────────────── */

.qa-report .qa-status-table td .qa-check-status {
    display: inline-block;
    font-size: 9.5px;
}

.qa-report .qa-status-table th:first-child,
.qa-report .qa-status-table td:first-child {
    font-weight: 600;
    color: var(--qa-ink);
}
