:root {
    --color-bg: #f7f7f5;
    --color-fg: #1f2320;
    --color-accent: #2f6f4f;
    --color-border: #ddd8d0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--color-bg);
    color: var(--color-fg);
    overflow-anchor: none;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.75rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--color-border);
}

.topbar .brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-accent);
    text-decoration: none;
}

.topbar nav a {
    margin-right: 1rem;
    color: var(--color-fg);
    text-decoration: none;
}

.topbar nav a:hover { color: var(--color-accent); }

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--color-fg);
}

.auth-page {
    max-width: 360px;
    margin: 4rem auto;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 2rem;
}
.auth-page h1 { font-size: 1.4rem; margin-top: 0; }
.auth-fehler {
    background: #fbeaea;
    color: #a33;
    border: 1px solid #e3b3b3;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

main { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }

.cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.card {
    display: block;
    padding: 1.25rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-fg);
    min-width: 200px;
}

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

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--color-border); }

form.inline { display: inline; }

button, .btn {
    background: var(--color-accent);
    color: white;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button.secondary, .btn.secondary { background: #888; }
button.danger, .btn.danger { background: #b33; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-header > div { display: flex; gap: 0.5rem; }

.filterleiste { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: center; }
.filterleiste select { padding: 0.35rem; border-radius: 6px; border: 1px solid var(--color-border); }

.formular fieldset {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-top: 1rem;
    padding: 1rem;
    background: white;
}
.formular legend { font-weight: 600; padding: 0 0.4rem; }
.formular label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    max-width: 320px;
}
.formular input, .formular select {
    padding: 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
}
.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; }

.tabstrip { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabstrip button { background: white; color: var(--color-fg); border: 1px solid var(--color-border); }
.tabstrip button.active { background: var(--color-accent); color: white; }

.ergebnis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-top: 1rem; }
.ergebnis-karte { background: white; border: 1px solid var(--color-border); border-radius: 8px; padding: 1.1rem; }
.ergebnis-karte h3 { margin-top: 0; margin-bottom: 0.25rem; }
.ergebnis-karte-kopf { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.ergebnis-karte-kopf h3 { flex: 1; }
.note-badge {
    display: inline-block;
    font-size: 1.8rem;
    font-weight: 700;
    padding: 0.2rem 0.7rem;
    border-radius: 8px;
    background: var(--color-accent);
    color: white;
}

/* --- Ergebnis-Seite: Kostenaufschluesselung + Bewertungs-Icons --- */
:root {
    --c-planung: #8a94a3;
    --c-verwaltung: #b7bfc9;
    --c-errichtung: #2f3b4c;
    --c-betrieb: #6f8a99;
    --c-ihis: #c97a2b;
    --c-abbruch: #a6412e;
}

.lzk-gesamt {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0.25rem 0 0.75rem;
}
.lzk-gesamt span { font-size: 0.85rem; font-weight: 400; color: #777; margin-left: 0.25rem; }

.stack-bar {
    display: flex;
    height: 0.9rem;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.9rem;
    border: 1px solid var(--color-border);
}
.stack-bar div { height: 100%; }

.breakdown { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 0; }
.breakdown td { padding: 0.28rem 0; border-bottom: none; }
.breakdown .swatch { width: 0.6rem; height: 0.6rem; border-radius: 1px; display: inline-block; margin-right: 0.5rem; }
.breakdown .lbl { color: #555; }
.breakdown .val { text-align: right; white-space: nowrap; }

.bewertung-gesamt { margin-top: 1.1rem; }
.bewertung-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #777;
    margin-bottom: 0.35rem;
}
.bewertung-sum { width: 100%; max-width: 320px; height: auto; display: block; }

.bewertung-einzeln { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.bewertung-zeile { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.bewertung-zeile-label { font-size: 0.85rem; color: #444; flex-shrink: 0; }
.bewertung-zeile img { height: 1.6rem; width: auto; }

/* --- Vergleichs-Workspace: Projektdaten-Spalten, Flaechen-Bildpicker --- */
.group-label {
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 0.6rem;
}

.formular-spalten {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0 2rem;
}

.formular-inline { display: flex; gap: 0.5rem; align-items: center; }
.formular-inline input { padding: 0.4rem; border: 1px solid var(--color-border); border-radius: 6px; }

.fl-thumb { width: 2.5rem; height: 2.5rem; object-fit: cover; border-radius: 4px; display: block; cursor: zoom-in; }

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 18, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 1000;
    cursor: zoom-out;
}
.lightbox-img { max-width: 90vw; max-height: 90vh; object-fit: contain; background: white; border-radius: 4px; cursor: default; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 18, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
}
.modal-box {
    background: white;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    width: 100%;
    max-width: 340px;
}
.modal-box h3 { margin-top: 0; margin-bottom: 1rem; font-size: 1.05rem; }
.modal-field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; margin-bottom: 0.9rem; }
.modal-field input[type="text"] { padding: 0.4rem; border: 1px solid var(--color-border); border-radius: 6px; font-size: 0.9rem; }
.modal-field-label { font-size: 0.8rem; color: #555; margin-bottom: 0.1rem; }
.modal-radio { display: flex; align-items: center; gap: 0.4rem; font-weight: 400; font-size: 0.88rem; margin-bottom: 0.3rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.1rem; }

.picker-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0.75rem 0; }
.picker-filter-label { font-size: 0.8rem; color: #666; margin-right: 0.15rem; }
.filter-btn {
    background: white;
    color: var(--color-fg);
    border: 1px solid var(--color-border);
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    cursor: pointer;
}
.filter-btn.active { background: var(--color-accent); color: white; border-color: var(--color-accent); }

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

.picker-table-wrap {
    overflow-y: auto;
    overflow-x: auto;
    max-height: 21.6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}
.picker-table { width: 100%; border-collapse: collapse; margin-top: 0; font-size: 0.85rem; }
.picker-table th { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 2px solid var(--color-border); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: #666; position: sticky; top: 0; background: white; z-index: 1; }
.picker-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.picker-table th.sortable:hover { color: var(--color-accent); }
.sort-arrow { font-size: 0.65rem; margin-left: 0.25rem; color: var(--color-accent); }
.picker-row { cursor: pointer; }
.picker-row td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--color-border); }
.picker-row:hover td { background: #f0efe9; }
.picker-row--aktiv td { background: #e4efe8; }

.picker-side {
    position: sticky;
    top: 1rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.9rem;
    min-height: 160px;
    max-height: calc(21.6rem + 2px);
    overflow-y: auto;
}
.picker-side-empty { font-size: 0.82rem; color: #888; }
.picker-side-img { width: 100%; height: 170px; object-fit: contain; background: #fff; display: block; margin-bottom: 0.6rem; cursor: zoom-in; }
.picker-side-code { font-weight: 600; font-size: 0.9rem; }
.picker-side-info { font-size: 0.75rem; color: #777; margin: 0.15rem 0 0.75rem; }

.picker-side-details { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.85rem; padding-top: 0.6rem; border-top: 1px solid var(--color-border); }
.picker-side-detail-group { font-size: 0.75rem; color: #555; line-height: 1.5; }
.picker-side-detail-title { font-weight: 600; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: #666; margin-bottom: 0.15rem; }

.picker-side-add { display: flex; flex-direction: column; gap: 0.4rem; }
.picker-side-add input { padding: 0.4rem; border: 1px solid var(--color-border); border-radius: 6px; font-size: 0.85rem; }

.slider-label { max-width: none !important; }
.slider-row { display: flex; align-items: center; gap: 0.6rem; }
.slider-row input[type="range"] { flex: 1; }
.slider-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 2.2em; text-align: right; }

/* --- Varianten-Detailseite: Aufschluesselung je Flaeche/Element + Grafiken --- */
.print-header { display: none; }

.detail-page { margin-top: 1rem; }
.detail-tab-panel { margin-top: 1rem; }

.detail-summary {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    max-width: 520px;
}

.detail-leer { color: #777; font-size: 0.9rem; }

.detail-chart-legende { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 1.1rem; font-size: 0.78rem; color: #555; }
.detail-chart-legende .swatch { width: 0.6rem; height: 0.6rem; border-radius: 1px; display: inline-block; margin-right: 0.35rem; }

.detail-chart { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.6rem 0 0; }
.detail-chart-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; align-items: center; gap: 0.75rem; }
.detail-chart-label { font-size: 0.82rem; color: #444; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-chart-bar-wrap { background: #eeece6; border-radius: 4px; overflow: hidden; height: 0.9rem; }
.detail-chart-bar-stack { display: flex; height: 100%; min-width: 2px; }
.detail-chart-bar-stack div { height: 100%; }
.detail-chart-value { font-size: 0.8rem; font-variant-numeric: tabular-nums; color: #555; white-space: nowrap; min-width: 5.5em; text-align: right; }
.detail-chart-hinweis { font-size: 0.75rem; color: #888; margin-top: 0.75rem; }

.detail-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.detail-table th { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 2px solid var(--color-border); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: #666; }
.detail-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.detail-table-gesamt { font-weight: 600; }

.detail-layout { display: flex; flex-direction: column; gap: 1.25rem; }
.detail-table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 6px; max-height: 30rem; overflow-y: auto; }
.detail-table-wrap .detail-table th { position: sticky; top: 0; background: white; z-index: 1; }

.detail-side { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 0.85rem; }
.detail-side > .picker-side-empty { padding: 0.5rem 0; }

.detail-box { background: white; border: 1px solid var(--color-border); border-radius: 8px; padding: 0.85rem 1rem; flex: 1 1 260px; min-width: 240px; }
.detail-box-title { font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: #666; margin-bottom: 0.4rem; }
.detail-box-gesamt { font-size: 1.15rem; font-weight: 700; }
.detail-box-sub { font-size: 0.8rem; color: #555; margin-top: 0.25rem; }

/* Flaechen-Detailpanel: links Flaechendetails (mit groesserem Bild) + NmF
   uebereinander, rechts daneben die restlichen Kosten-Sparten. */
.detail-side-spalten { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.85rem; align-items: flex-start; width: 100%; }
.detail-side-links { display: flex; flex-direction: column; gap: 0.85rem; flex: 1 1 340px; min-width: 280px; max-width: 420px; }
.detail-side-rechts { display: flex; flex-direction: column; gap: 0.85rem; flex: 2 1 380px; min-width: 280px; }
.detail-side-links .detail-box, .detail-side-rechts .detail-box { flex: none; width: 100%; min-width: 0; }

.detail-flaeche-bild { width: 100%; height: 260px; object-fit: contain; background: #fff; border-radius: 4px; cursor: zoom-in; margin-bottom: 0.65rem; }
.detail-flaeche-info { font-size: 0.82rem; line-height: 1.7; }

.detail-aktionen-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; margin-top: 0.6rem; }
.detail-aktionen-table th { text-align: left; padding: 0.25rem 0.4rem; border-bottom: 1px solid var(--color-border); color: #777; font-weight: 600; }
.detail-aktionen-table td { padding: 0.3rem 0.4rem; border-bottom: 1px solid #f0efe9; }

.nmf-bars { display: flex; flex-direction: column; gap: 0.55rem; }
.nmf-bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.4rem 0.6rem; }
.nmf-bar-label { font-size: 0.78rem; color: #444; grid-column: 1 / -1; }
.nmf-bar-wrap { background: #eeece6; border-radius: 999px; overflow: hidden; height: 0.55rem; }
.nmf-bar-fill { height: 100%; background: var(--color-accent); border-radius: 999px; }
.nmf-bar-value { font-size: 0.75rem; font-variant-numeric: tabular-nums; color: #555; white-space: nowrap; }

@media print {
    .no-print, .topbar { display: none !important; }
    .print-header { display: block; margin-bottom: 1rem; }
    .print-header h1 { margin: 0 0 0.2rem; font-size: 1.3rem; }
    .print-subtitle { color: #555; font-size: 0.9rem; }
    body { background: white; }
    main { padding: 0; max-width: none; }
    .detail-tab-panel { display: block !important; margin-top: 1.2rem; page-break-inside: avoid; }
    .detail-table-wrap { max-height: none; overflow: visible; }
    .detail-table { font-size: 0.75rem; }
    .detail-chart-bar-wrap, .nmf-bar-wrap, .stack-bar, .detail-chart-bar-stack, .nmf-bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
