/* Corporate Identity brands & values
 * ---------------------------------------------------------------------------
 * Farben und Schriften stammen aus dem Stylesheet der Website selbst
 * (`brandsandvalues.com/assets/css/framework.css`), nicht aus einer
 * Bildschirmabnahme: Sand #E0D9C9 als haeufigste Flaeche, Salbei #4D6B60 als
 * Primaerton, Tiefgruen #183A36 als dunkler Grund, Ocker #BAA933 als Akzent,
 * Koralle #F45F4B als Signal. Schriften Roboto und Roboto Condensed.
 *
 * Die uebrigen rund 130 Farben der Oberflaeche wurden nicht einzeln neu
 * gewaehlt, sondern **im Farbton gedreht und in der Helligkeit belassen**.
 * Die Helligkeit traegt den Kontrast - wer sie anfasst, macht aus lesbarem
 * Text unlesbaren; der Farbton traegt die Identitaet. Deshalb bleiben alle
 * Abstufungen erhalten, die die Oberflaeche vorher schon gemacht hat.
 */
:root {
    --bv-sand:        #e0d9c9;
    --bv-sand-hell:   #f2eee4;
    --bv-sand-dunkel: #ccc4af;
    --bv-salbei:      #4d6b60;
    --bv-tiefgruen:   #183a36;
    --bv-oliv:        #6c7947;
    --bv-ocker:       #baa933;
    --bv-braun:       #3d2e09;
    --bv-koralle:     #f45f4b;
    --bv-rost:        #963a2e;

    --schrift-text:   'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --schrift-titel:  'Roboto Condensed', 'Roboto', Helvetica, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* `hidden` muss staerker sein als jede Klassenregel.
 *
 * Das `display: none` des `hidden`-Attributs kommt aus dem Stylesheet des
 * Browsers und hat die Spezifitaet eines Typselektors. Jede Klassenregel mit
 * eigenem `display` schlaegt es - und das Element bleibt sichtbar, obwohl
 * `hidden` gesetzt ist.
 *
 * Genau daran ist der Schliessknopf der Ausfuellhilfe gescheitert:
 * `.assistant-panel` setzt `display: flex`, also blieb das Panel stehen -
 * beim Schliessen wie beim Laden der Seite. Im JavaScript war nichts falsch,
 * deshalb war es dort auch nicht zu finden.
 *
 * Als eine Regel fuer alle statt als Reparatur an einer Klasse: sonst faellt
 * das naechste Element mit eigenem `display` in dieselbe Falle.
 */
[hidden] {
    display: none !important;
}

/* Der Grund der gesamten Anwendung: die Sage-Textur der CI.
 *
 * `background-color` steht als Rueckfallebene DARUNTER und nicht nur der
 * Vollstaendigkeit halber: solange das Bild laedt - und es ist gross -, ist
 * es die Flaeche, die der Anwender sieht. Ohne sie waere das fuer einen
 * Moment Weiss, und die weissen Karten haetten keine Kante.
 *
 * Die Textur steht beim Blaettern still - aber NICHT ueber
 * `background-attachment: fixed`. Das war der erste Versuch, und er hat
 * sichtbar gerissen: beim Scrollen blieb eine leere Flaeche stehen, wo Inhalt
 * haette sein muessen, und erst nach dem Anhalten zeichnete Chrome sie
 * richtig. `fixed` zwingt den Browser, das Bild bei JEDEM Scrollschritt neu
 * gegen den Inhalt zu rechnen; bei 2752 x 1536 Pixeln kommt er nicht nach.
 *
 * Stattdessen eine eigene Ebene hinter allem (`body::before`, fest
 * positioniert, `z-index: -1`). Die wird einmal zusammengesetzt und beim
 * Scrollen nur verschoben - kein Neuzeichnen.
 *
 * Gesetzt in `style.css`, weil ALLE Seiten sie zuerst laden. Die beiden
 * Farbverlaeufe, die den Grund vorher setzten (`auth-pages.css` und der
 * `<style>`-Block in `select-epd.html`), sind entfernt - sonst haetten sie
 * das hier ueberschrieben, und die Textur waere nur auf dem Bogen zu sehen.
 */
body {
    font-family: var(--schrift-text);
    background-color: var(--bv-salbei);
    color: var(--bv-braun);
    line-height: 1.6;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url('bg.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

/* Überschriften in der schmalen Schnittvariante — so setzt die Website ihre
   Titel. Der Unterschied zwischen Roboto und Roboto Condensed ist das, was
   die Typografie überhaupt als CI erkennbar macht; nur eine Familie zu
   verwenden sähe aus wie jede Standardanwendung. */
h1, h2, h3, h4, legend, .stat b {
    font-family: var(--schrift-titel);
    letter-spacing: 0.01em;
}

header {
    background: linear-gradient(135deg, var(--bv-tiefgruen), var(--bv-salbei));
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.app-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Die Bildmarke von brands & values.
 *
 * Sie ist hochkant (468 x 640) - deshalb ueber die HOEHE bemessen und die
 * Breite automatisch. Ueber die Breite bemessen waere sie je nach Seite
 * unterschiedlich hoch.
 *
 * Das Ocker der Marke ist derselbe Ton wie der B&V-AI-Knopf. Das ist kein
 * Widerspruch zu "ein Akzent": der Knopf ist der einzige ockerfarbene
 * BEDIENELEMENT, die Marke ist Identitaet und keine Schaltflaeche. Damit sie
 * nicht mit ihm um Aufmerksamkeit ringt, bleibt sie klein und sitzt am
 * gegenueberliegenden Rand.
 */
.bv-mark {
    height: 2rem;
    width: auto;
    display: block;
    flex-shrink: 0;
}

/* Auf den Karten von Anmeldung, Einladung und Projektauswahl steht sie
   ueber dem Titel und darf groesser sein - dort ist Platz, und die Seite
   ist der Eintritt in die Anwendung. */
.auth-header .bv-mark,
.epd-header .bv-mark {
    height: 3.25rem;
    margin: 0 auto 1rem;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.2);
}

.nav-btn.active {
    background: white;
    color: #183a36;
}

main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.section {
    display: none;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section.active {
    display: block;
}

h2 {
    color: #183a36;
    border-bottom: 2px solid #4d6b60;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

h3 {
    color: #4d6b60;
    margin: 1rem 0 0.5rem;
}

fieldset {
    border: 1px solid #dfdedb;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

legend {
    font-weight: bold;
    color: #183a36;
    padding: 0 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: #595751;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dfdedb;
    border-radius: 4px;
    font-size: 1rem;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #4d6b60;
    box-shadow: 0 0 0 2px rgba(86, 140, 124, 0.2);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

small {
    display: block;
    color: #6f6b63;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Ankreuzfelder, Auswahlknöpfe und Fortschrittsbalken in der CI.
 *
 * Ohne `accent-color` malt der Browser sie im Systemton — unter Windows ein
 * kräftiges Blau, das nach der Umstellung die einzige blaue Fläche der
 * Anwendung war und genau deshalb ins Auge sprang. Eine Zeile, die den
 * letzten Rest des alten Farbschemas erwischt.
 *
 * Auf `:root`, nicht auf einzelne Selektoren: `accent-color` vererbt sich,
 * und jedes künftige Bedienelement ist damit von selbst richtig. */
:root {
    accent-color: var(--bv-salbei);
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #efeeed;
}

.tab-btn {
    background: #f5f5f5;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s;
}

.tab-btn:hover {
    background: #e2e1de;
}

.tab-btn.active {
    background: #4d6b60;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid #dfdedb;
    max-width: 100%;
}

.dynamic-table {
    width: auto;
    border-collapse: collapse;
    margin-bottom: 0;
    font-size: 0.75rem;
    min-width: 100%;
    table-layout: auto;
}

.dynamic-table th,
.dynamic-table td {
    border: 1px solid #dfdedb;
    padding: 0.35rem 0.5rem;
    text-align: left;
    white-space: nowrap;
}

.dynamic-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #595751;
    position: sticky;
    top: 0;
    z-index: 1;
    cursor: col-resize;
    user-select: none;
}

.dynamic-table th::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 4px;
    background-color: #cfcdc9;
    opacity: 0;
    transition: opacity 0.2s;
}

.dynamic-table th:hover::after {
    opacity: 1;
}

.dynamic-table th.resizing {
    cursor: col-resize;
    background: #e2e1de;
}

.dynamic-table th.resizing::after {
    opacity: 1;
    background-color: #4d6b60;
}

.dynamic-table input,
.dynamic-table select {
    width: 100%;
    border: none;
    padding: 0.2rem;
    font-size: 0.75rem;
    background: transparent;
}

.dynamic-table input:focus,
.dynamic-table select:focus {
    outline: 1px solid #4d6b60;
    box-shadow: none;
    background: white;
}

.dynamic-table tbody tr:not([class^="stufe-"]):hover {
    background-color: #f8faf9;
}

.dynamic-table th.col-wide,
.dynamic-table td.col-wide {
    width: 150px;
}

.dynamic-table tbody tr.stufe-0 { background-color: #ffffff; }
.dynamic-table tbody tr.stufe-1 { background-color: #183a36; color: white; }
.dynamic-table tbody tr.stufe-2 { background-color: #4d6b60; color: white; }
.dynamic-table tbody tr.stufe-3 { background-color: #a6c8be; }
.dynamic-table tbody tr.stufe-4 { background-color: #dce9e5; }
.dynamic-table tbody tr.stufe-1 input,
.dynamic-table tbody tr.stufe-1 select,
.dynamic-table tbody tr.stufe-2 input,
.dynamic-table tbody tr.stufe-2 select { color: white; }

.btn-add {
    background: #6c7947;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-add:hover {
    background: #5c6739;
}

.btn-delete {
    background: #c14a38;
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-delete:hover {
    background: #963a2e;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 2px solid #efeeed;
}

.btn-save {
    background: #4d6b60;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.btn-save:hover {
    background: #183a36;
}

.btn-export {
    background: #7a756a;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.btn-export:hover {
    background: #6d6961;
}

/* Der JSON-Abzug ist der Nebenweg - der Bogen ist das, womit weitergearbeitet
   wird. Gleiche Form, weniger Gewicht. */
.btn-export-secondary {
    background: none;
    color: #7a756a;
    border: 1px solid #bcc8c4;
}

.btn-export-secondary:hover {
    background: #edf0ef;
    color: #566a64;
}

/* Exportbericht: was in der Datei steht - und was nicht. Dieselbe Rolle wie
   der Importbericht, deshalb dieselbe Anmutung. */
.export-report {
    margin: 1rem 2rem 2rem;
    padding: 1rem 1.25rem;
    background: #f8faf9;
    border: 1px solid #e2e7e6;
    border-radius: 6px;
}

.export-report h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: #334942;
}

.export-report-sheets {
    list-style: none;
    margin: 0;
    padding: 0;
}

.export-report-sheets li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid #eef1f0;
    font-size: 0.875rem;
}

.export-report-sheets li:last-child {
    border-bottom: none;
}

.export-report-sheet {
    min-width: 14rem;
    font-weight: 600;
    color: #334942;
}

.export-report-count {
    color: #45715b;
    font-variant-numeric: tabular-nums;
}

.export-report-blocks {
    color: #7a756a;
}

.export-report-note {
    flex-basis: 100%;
    margin-top: 0.25rem;
    padding-left: 0.75rem;
    border-left: 3px solid #c7b53e;
    color: #7b733a;
    font-size: 0.825rem;
    line-height: 1.45;
}

.status-message {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s;
}

.status-message.success {
    background: #6c7947;
    opacity: 1;
}

.status-message.error {
    background: #c14a38;
    opacity: 1;
}

@media (max-width: 768px) {
    .dynamic-table {
        font-size: 0.75rem;
    }

    .dynamic-table th,
    .dynamic-table td {
        padding: 0.25rem;
    }

    nav {
        gap: 0.25rem;
    }

    .nav-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
}

.help-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.help-wrapper label {
    flex: 1;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #6e877f;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.help-icon:hover {
    background: #4d6b60;
}

.tooltip {
    position: absolute;
    background: #334942;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    max-width: 400px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    line-height: 1.4;
}

.tooltip::before {
    content: '?';
    position: absolute;
    top: -10px;
    left: 15px;
    background: #334942;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.form-group .tooltip {
    margin-top: 0.25rem;
}

.tooltip-close {
    position: absolute;
    top: 5px;
    right: 8px;
    cursor: pointer;
    font-size: 16px;
    color: #cfcdc9;
}

.tooltip-close:hover {
    color: white;
}

.btn-upload {
    background: #5c9579;
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.3s;
}

.btn-upload:hover {
    background: #51836a;
}

.import-status {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.import-status.success {
    background: #e4ead7;
    color: #3d4725;
}

.import-status.error {
    background: #f7dcd8;
    color: #70291e;
}

.import-status.info {
    background: #dae8e4;
    color: #29433b;
}

.import-status.warning {
    background: #f4f0d8;
    color: #6a601f;
}

/* Summenzeilen des Bogens, die nicht zu ihren Unterzeilen passen. */
.import-discrepancies {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid #d4c66a;
    background: #fcfbf3;
    font-size: 0.85rem;
}

.import-discrepancies h4 {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    color: #867d3f;
}

.import-discrepancies ul {
    margin: 0 0 0.5rem 1.1rem;
    padding: 0;
}

.import-discrepancies li {
    margin-bottom: 0.25rem;
}

.import-discrepancies p {
    margin: 0;
    color: #6b6861;
    font-style: italic;
}

.io-balance-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8faf9;
    border-radius: 8px;
    border: 1px solid #dfe5e3;
}

.io-balance-panel h3 {
    margin-bottom: 0.75rem;
    color: #485853;
    font-size: 1rem;
}

.io-balance-content {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.io-balance-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid #eaeeed;
}

.io-balance-row.total {
    font-weight: 600;
    border-bottom: 2px solid #aebcb8;
    padding-top: 0.5rem;
}

.io-label {
    color: #485853;
}

.io-value {
    font-family: monospace;
    font-weight: 500;
}

.io-status {
    margin-top: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
}

.io-status.status-ok {
    background: #e4ead7;
    color: #3d4725;
}

.io-status.status-error {
    background: #f7dcd8;
    color: #70291e;
}

.btn-validate {
    background: #4f8071;
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.btn-validate:hover {
    background: #40695d;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-delete-all {
    background: #d84e39;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.btn-delete-all:hover {
    background: #c43c27;
}

.row-number {
    text-align: center;
    color: #8e8a82;
    font-size: 0.85rem;
    font-weight: 500;
    background: #f8faf9;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
}

.modal-header {
    background: linear-gradient(135deg, #183a36, #4d6b60);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 130px);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dfe5e3;
    text-align: right;
}

.btn-modal-close {
    background: #7b776e;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-modal-close:hover {
    background: #67635b;
}

.validation-loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    border: 4px solid #f4f3f2;
    border-top: 4px solid #4d6b60;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.validation-check {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    border-left: 4px solid;
}

.validation-check.passed {
    background: #e4ead7;
    border-color: #758946;
}

.validation-check.failed {
    background: #f7dcd8;
    border-color: #d84e39;
}

/* Warnungen sind fachliche Hinweise und blockieren die Freigabe nicht. */
.validation-check.warned {
    background: #f4f0d8;
    border-color: #d4c66a;
}

.validation-check.warned .validation-errors {
    color: #6a601f;
}

.validation-check.warned .validation-error-item {
    border-bottom-color: #e8e1b0;
}

.validation-check-ref {
    margin-top: 0.5rem;
    margin-left: 1.7rem;
    font-size: 0.78rem;
    color: #7b776e;
    font-style: italic;
}

.validation-debug {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #eaeeed;
    border-radius: 4px;
    font-size: 0.85rem;
}

.validation-debug div {
    padding: 0.2rem 0;
}

.validation-check-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.validation-check-icon {
    font-size: 1.2rem;
}

.validation-check-title {
    flex: 1;
}

.validation-check-message {
    font-size: 0.9rem;
    color: #485853;
    margin-left: 1.7rem;
}

.validation-errors {
    margin-top: 0.5rem;
    margin-left: 1.7rem;
    font-size: 0.85rem;
    color: #70291e;
}

.validation-error-item {
    padding: 0.25rem 0;
    border-bottom: 1px solid #f4cdc7;
}

.io-details {
    background: #f8faf9;
    padding: 0.75rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-family: monospace;
    font-size: 0.85rem;
}

.io-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
}

/* ---- Berechnungsschritte zur I/O-Bilanz (Bogen: Block BA1 und Zelle O1) ---- */

.btn-steps-toggle {
    margin-top: 0.75rem;
    padding: 0.4rem 0.9rem;
    background: transparent;
    border: 1px solid #7e958e;
    border-radius: 4px;
    color: #334942;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-steps-toggle:hover {
    background: #eaf1ef;
}

.io-steps {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #d8e0de;
    font-size: 0.85rem;
}

.io-steps h4 {
    margin: 1.2rem 0 0.3rem;
    color: #334942;
}

.io-steps h4:first-child {
    margin-top: 0;
}

.io-steps h5 {
    margin: 0.9rem 0 0.3rem;
    color: #586b65;
    font-weight: 600;
}

.io-steps-rule {
    margin: 0 0 0.5rem;
    color: #7e958e;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.8rem;
}

.io-steps-table {
    width: 100%;
    border-collapse: collapse;
}

.io-steps-table th,
.io-steps-table td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid #e5ebe9;
    text-align: right;
}

.io-steps-table th:nth-child(-n+4),
.io-steps-table td:nth-child(-n+4) {
    text-align: left;
}

.io-steps-table th {
    background: #f1f6f4;
    font-weight: 600;
}

/* Uebersprungene Zeilen bleiben sichtbar - der Bogen setzt sie auf 0,
   statt sie zu entfernen, und genau das soll nachvollziehbar sein. */
.io-steps-table tr.skipped {
    color: #9daea9;
}

.io-steps-table tr.io-steps-result td {
    border-top: 2px solid #334942;
    font-weight: 700;
}

.io-steps-cond {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.75rem;
    color: #7e958e;
}

.io-steps-reason,
.io-steps-note {
    font-size: 0.75rem;
    font-style: italic;
}

.io-steps-reason { color: #9daea9; }
.io-steps-note { color: #988a2c; }

.io-steps-check {
    margin: 0.4rem 0 0.8rem;
    font-family: Consolas, "Courier New", monospace;
}

.io-steps-check.status-ok { color: #576635; }
.io-steps-check.status-error { color: #af3624; }

.io-steps-deviation {
    margin-top: 1rem;
    padding: 0.7rem 0.9rem;
    background: #f8f6e8;
    border-left: 4px solid #b7a635;
}

.io-steps-error {
    color: #af3624;
}

.io-chain {
    margin: 0.4rem 0;
}

.io-chain-children {
    margin-left: 1.4rem;
    padding-left: 0.7rem;
    border-left: 1px solid #d8e0de;
}

.io-chain-head,
.io-chain-leaf {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
    padding: 0.15rem 0;
}

.io-chain-name {
    min-width: 12rem;
    font-weight: 600;
}

.io-chain-rule {
    flex: 1;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.78rem;
    color: #7e958e;
}

.io-chain-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Import-Befunde: dokumentierter Zuschnitt vs. echte Unklarheit */

.discrepancy-group + .discrepancy-group {
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid #e1dec6;
}

.discrepancy-group h4 {
    margin: 0 0 0.4rem;
}

.discrepancy-group.unclear h4 {
    color: #8a7d28;
}

.discrepancy-group.hint h4 {
    color: #586b65;
}

.discrepancy-group.hint {
    opacity: 0.85;
}

.discrepancy-group p {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    color: #586b65;
}

/* Spalte N: von Hand eingetragen statt aus G x K x M gerechnet. Der Bogen
   sieht das ausdruecklich vor - ohne Kennzeichnung waere im Nachhinein nicht
   mehr erkennbar, welche Zeilen eine Eingabe tragen. */
.dynamic-table input.manual-value {
    background: #f8f6e7;
    border-color: #ccbc50;
    font-weight: 600;
}

/* Vorschau der hochgeladenen Bilder (Titelbild, Prozessdiagramm). */
.image-preview {
    margin-top: 0.6rem;
}

.image-preview:empty {
    display: none;
}

.image-preview img {
    display: block;
    max-width: 320px;
    max-height: 220px;
    border: 1px solid #d6dedb;
    border-radius: 4px;
    margin-bottom: 0.4rem;
}

/* Detailbereich je Materialzeile: die Spalten des Bogens, die selten
   gebraucht werden (Output-Parameter, Parameter, Komponenten- und
   Verkaufsartikelnummer). Die Haupttabelle ist mit 23 Spalten am Limit. */
.btn-row-details {
    background: none;
    border: none;
    cursor: pointer;
    color: #7a928b;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0 0 0 0.25rem;
}

.btn-row-details.open {
    transform: rotate(90deg);
}

/* Ein befuelltes Detailfeld muss sichtbar sein, ohne dass man jede Zeile
   aufklappt - sonst verschwinden importierte Werte aus dem Blick. */
.btn-row-details.filled {
    color: #596836;
    font-weight: 700;
}

tr.material-details > td {
    background: #f7f9f8;
    border-top: none;
    padding: 0.5rem 0.75rem 0.75rem;
}

.material-details-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.material-details-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
    color: #586b65;
}

.material-details-grid input {
    min-width: 190px;
}

/* Summenzeilen des Bogens (Energieblatt I6, Abfallblatt H6). */
.dynamic-table tfoot .sum-row td {
    background: #eff4f2;
    font-weight: 600;
    border-top: 2px solid #c9d3d0;
}

/* --- Checkliste ------------------------------------------------------- */

/* Vollstaendigkeitsblock: ersetzt die "Missing"-Hyperlinks des Bogens. */
.checklist-areas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.5rem;
}

.checklist-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border-left: 3px solid transparent;
    background: #f7f9f8;
}

.checklist-area.filled {
    border-left-color: #596836;
}

.checklist-area.missing {
    border-left-color: #af3523;
    background: #fcf1f0;
}

.checklist-ok {
    font-size: 0.8rem;
    color: #596836;
}

.checklist-area a {
    font-size: 0.85rem;
    font-weight: 600;
    color: #af3523;
}

.checklist-io {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    border-left: 3px solid transparent;
    background: #f7f9f8;
    font-size: 0.9rem;
}

.checklist-io.balanced {
    border-left-color: #596836;
}

.checklist-io.unbalanced {
    border-left-color: #af3523;
    background: #fcf1f0;
}

.checklist-io div {
    margin-top: 0.3rem;
    color: #586b65;
}

.checklist-question {
    padding: 0.9rem 0;
    border-bottom: 1px solid #e6ebea;
}

.checklist-question:last-child {
    border-bottom: none;
}

.checklist-text {
    margin: 0 0 0.2rem;
    font-weight: 500;
}

.checklist-hint {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    color: #7a928b;
}

.checklist-controls {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.4rem;
}

.checklist-controls label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Begruendungsfeld: der Bogen blendet es erst bei "Nein, weil:" ein. */
.checklist-justification {
    width: 100%;
    min-height: 3.5rem;
}

/* --- Baumansicht der Stueckliste --------------------------------------- */

.tree-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .tree-layout {
        grid-template-columns: 1fr;
    }
}

.material-tree {
    min-width: 0;
}

.tree-category + .tree-category {
    margin-top: 1.5rem;
}

.tree-category h4 {
    margin: 0 0 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    border-bottom: 1px solid #e6ebea;
    padding-bottom: 0.3rem;
}

.tree-category-meta {
    font-size: 0.78rem;
    font-weight: 400;
    color: #7a928b;
}

/* Die Einrueckung macht die Stufen-Hierarchie sichtbar - im Bogen steckt sie
   nur in einer Zahlenspalte und der Zeilenreihenfolge. */
.tree-children {
    margin-left: 1.15rem;
    border-left: 1px solid #dfe6e4;
    padding-left: 0.35rem;
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.tree-node:hover {
    background: #eff4f2;
}

.tree-node.selected {
    background: #e8f1ee;
    border-left-color: #518575;
}

.tree-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #7a928b;
    font-size: 0.8rem;
    line-height: 1;
    width: 1rem;
    padding: 0;
    transition: transform 0.12s;
}

.tree-toggle.open {
    transform: rotate(90deg);
}

.tree-toggle-spacer {
    width: 1rem;
}

.tree-marker {
    color: #899e98;
    font-size: 0.8rem;
}

.tree-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-kg {
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    color: #586b65;
}

.tree-badge {
    font-size: 0.8rem;
}

.tree-badge.error   { color: #af3523; }
.tree-badge.warning { color: #9d8e2d; }

.tree-empty,
.tree-detail-empty {
    color: #7a928b;
    font-size: 0.88rem;
    padding: 0.5rem 0;
}

/* --- Detailpanel: die 25 Bogenspalten ohne horizontales Scrollen -------- */

.tree-detail {
    position: sticky;
    top: 1rem;
    background: #f7f9f8;
    border: 1px solid #e6ebea;
    border-radius: 4px;
    padding: 0.9rem 1rem;
    max-height: 78vh;
    overflow-y: auto;
}

.detail-head h4 {
    margin: 0 0 0.2rem;
}

.detail-formula {
    margin: 0 0 0.6rem;
    font-size: 0.78rem;
    color: #7a928b;
}

.detail-group {
    margin-top: 0.9rem;
}

.detail-group h5 {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7a928b;
}

.detail-row {
    display: grid;
    grid-template-columns: 1.1rem 1fr auto;
    gap: 0.45rem;
    align-items: baseline;
    padding: 0.18rem 0.25rem;
    font-size: 0.83rem;
    border-radius: 2px;
}

/* Das Feld, auf das sich ein Befund bezieht. */
.detail-row.flagged {
    background: #fcf1f0;
}

.detail-col {
    font-size: 0.68rem;
    color: #a5b6b1;
    font-variant-numeric: tabular-nums;
}

.detail-label {
    color: #586b65;
}

.detail-value {
    font-variant-numeric: tabular-nums;
    text-align: right;
    word-break: break-word;
}

.detail-value.empty {
    color: #b7c4c0;
}

.detail-findings {
    margin-top: 0.6rem;
}

.tree-finding {
    padding: 0.4rem 0.6rem;
    border-radius: 3px;
    border-left: 3px solid transparent;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
}

.tree-finding.error {
    background: #fcf1f0;
    border-left-color: #af3523;
}

.tree-finding.warning {
    background: #faf9ef;
    border-left-color: #9d8e2d;
}

.tree-finding small {
    display: block;
    margin-top: 0.15rem;
    color: #7a928b;
    font-size: 0.72rem;
}

.tree-project-findings {
    margin-top: 1.5rem;
}

.tree-project-findings h4 {
    margin: 0 0 0.4rem;
    font-size: 0.9rem;
}

/* Zeile, zu der aus dem Baum gesprungen wurde. */
tr.row-highlight > td {
    background: #f8f6e7;
    transition: background 0.4s;
}

/* --- Komponenten-Katalog ------------------------------------------------ */

.catalog-corpus {
    padding: 0.55rem 0.8rem;
    background: #f1f6f4;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
}

.catalog-finding-group {
    margin-bottom: 1rem;
}

.catalog-finding-group h4 {
    margin: 0 0 0.25rem;
    font-size: 0.9rem;
}

.catalog-hint {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    color: #7a928b;
}

.catalog-finding {
    padding: 0.5rem 0.7rem;
    border-radius: 3px;
    border-left: 3px solid transparent;
    margin-bottom: 0.4rem;
    background: #faf9ef;
    border-left-color: #9d8e2d;
    font-size: 0.85rem;
}

.catalog-finding small {
    color: #7a928b;
    font-size: 0.75rem;
    margin-left: 0.4rem;
}

.catalog-divergence {
    margin-top: 0.25rem;
    font-size: 0.82rem;
    color: #586b65;
}

.catalog-divergence small {
    display: block;
    margin: 0.1rem 0 0;
}

.catalog-divergence code {
    background: #fff;
    border: 1px solid #ded9b6;
    border-radius: 2px;
    padding: 0 0.25rem;
    font-variant-numeric: tabular-nums;
}

.catalog-search {
    width: 100%;
    margin-bottom: 0.6rem;
}

.catalog-meta {
    font-size: 0.8rem;
    color: #7a928b;
    margin-bottom: 0.5rem;
}

.catalog-warn {
    color: #9d8e2d;
}

.catalog-entry {
    border: 1px solid #e6ebea;
    border-left: 3px solid transparent;
    border-radius: 4px;
    padding: 0.55rem 0.8rem;
    margin-bottom: 0.45rem;
}

/* Widerspruechliche Stammdaten: die Komponente heisst ueberall gleich,
   traegt aber unterschiedliche Werte. */
.catalog-entry.divergent {
    border-left-color: #9d8e2d;
    background: #fdfdfa;
}

.catalog-entry-head {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.catalog-name {
    font-weight: 600;
}

.catalog-tag {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #eaefee;
    color: #586b65;
    border-radius: 2px;
    padding: 0.05rem 0.3rem;
}

.catalog-usage {
    margin-left: auto;
    font-size: 0.78rem;
    color: #7a928b;
}

.catalog-entry-body {
    margin-top: 0.25rem;
    font-size: 0.82rem;
    color: #586b65;
}

.catalog-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 1rem;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    color: #7a928b;
}

.catalog-divergence.warn {
    color: #776c23;
}

/* Befundblock über der Katalogliste. */
.catalog-gaps {
    margin-bottom: 1rem;
}

.catalog-gaps:empty {
    display: none;
}

/* ------------------------------------------------------------------ */
/* Importseite (static/import.html)                                     */
/* ------------------------------------------------------------------ */

.import-page {
    max-width: 900px;
}

.import-form {
    background: #f8faf9;
    border: 2px dashed #dfdedb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.import-form .form-group {
    margin-bottom: 1rem;
}

.import-form small {
    display: block;
    margin-top: 0.35rem;
    color: #6b6861;
}

.import-replace {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
}

.import-report {
    margin-top: 1rem;
}

.import-report h3 {
    margin: 0 0 0.25rem;
}

.import-report-summary {
    margin: 0 0 0.75rem;
    color: #595751;
    font-size: 0.9rem;
}

.import-report-missing {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #963a2e;
    background: #fdf4f2;
    font-size: 0.85rem;
}

.import-sheet {
    border: 1px solid #e2e7e6;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    background: white;
}

.import-sheet.missing {
    opacity: 0.65;
}

.import-sheet > summary {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    list-style: none;
}

.import-sheet > summary::-webkit-details-marker {
    display: none;
}

.import-sheet > summary::before {
    content: '▸';
    margin-right: 0.5rem;
    color: #8e8a82;
}

.import-sheet[open] > summary::before {
    content: '▾';
}

.import-sheet .sheet-name {
    font-weight: 600;
    flex: 1;
}

.import-sheet .sheet-facts {
    color: #6b6861;
    font-size: 0.82rem;
    text-align: right;
}

.import-sheet-body {
    padding: 0 0.9rem 0.8rem 1.9rem;
    font-size: 0.85rem;
}

.import-sheet-empty {
    margin: 0;
    color: #6f6b63;
    font-style: italic;
}

.import-block {
    margin-bottom: 0.8rem;
}

.import-block h4 {
    margin: 0 0 0.2rem;
    font-size: 0.88rem;
    color: #183a36;
}

.import-block > p {
    margin: 0 0 0.4rem;
    color: #595751;
}

.import-list > summary {
    cursor: pointer;
    color: #4d6b60;
    padding: 0.15rem 0;
}

.import-list ul {
    margin: 0.2rem 0 0.5rem 1.2rem;
    padding: 0;
    color: #474541;
}

.import-list li {
    margin-bottom: 0.15rem;
}

/* ---- Validierungsbericht: Kopf, Gruppen je Blatt ------------------------- */
/*
   Der Bericht war eine flache Liste aller Pruefungen. Bei 27 Pruefungen ueber
   sieben Blaetter ist das keine Uebersicht mehr - deshalb gruppiert, und ein
   sauberes Blatt ist nur noch eine Zeile.
*/

.validation-verdict {
    padding: 1rem 1.1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
    background: #eaeeed;
}

.validation-verdict.all-passed { background: #e4ead7; color: #3d4725; }
.validation-verdict.has-errors { background: #f7dcd8; color: #70291e; }
.validation-verdict.has-warnings { background: #f4f0d8; color: #6a601f; }

.validation-verdict-headline {
    font-size: 1.15rem;
    font-weight: 700;
}

.validation-verdict-detail {
    margin-top: 0.35rem;
    font-size: 0.82rem;
    opacity: 0.85;
}

.validation-verdict-hint {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(0,0,0,0.12);
    font-size: 0.82rem;
}

.validation-area {
    margin-bottom: 0.6rem;
    border: 1px solid #dfe5e3;
    border-radius: 6px;
    overflow: hidden;
}

.validation-area > summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    background: #f8faf9;
    font-weight: 600;
    list-style: none;
}

.validation-area > summary::-webkit-details-marker { display: none; }

.validation-area.has-errors > summary { background: #f7dcd8; color: #70291e; }
.validation-area.has-warnings > summary { background: #f4f0d8; color: #6a601f; }
.validation-area.clean > summary { color: #3d4725; font-weight: 500; }

.validation-area-icon { font-size: 1.05rem; }
.validation-area-title { flex: 1; }

.validation-area-body {
    padding: 0.9rem 0.9rem 0.1rem;
    background: white;
}

.count-pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.count-pill.error { background: #d84e39; color: white; }
.count-pill.warning { background: #d4c66a; color: #2f2b0e; }
.count-pill.ok { background: #e4ead7; color: #3d4725; font-weight: 500; }

.area-jump {
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    color: inherit;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    opacity: 0.75;
}

.area-jump:hover { opacity: 1; }

/* Woher der Befund stammt - ohne diese Angabe war eine Energiezeile von einer
   Materialzeile nicht zu unterscheiden. */
.validation-error-where {
    display: inline-block;
    margin-right: 0.45rem;
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    background: rgba(0,0,0,0.07);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.validation-error-more { font-style: italic; opacity: 0.8; }

.io-detail-total {
    font-weight: bold;
    border-top: 1px solid #aebcb8;
    padding-top: 0.3rem;
    margin-top: 0.3rem;
}

.validation-debug { margin-top: 1.25rem; }

/* ---- Markierungen im Bogen selbst ---------------------------------------- */

.nav-badge {
    display: inline-block;
    margin-left: 0.4rem;
    min-width: 1.15rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.3rem;
    text-align: center;
}

.nav-badge.error { background: #d84e39; color: white; }
.nav-badge.warning { background: #d4c66a; color: #2f2b0e; }

/* Der aktive Reiter hat weissen Grund - dort braucht die Zahl einen Rand,
   sonst verschwindet Gelb auf Weiss. */
.nav-btn.active .nav-badge.warning { box-shadow: 0 0 0 1px #ac9c33; }

tr.finding-error > td:first-child,
tr.finding-warning > td:first-child {
    position: relative;
}

tr.finding-error {
    background: #fcf2f1 !important;
    box-shadow: inset 3px 0 0 #d84e39;
}

tr.finding-warning {
    background: #fcfbf3 !important;
    box-shadow: inset 3px 0 0 #d4c66a;
}

tr.finding-error > td:first-child::after { content: ' ✗'; color: #d84e39; font-weight: 700; }
tr.finding-warning > td:first-child::after { content: ' !'; color: #ac9c33; font-weight: 700; }

textarea.finding-error,
textarea.finding-warning,
input.finding-error,
input.finding-warning {
    border-width: 2px;
    border-style: solid;
}

textarea.finding-error, input.finding-error { border-color: #d84e39; background: #fcf2f1; }
textarea.finding-warning, input.finding-warning { border-color: #d4c66a; background: #fcfbf3; }

[data-finding] { cursor: help; }

/* ---- Anklickbare Befunde und das Aufblinken der Zielstelle --------------- */

.validation-error-item.reachable {
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    border-radius: 3px;
    padding-left: 0.25rem;
    margin-left: -0.25rem;
}

.validation-error-item.reachable:hover,
.validation-error-item.reachable:focus-visible {
    background: rgba(0,0,0,0.06);
    outline: none;
}

.validation-error-goto {
    margin-left: auto;
    padding-left: 0.5rem;
    opacity: 0.45;
    font-weight: 700;
}

.validation-error-item.reachable:hover .validation-error-goto { opacity: 1; }

/* Die dauerhafte Markierung sagt "hier ist etwas". Nach einem Sprung aus dem
   Bericht muss zusaetzlich klar sein, WELCHE der markierten Stellen gemeint
   war - dafuer blinkt sie kurz auf. */
@keyframes finding-flash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(216,78,57,0); }
    15%, 65% { box-shadow: 0 0 0 3px rgba(220,53,69,0.85); }
}

.finding-flash {
    animation: finding-flash 1.3s ease-in-out 2;
    position: relative;
    z-index: 2;
}

tr.finding-flash > td { background: #fbeae7 !important; }

@media (prefers-reduced-motion: reduce) {
    .finding-flash { animation: none; box-shadow: 0 0 0 3px rgba(220,53,69,0.85); }
}

/* ===========================================================================
   B&V AI, die Ausfüllhilfe (assistant.js)
   =========================================================================== */

/* Sitzt am rechten Ende der Reiterleiste. NICHT absolut positioniert: dort
   lag er auf dem Link „Projekt wechseln", den `app.js` erst zur Laufzeit in
   den Header einfügt. Im Textfluss kann er per Definition nichts überdecken,
   und bei schmalem Fenster bricht er mit den Reitern um. */
/* Der eine Knopf in der Leiste, der kein Reiter ist — und der einzige, der
   den Ockerakzent der CI trägt.
 *
 * Vorher war er ein durchscheinendes Weiß auf dem Grün und damit optisch ein
 * Reiter unter elf anderen. Er ist aber etwas anderes: kein Blatt des Bogens,
 * sondern ein Angebot. Ocker ist in der CI genau dafür da — sparsam, an einer
 * Stelle. Wäre er grün wie alles andere, fiele er nicht auf; wäre er Koralle,
 * sähe er nach Fehler aus. */
.assistant-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 1rem 0.42rem 0.55rem;
    border: 0;
    border-radius: 999px;
    background: var(--bv-ocker);
    color: var(--bv-braun);
    font-family: var(--schrift-titel);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
    transition: background 0.2s, box-shadow 0.2s, transform 0.12s;
}

/* Das „?" als eigene Scheibe. Ein Zeichen vor dem Namen wirkt wie ein
   Tippfehler; eine Scheibe wirkt wie ein Zeichen. */
.assistant-toggle span[aria-hidden] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    background: var(--bv-braun);
    color: var(--bv-ocker);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}

.assistant-toggle:hover {
    background: #cdbb3c;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.28);
    transform: translateY(-1px);
}

.assistant-toggle:active { transform: translateY(0); }

.assistant-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Solange das Panel offen ist, gehört der Knopf zum Panel und nicht mehr in
   den Vordergrund — sonst konkurrieren beide um dieselbe Aufmerksamkeit. */
body.assistant-open .assistant-toggle {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    box-shadow: none;
}

body.assistant-open .assistant-toggle span[aria-hidden] {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    .assistant-toggle { transition: none; }
    .assistant-toggle:hover { transform: none; }
}

/* Fest am rechten Rand statt im Textfluss: der Bogen bleibt daneben
   sichtbar und behält seine Breite - ein Panel, das die Tabelle beim
   Öffnen umbricht, kostet mehr als es hilft. */
.assistant-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #d7dedc;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.08);
    z-index: 900;
}

body.assistant-open main { padding-right: 400px; }

.assistant-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e5eae9;
}

.assistant-area {
    display: block;
    font-size: 0.8rem;
    color: #677e77;
}

.assistant-close {
    border: 0;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    color: #677e77;
    cursor: pointer;
}

.assistant-log {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.assistant-empty {
    color: #677e77;
    font-size: 0.9rem;
    line-height: 1.5;
}

.assistant-turn {
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.55;
}

.assistant-user {
    align-self: flex-end;
    max-width: 88%;
    background: #568b7b;
    color: #fff;
    white-space: pre-wrap;
}

.assistant-answer {
    background: #f3f8f6;
    border: 1px solid #e3ece9;
}

.assistant-answer p { margin: 0 0 0.5rem; }
.assistant-answer p:last-child { margin-bottom: 0; }
.assistant-answer ul { margin: 0.3rem 0 0.5rem 1.1rem; padding: 0; }
.assistant-answer li { margin-bottom: 0.25rem; }

.assistant-answer code {
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    background: #e6efec;
    font-size: 0.85em;
}

.assistant-error {
    background: #fcefed;
    border: 1px solid #f2cac4;
    color: #943f32;
}

/* Woraus die Antwort gebaut ist. Klein, aber vorhanden: eine Antwort ohne
   jede Grundlage soll man erkennen können. */
.assistant-grounding {
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed #d2deda;
    font-size: 0.75rem;
    color: #677e77;
}

.assistant-thinking { display: flex; gap: 0.3rem; padding: 0.7rem 0.8rem; }

.assistant-thinking span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9dafaa;
    animation: assistant-blink 1.2s infinite ease-in-out;
}

.assistant-thinking span:nth-child(2) { animation-delay: 0.2s; }
.assistant-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes assistant-blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

.assistant-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.6rem;
}

.assistant-starter {
    padding: 0.35rem 0.7rem;
    border: 1px solid #d2deda;
    border-radius: 999px;
    background: #fff;
    font-size: 0.8rem;
    color: #3b544d;
    cursor: pointer;
    text-align: left;
}

.assistant-starter:hover { background: #f1f6f5; border-color: #a8c9bf; }

.assistant-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border-top: 1px solid #e5eae9;
}

.assistant-input textarea {
    flex: 1;
    resize: none;
    padding: 0.5rem 0.6rem;
    border: 1px solid #d2deda;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
}

.assistant-input button {
    padding: 0 1rem;
    border: 0;
    border-radius: 8px;
    background: #568b7b;
    color: #fff;
    cursor: pointer;
}

.assistant-input button:disabled { background: #9dafaa; cursor: default; }

/* Der Datenschalter. Als `label` um das Kaestchen herum, damit auch der
   Text schaltet - die Trefferflaeche eines nackten Kaestchens ist auf einem
   Beruehrungsbildschirm zu klein. */
.assistant-data {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin: 0 1rem 0.6rem;
    padding: 0.6rem 0.7rem;
    background: #f5f8f7;
    border: 1px solid #e1e8e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.74rem;
    line-height: 1.4;
}

.assistant-data input {
    margin: 0.15rem 0 0;
    flex: none;
    cursor: pointer;
}

.assistant-data strong {
    display: block;
    font-size: 0.76rem;
    color: #303c38;
}

.assistant-data em {
    font-style: normal;
    color: #677e77;
}

.assistant-foot {
    margin: 0;
    padding: 0 1rem 0.9rem;
    font-size: 0.72rem;
    line-height: 1.45;
    color: #677e77;
}

/* Auf schmalen Fenstern deckt das Panel den Bogen ab, statt ihn auf eine
   unbenutzbare Restbreite zu quetschen. */
@media (max-width: 1100px) {
    .assistant-panel { width: 100%; }
    body.assistant-open main { padding-right: 0; }
}

/* ===========================================================================
   Feedback je Reiterseite (Testphase)
   =========================================================================== */

/* Salbei statt Ocker: Ocker bleibt laut Corporate-Identity-Konvention "ein
   Akzent" dem B&V-AI-Knopf vorbehalten (siehe CLAUDE.md). */
.feedback-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 1rem;
    border: 0;
    border-radius: 999px;
    background: var(--bv-salbei);
    color: #fff;
    font-family: var(--schrift-titel);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
    transition: background 0.2s, box-shadow 0.2s, transform 0.12s;
}

/* Kein `margin-left: auto` hier: `.assistant-toggle` traegt es bereits und
   schiebt die ganze restliche Gruppe der Reiterleiste nach rechts. */

.feedback-toggle:hover {
    background: #3d574d;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.28);
    transform: translateY(-1px);
}

.feedback-toggle:active { transform: translateY(0); }

.feedback-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

body.feedback-open .feedback-toggle {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    .feedback-toggle { transition: none; }
    .feedback-toggle:hover { transform: none; }
}

/* Links statt rechts positioniert (wie das B&V-AI-Panel, nur gespiegelt) -
   beide Panels koennen so gleichzeitig offen sein, ohne sich zu ueberlappen. */
.feedback-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 340px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #d7dedc;
    box-shadow: 4px 0 18px rgba(0, 0, 0, 0.08);
    z-index: 900;
}

body.feedback-open main { padding-left: 360px; }

.feedback-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e5eae9;
}

.feedback-area {
    display: block;
    font-size: 0.8rem;
    color: #677e77;
}

.feedback-close {
    border: 0;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    color: #677e77;
    cursor: pointer;
}

#feedback-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1rem;
    overflow-y: auto;
}

.feedback-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #303c38;
}

.feedback-field select,
.feedback-field textarea {
    font: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #d2deda;
    border-radius: 8px;
    resize: vertical;
}

#feedback-send {
    padding: 0.55rem 1rem;
    border: 0;
    border-radius: 8px;
    background: var(--bv-salbei);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

#feedback-send:disabled { background: #9dafaa; cursor: default; }

.feedback-success {
    margin: 0;
    padding: 0.6rem 0.7rem;
    border-radius: 6px;
    background: #eef4ee;
    color: var(--bv-oliv);
    font-size: 0.85rem;
}

.feedback-error {
    margin: 0;
    padding: 0.6rem 0.7rem;
    border-radius: 6px;
    background: #fcefed;
    color: #943f32;
    font-size: 0.85rem;
}

@media (max-width: 1100px) {
    .feedback-panel { width: 100%; }
    body.feedback-open main { padding-left: 0; }
}

/* "Erklären" am einzelnen Befund. Erscheint nur, wenn der Assistent
   eingerichtet ist - siehe `renderCheck()` in app.js. */
.check-explain {
    margin-top: 0.5rem;
    padding: 0.25rem 0.7rem;
    border: 1px solid #d2deda;
    border-radius: 999px;
    background: #fff;
    font-size: 0.78rem;
    color: #3b544d;
    cursor: pointer;
}

.check-explain:hover { background: #f1f6f5; border-color: #a8c9bf; }

/* „Erklären" am einzelnen Befund.
 *
 * Zurückhaltender als der Knopf an der Prüfung: er sitzt IN einer Zeile, die
 * selbst schon anklickbar ist (Sprung zur Stelle im Bogen). Wäre er ebenso
 * kräftig, konkurrierten zwei Angebote in derselben Zeile, und der Anwender
 * müsste erst lesen, welches was tut.
 *
 * Deshalb: erscheint erst beim Überfahren der Zeile — und bleibt dauerhaft
 * sichtbar, sobald er selbst den Tastaturfokus hat. Ein Knopf, den man nur
 * mit der Maus findet, ist für die Tastatur kein Knopf. */
.finding-explain {
    float: right;
    margin-left: 0.6rem;
    padding: 0.1rem 0.6rem;
    border: 1px solid var(--bv-ocker);
    border-radius: 999px;
    background: transparent;
    color: #6a601f;
    font-family: var(--schrift-titel);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.validation-error-item:hover .finding-explain,
.finding-explain:focus-visible {
    opacity: 1;
}

.finding-explain:hover {
    background: var(--bv-ocker);
    color: var(--bv-braun);
}

/* Auf Geräten ohne Zeigegerät gibt es kein Überfahren - dort steht er
   immer. Sonst wäre er auf einem Tablet schlicht nicht erreichbar. */
@media (hover: none) {
    .finding-explain { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .finding-explain { transition: none; }
}

/* ===========================================================================
   Feldhilfe (fieldhelp.js) — der Ausfüllhinweis des Bogens am Feld
   =========================================================================== */

.fieldhelp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    margin-left: 0.35rem;
    padding: 0;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    opacity: 0.55;
    vertical-align: middle;
}

.fieldhelp:hover,
.fieldhelp:focus-visible {
    opacity: 1;
    background: rgba(82, 137, 122, 0.15);
}

/* `position: fixed`, weil die Materialtabelle waagerecht scrollt: ein
   absolut positioniertes Kind würde an deren Rand abgeschnitten. */
.fieldhelp-pop {
    position: fixed;
    z-index: 1200;
    max-width: 340px;
    padding: 0.7rem 0.85rem;
    background: #fff;
    border: 1px solid #d2deda;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.5;
    color: #3b544d;
    text-align: left;
    white-space: normal;
}

.fieldhelp-pop strong { display: block; margin-bottom: 0.25rem; }
.fieldhelp-pop p { margin: 0; }

/* Die Fundstelle im Bogen. Klein, aber vorhanden: eine Angabe, die man
   nachschlagen kann, ist überprüfbar. */
.fieldhelp-source {
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed #d2deda;
    font-size: 0.72rem;
    color: #677e77;
}

/* Eine Zeilenangabe in einer Antwort des Assistenten. Sieht aus wie Text,
   verhält sich wie der Befund im Validierungsbericht: Klick springt hin und
   lässt die Zeile aufblinken. */
.row-jump {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: #568b7b;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.row-jump:hover { color: #3b5f54; }
