/* Farben und Schriften wie toolbox.itrain.ch */
:root {
    --it-primary: #0A2642;
    --it-primary-dark: #06182c;
    --it-accent: #144D87;
    --it-accent-hover: #0f3d6c;
    --it-sky: #6EC1E4;
    --it-green: #23A455;
    --it-text: #2B2B2B;
    --it-muted: #54595F;
    --it-border: #e0e0e0;
    --it-bg-soft: #f9f9f9;
    --it-bg-tint: #f3f6fa;
    --pass: #23A455;
    --partial: #fd7e14;
    --fail: #cf2e2e;
    --na: #7A7A7A;
    --sev-critical: #8b1538;
    --sev-high: #cf2e2e;
    --sev-medium: #fd7e14;
    --sev-low: #c9a000;
    --sev-info: #144D87;
    --radius: 8px;
    --shadow-sm: 0 2px 10px rgba(10, 38, 66, 0.06);
    --font-heading: "Poppins", system-ui, sans-serif;
    --font-body: "Open Sans", system-ui, sans-serif;
}

body {
    font-family: var(--font-body);
    color: var(--it-text);
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { flex: 1; }

h1, h2, h3, h4 { font-family: var(--font-heading); color: var(--it-primary); }
h1 { font-size: 1.9rem; font-weight: 600; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; margin-top: 1rem; }

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

.it-header { background: var(--it-primary); color: #fff; padding: 0.9rem 0; }
.it-brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; line-height: 1.1; }
.it-brand-small { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--it-sky); }
.it-brand-name { font-family: var(--font-heading); font-weight: 600; font-size: 1.15rem; }
.it-nav { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.it-nav a { color: #fff; text-decoration: none; font-weight: 500; }
.it-nav a:hover { color: var(--it-sky); }
.it-user { color: var(--it-sky); font-size: 0.85rem; }

.it-footer { border-top: 1px solid var(--it-border); color: var(--it-muted); font-size: 0.85rem; padding: 1rem 0; margin-top: 3rem; }

.it-hero { background: var(--it-bg-tint); border-radius: var(--radius); padding: 2.5rem; }
.it-eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.75rem; color: var(--it-accent); font-weight: 600; }

.it-card { background: #fff; border: 1px solid var(--it-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem; }
.it-count { font-size: 0.85rem; color: var(--it-muted); }

.btn-it { background: var(--it-accent); border-color: var(--it-accent); color: #fff; }
.btn-it:hover { background: var(--it-accent-hover); border-color: var(--it-accent-hover); color: #fff; }
.btn-it-outline { border: 1px solid var(--it-accent); color: var(--it-accent); background: #fff; }
.btn-it-outline:hover, .btn-it-outline.active { background: var(--it-accent); color: #fff; }

.it-progress { background: var(--it-accent); transition: width 0.4s; }

.it-table th { font-family: var(--font-heading); font-weight: 500; color: var(--it-primary); font-size: 0.85rem; }
.it-table .row-fail td { background: #fff5f5; }

/* Score */
.score-card { text-align: center; border-top: 6px solid var(--na); }
.score-card.score-good { border-top-color: var(--pass); }
.score-card.score-mid { border-top-color: var(--partial); }
.score-card.score-bad { border-top-color: var(--fail); }
.score-value { font-family: var(--font-heading); font-size: 3.6rem; font-weight: 700; color: var(--it-primary); line-height: 1; }
.score-grade { font-weight: 600; color: var(--it-muted); }

.score-bar { display: inline-block; width: calc(100% - 3rem); height: 0.6rem; background: #eee; border-radius: 3px; overflow: hidden; vertical-align: middle; }
.score-bar > div { height: 100%; }
.score-bar .score-good { background: var(--pass); }
.score-bar .score-mid { background: var(--partial); }
.score-bar .score-bad { background: var(--fail); }

.status-counts li { margin-bottom: 0.3rem; }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.5rem; }
.dot.st-pass { background: var(--pass); }
.dot.st-partial { background: var(--partial); }
.dot.st-fail { background: var(--fail); }
.dot.st-na { background: var(--na); }
.dot.st-error { background: #000; }

/* Badges */
.badge-status, .badge-sev, .badge-strict, .badge-dep {
    display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 4px; white-space: nowrap;
}
.badge-status { color: #fff; min-width: 6.5rem; text-align: center; }
.badge-status.st-pass { background: var(--pass); }
.badge-status.st-partial { background: var(--partial); }
.badge-status.st-fail { background: var(--fail); }
.badge-status.st-na { background: var(--na); }
.badge-status.st-error { background: #000; }
.badge-sev { border: 1px solid currentColor; }
.sev-critical { color: var(--sev-critical); }
.sev-high { color: var(--sev-high); }
.sev-medium { color: var(--sev-medium); }
.sev-low { color: var(--sev-low); }
.sev-info { color: var(--sev-info); }
.badge-strict { background: var(--it-primary); color: #fff; }

.it-actions li { margin-bottom: 0.6rem; }

/* Massnahmenplan und Folgebefunde */
.plan-tier { margin-top: 1.5rem; padding-left: 0.6rem; border-left: 5px solid var(--na); font-size: 1.15rem; }
.plan-tier.tier-1 { border-left-color: var(--fail); }
.plan-tier.tier-2 { border-left-color: var(--partial); }
.plan-tier.tier-3 { border-left-color: var(--it-primary); }
.plan-dependents { margin-top: 0.2rem; }
.plan-dependents a { margin-left: 0.35rem; }
.badge-dep { border: 1px dashed var(--it-muted); color: var(--it-muted); }
.badge-dep a { color: inherit; }

/* Domain-Übersicht */
.domain-matrix .cell { display: inline-block; width: 1.8rem; height: 1.8rem; line-height: 1.8rem; border-radius: 50%; color: #fff; font-weight: 700; cursor: help; }
.domain-matrix .cell.st-pass { background: var(--pass); }
.domain-matrix .cell.st-partial { background: var(--partial); }
.domain-matrix .cell.st-fail { background: var(--fail); }
.domain-matrix .cell.st-na { background: transparent; color: var(--na); }
.domain-matrix .row-excluded td { color: var(--na); background: var(--it-bg-soft); }
.domain-matrix .role-select { min-width: 9rem; }

/* Checks */
details.check { border: 1px solid var(--it-border); border-left: 5px solid var(--na); border-radius: var(--radius); margin-bottom: 0.5rem; background: #fff; }
details.check.st-pass { border-left-color: var(--pass); }
details.check.st-partial { border-left-color: var(--partial); }
details.check.st-fail { border-left-color: var(--fail); }
details.check.st-error { border-left-color: #000; }
details.check > summary { cursor: pointer; padding: 0.6rem 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; list-style: none; }
details.check > summary::-webkit-details-marker { display: none; }
.check-id { font-family: monospace; color: var(--it-muted); font-size: 0.85rem; }
.check-title { font-weight: 600; }
.check-summary { flex-basis: 100%; font-size: 0.85rem; color: var(--it-muted); padding-left: 7rem; }
.check-body { padding: 0 1rem 1rem 1rem; border-top: 1px solid var(--it-border); padding-top: 0.8rem; }

.code-block { position: relative; margin-bottom: 0.8rem; }
.code-block pre { background: var(--it-primary-dark); color: #e8eef5; border-radius: 6px; padding: 0.9rem; font-size: 0.82rem; white-space: pre-wrap; word-break: break-word; margin: 0; }
.btn-copy { position: absolute; top: 0.4rem; right: 0.4rem; background: rgba(255, 255, 255, 0.15); color: #fff; border: none; }
.btn-copy:hover { background: rgba(255, 255, 255, 0.3); color: #fff; }

/* Ausführungsort einer Massnahme */
.remediation-where { margin-bottom: 0.6rem; }
.remediation-where code { background: #eef2f6; color: var(--it-primary-dark); padding: 0.1rem 0.4rem; border-radius: 4px; word-break: break-all; }
.btn-copy-inline { padding: 0 0.45rem; font-size: 0.72rem; line-height: 1.5; vertical-align: baseline; }
.remediation-target h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }

/* Einrichtung */
.setup-step { display: flex; gap: 1.25rem; align-items: flex-start; }
.setup-step > div:last-child { flex: 1; min-width: 0; }
.setup-number {
    flex: 0 0 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--it-accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-family: var(--font-heading); font-weight: 700; font-size: 1.2rem;
}
.setup-step h2 { font-size: 1.25rem; }
.setup-step h3 { font-size: 1rem; }

/* Erläuterungen */
.info-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.35rem; height: 1.35rem; border-radius: 50%;
    border: 1px solid var(--it-accent); background: #fff; color: var(--it-accent);
    font: italic 700 0.8rem/1 Georgia, serif; padding: 0; cursor: pointer; vertical-align: middle;
}
.info-btn:hover, .info-btn:focus-visible { background: var(--it-accent); color: #fff; outline: none; }

.explain-dialog {
    width: min(46rem, calc(100vw - 2rem)); max-height: calc(100vh - 3rem);
    border: none; border-radius: var(--radius); padding: 0; box-shadow: 0 12px 40px rgba(10, 38, 66, 0.25);
}
.explain-dialog::backdrop { background: rgba(10, 38, 66, 0.45); }
.explain-dialog-header {
    position: sticky; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
    background: var(--it-primary); color: #fff; padding: 1rem 1.25rem;
}
.explain-dialog-header h3 { color: #fff; margin: 0; font-size: 1.1rem; }
.explain-dialog-header .btn-close { filter: invert(1); }
#explain-body { padding: 1rem 1.25rem 1.25rem; }

.explanation h5 { font-family: var(--font-heading); font-size: 0.9rem; font-weight: 600; color: var(--it-primary); margin: 1rem 0 0.25rem; }
.explanation p { margin-bottom: 0.25rem; }
.explanation-head { display: flex; gap: 0.75rem; align-items: center; }
.explanation-result { background: var(--it-bg-soft); border-left: 4px solid var(--na); padding: 0.25rem 0.75rem 0.5rem; margin-top: 0.75rem; border-radius: 4px; }
.explanation-result.st-pass { border-left-color: var(--pass); }
.explanation-result.st-partial { border-left-color: var(--partial); }
.explanation-result.st-fail { border-left-color: var(--fail); }
.explanation-example { background: var(--it-bg-tint); padding: 0.25rem 0.75rem 0.5rem; border-radius: 4px; margin-top: 0.75rem; }
.explanation-print { display: none; }

@media (max-width: 576px) {
    .check-summary { padding-left: 0; }
    .it-hero { padding: 1.5rem; }
}

.print-only { display: none; }

/* Druck und PDF: A4, kompakt, Farben mitdrucken, nur Befunde ausführlich */
@media print {
    @page { size: A4; margin: 14mm 12mm; }
    html { font-size: 9pt; }
    body { -webkit-print-color-adjust: exact; print-color-adjust: exact; min-height: 0; display: block; }

    .no-print, .it-header nav, .it-footer, .explain-dialog { display: none !important; }
    .print-only { display: inline; }
    .container { max-width: none !important; width: 100% !important; padding: 0 !important; }
    main.container { padding-top: 0 !important; }
    .it-header { background: none; color: var(--it-primary); padding: 0 0 0.5rem; border-bottom: 2px solid var(--it-primary); }
    .it-brand { color: var(--it-primary); }

    /* Kacheln wie am Bildschirm nebeneinander, A4 ist schmaler als der Bootstrap-Breakpoint */
    .row { display: flex; flex-wrap: wrap; }
    .row > .col-md-4, .row > .col-lg-4 { flex: 0 0 auto; width: 33.333%; }
    .row > .col-md-6, .row > .col-lg-6 { flex: 0 0 auto; width: 50%; }
    .it-card { box-shadow: none; padding: 0.75rem; }
    .score-value { font-size: 2.6rem; }

    /* Seitenumbrüche: kleine Blöcke zusammenhalten, Überschriften nicht allein am Seitenende */
    h1, h2, h3, h4, h5 { break-after: avoid; page-break-after: avoid; }
    details.check { break-inside: auto; margin-bottom: 0.35rem; }
    details.check > summary, .it-table tr, .code-block, .it-card, .explanation section, .explanation-head { break-inside: avoid; }
    .it-table { font-size: 0.85rem; }
    .it-table td.text-break { word-break: break-word; }

    /* Prüfungen: erfüllte als eine Zeile, Befunde mit Erläuterung, ohne Doppelungen */
    details.check > summary { padding: 0.35rem 0.6rem; }
    details.check:not([open]) .check-summary { flex-basis: auto; padding-left: 0; }
    details.check.st-pass .check-summary { display: none; }
    .check-summary { padding-left: 0; }
    .check-body { padding: 0.5rem 0.75rem 0.75rem; }
    .check-rationale { display: none; }
    .explanation-print { display: block; margin: 0 0 0.75rem; }
    .explanation-print .explanation-recommendation, .explanation-print .explanation-head { display: none; }
    .explanation h5 { margin-top: 0.6rem; }
    .code-block pre { background: #f3f3f3; color: #000; }

    .domain-matrix .role-select { display: none; }
    a { color: inherit; text-decoration: none; }
}
