/* Wohnung (Kauf & Miete) – seitenspezifische Styles (Basis: assets/css/reset.css, theme.css) */

:root {
    --surface: var(--theme-surface);
    --text: var(--theme-text);
    --muted: var(--theme-text-muted);
    --primary: var(--theme-accent);
    --primary-strong: var(--theme-accent-strong);
    --primary-light: var(--theme-accent-soft);
    --border: var(--theme-border);
    --input-bg: var(--theme-gray-100);

    /* Diagrammfarben (Kategorien 1–3, validiert für hell und dunkel). */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --map-filter: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --date-scheme: dark;
        --map-filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
    }
}

:root[data-theme="dark"] {
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --date-scheme: dark;
    --map-filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
}

button, input, select, textarea {
    font-family: inherit;
}

/* Fokussierte Felder nicht unter Kopfmenü und angehefteter Leiste verstecken. */
html { scroll-padding-top: calc(var(--theme-nav-height) + 70px); }

body {
    padding: calc(var(--theme-nav-height) + 30px) 16px 60px;
    min-height: 100vh;
    font-size: 14px;
}

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.page-head {
    text-align: center;
    margin-bottom: 24px;
}

.page-head h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.page-head p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.bad-text { color: var(--theme-danger); }
.warn-text { color: var(--theme-warning-text); }

/* ── Panels ── */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--theme-shadow-sm);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.panel-head h2 {
    font-size: 16px;
    font-weight: 800;
    color: var(--theme-text-strong);
}

/* Einklappbar (Übersicht), siehe panel() in app.js */
.panel-head:has(> h2 > .panel-toggle) > h2 { flex: 1 1 auto; min-width: 0; }
.panel-head:has(> .actions) { flex-wrap: wrap; }
.panel-head:has(> .actions) > h2:has(> .panel-toggle) { min-width: max-content; }

.panel-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 32px;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.panel-toggle:hover { color: var(--primary-strong); }
.panel-chevron { flex: none; font-size: 13px; color: var(--muted); transition: transform 0.2s; }
.is-collapsed .panel-chevron { transform: rotate(-90deg); }
.panel.is-collapsed > :not(.panel-head) { display: none; }
.panel.is-collapsed > .panel-head { margin-bottom: 0; }
.panel.is-collapsed { padding-top: 12px; padding-bottom: 12px; }

.panel-hint {
    color: var(--muted);
    font-size: 12.5px;
    margin-bottom: 8px;
    line-height: 1.45;
}

.group + .group,
.group + .group-title {
    margin-top: 18px;
}

.group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-strong);
    margin: 14px 0 10px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px 14px;
}

.span-2 { grid-column: span 2; }

/* ── Formularfelder ── */

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field-label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.field-hint {
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.35;
}

/* Felder einer Zeile teilen sich drei Rasterzeilen (Überschrift, Feld, Hinweis).
   So bleiben alle Eingaben auf einer Höhe, auch wenn eine Überschrift umbricht.
   Die Abstände stecken in den Feldern, weil leere Hinweiszeilen sonst doppelte
   Lücken ergäben; der negative Rand gleicht den Abstand der letzten Zeile aus. */
@supports (grid-template-rows: subgrid) {
    .grid:has(> .field) {
        row-gap: 0;
        margin-bottom: -12px;
    }
    .grid.cost-persons { margin-bottom: 0; }
    .grid > .field {
        display: grid;
        grid-template-rows: subgrid;
        grid-template-columns: minmax(0, 1fr);
        grid-row: span 3;
        align-items: start;
        gap: 0;
        margin-bottom: 12px;
    }
    .grid > .field > .field-label {
        align-self: end;
        margin-bottom: 5px;
    }
    .grid > .field > .field-hint { margin-top: 5px; }
}

.input-wrap {
    position: relative;
    display: flex;
}

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-width: 0;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    padding: 8px 10px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea { resize: vertical; line-height: 1.4; }

.input-wrap input {
    padding-right: 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.input-wrap.unit-wide input { padding-right: 68px; }

.unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--muted);
    pointer-events: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input:disabled {
    opacity: 0.55;
}

input::placeholder,
textarea::placeholder {
    color: var(--theme-gray-400);
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ── Buttons ── */

.btn {
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    min-height: 40px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-strong); }
.btn-danger:hover { border-color: var(--theme-danger); color: var(--theme-danger); }

.btn-add {
    margin-top: 12px;
    width: 100%;
    border-style: dashed;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.icon-btn:hover { background: var(--theme-danger-soft); color: var(--theme-danger); }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Kacheln ── */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.tile {
    background: var(--theme-surface-muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}

.tile-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
}

/* Bezugsgröße: für alle / für eine Person */
.who {
    display: inline-block;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.who-all { color: var(--muted); background: var(--theme-surface-muted); }
.who-me { color: var(--primary-strong); background: var(--primary-light); border-color: var(--theme-accent-border); }
.who-legend { margin-bottom: 8px; line-height: 1.6; }

.tile-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--theme-text-strong);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.tile-sub {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 2px;
}

.budget-note { margin-top: 10px; line-height: 1.5; }
.budget-note .btn { margin-left: 4px; }

.tile-warn { border-color: var(--theme-warning); background: var(--theme-warning-soft); }
.tile-bad { border-color: var(--theme-danger); background: var(--theme-danger-soft); }

/* ── Wohnungskarten & Vergleich ── */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.card {
    display: block;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    background: var(--theme-surface-muted);
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.card:hover {
    border-color: var(--theme-accent-border);
    box-shadow: var(--theme-shadow);
    transform: translateY(-2px);
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.card-name {
    font-weight: 800;
    font-size: 15px;
    color: var(--primary-strong);
    overflow-wrap: anywhere;
}

.card-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.card-facts {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 12px;
    margin-top: 10px;
    font-size: 12.5px;
}

.card-facts dt { color: var(--muted); }
.card-facts dd { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-facts .card-over { grid-column: 1 / -1; font-size: 11.5px; white-space: normal; }

.badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
    border: 1px solid currentColor;
}

.badge-ok { color: var(--theme-success); background: var(--theme-success-soft); }
.badge-warn { color: var(--theme-warning-text); background: var(--theme-warning-soft); }
.badge-bad { color: var(--theme-danger); background: var(--theme-danger-soft); }

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 10px;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-variant-numeric: tabular-nums;
}

.compare th,
.compare td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
    font-size: 13px;
}

.compare thead th {
    background: var(--theme-surface-muted);
    font-size: 13px;
}

.compare thead th a { text-decoration: none; font-weight: 800; }

.compare tbody th {
    text-align: left;
    font-weight: 500;
    color: var(--muted);
    position: sticky;
    left: 0;
    background: var(--surface);
}

.compare thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
}

.compare tr.strong th,
.compare tr.strong td { font-weight: 800; color: var(--theme-text-strong); }
.compare tr.sep th,
.compare tr.sep td { border-top: 2px solid var(--border); }
.compare tr:last-child th,
.compare tr:last-child td { border-bottom: none; }

.compare td.best {
    background: var(--theme-success-soft);
    color: var(--theme-success);
    font-weight: 700;
}

.compare td.best::before { content: "★ "; font-size: 10px; }

.compare tr td.over-bad { background: var(--theme-danger-soft); color: var(--theme-danger); }
.compare tr td.over-warn { background: var(--theme-warning-soft); color: var(--theme-warning-text); }

/* ── Karte (map.js) ── */

.map-box [hidden] { display: none; }
.map-ask p { max-width: 80ch; line-height: 1.5; margin-bottom: 10px; }

.flat-map {
    height: clamp(300px, 55vh, 520px);
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--theme-surface-muted);
    isolation: isolate;   /* Leaflet-Ebenen unter dem Kopfmenü halten */
    font: inherit;
}

.flat-map .leaflet-tile-pane { filter: var(--map-filter); }
.flat-map .leaflet-control-attribution { background: var(--surface); color: var(--muted); font-size: 10.5px; }
.flat-map .leaflet-control-attribution a { color: var(--muted); text-decoration: underline; }
.flat-map .leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--border); }
.flat-map .leaflet-bar a.leaflet-disabled { color: var(--muted); }
.flat-map .leaflet-popup-content-wrapper,
.flat-map .leaflet-popup-tip,
.flat-map .leaflet-tooltip { background: var(--surface); color: var(--text); border-color: var(--surface); }
.flat-map .leaflet-popup-content { margin: 12px 14px; font-size: 12.5px; line-height: 1.45; }
.flat-map .leaflet-popup-content p { margin: 8px 0 0; }
.flat-map .leaflet-tooltip-top::before { border-top-color: var(--surface); }
.flat-map .leaflet-container a.leaflet-popup-close-button,
.flat-map a.leaflet-popup-close-button { color: var(--muted); }

.map-title { font-weight: 800; font-size: 14px; color: var(--primary-strong); }
.flat-map a.map-title { color: var(--primary-strong); }
.map-away { margin-top: 8px; font-weight: 700; }
.map-popup .card-facts { margin-top: 2px; }

/* Wohnung: blaue Nadel mit Nummer, Ort einer Person: oranges Quadrat mit Anfangsbuchstabe */
.map-mark {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 2px solid #fff;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.map-flat { background: #1f63b8; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.map-flat > span { transform: rotate(45deg); }
.map-flat.is-out { background: #71717a; }
.map-place { background: #b8470f; border-radius: 7px; }

.map-status { margin-top: 8px; }
.map-actions { margin-top: 10px; flex-wrap: wrap; }

.map-lists {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 4px 24px;
    margin-top: 6px;
}

.map-list { list-style: none; margin: 0; padding: 0; }
.map-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    text-decoration: none;
    overflow-wrap: anywhere;
}
button.map-item { cursor: pointer; }
button.map-item:hover,
a.map-item:hover { background: var(--theme-surface-muted); }
.map-item .map-mark { width: 24px; height: 24px; font-size: 11px; }
.map-note { display: block; font-size: 11.5px; }

/* ── Detailansicht ── */

/* Bleibt beim Scrollen unter dem Kopfmenü angeheftet. */
.detail-bar {
    position: sticky;
    top: calc(var(--theme-nav-height) + 8px);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 7px 14px 7px 7px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--theme-shadow-sm);
}

.back {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.back:hover { background: var(--primary-strong); color: #fff; }

.detail-name {
    min-width: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-actions { margin-bottom: 18px; }

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    gap: 18px;
    align-items: start;
}

.detail-aside { min-width: 0; }

.results-panel h3 {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-strong);
    margin: 18px 0 6px;
}

.calc th,
.calc td {
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: top;
}

.calc th { text-align: left; font-weight: 400; color: var(--muted); padding-right: 10px; }
.calc td { text-align: right; white-space: nowrap; }
.calc tr.sum th,
.calc tr.sum td { border-top: 2px solid var(--theme-gray-300); color: var(--text); font-weight: 600; }
.calc tr.strong th,
.calc tr.strong td { font-weight: 800; color: var(--theme-text-strong); }
.calc tr.muted-row td { color: var(--muted); }
.rent-plan tr:first-child td { white-space: normal; padding-left: 8px; }
.calc-split { margin-top: 10px; }

.calc + .small,
.calc-split + .small { margin-top: 6px; line-height: 1.4; }

.checks {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checks li {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    font-size: 13px;
    line-height: 1.4;
}

.check-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    margin-top: 1px;
}

.check-ok .check-icon { background: var(--theme-success); }
.check-warn .check-icon { background: var(--theme-warning); }
.check-bad .check-icon { background: var(--theme-danger); }
.check-info .check-icon { background: var(--theme-gray-400); font-style: italic; font-family: Georgia, serif; }

/* Objekt-Bewertung & Rückfragen */
.review-intro { margin-bottom: 8px; line-height: 1.4; }

.review {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.review-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--theme-surface-muted);
    margin-top: 0;
}

.review-item.docs { margin-top: 6px; }

.review-item summary {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 8px 10px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    list-style: none;
}

.review-item summary::-webkit-details-marker { display: none; }

.review-item summary::after {
    content: "▾";
    margin-left: 4px;
    color: var(--muted);
    transition: transform 0.15s;
}

.review-item[open] summary::after { transform: rotate(180deg); }
.review-title { flex: 1; line-height: 1.4; }

.review-count {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 7px;
}

.review-body {
    padding: 0 12px 10px 39px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text);
}

.review-q-title {
    margin-top: 8px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
}

.review-body ul {
    margin: 4px 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.btn-copy {
    width: 100%;
    margin-top: 10px;
}

/* WG-Zimmer */
.room {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr) minmax(0, 0.8fr) minmax(0, 1fr) 32px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.room-head {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    margin-bottom: 4px;
}

.room .input-wrap input { padding-right: 30px; }
.room .unit { right: 8px; }
.room-fair { margin: -2px 0 14px; line-height: 1.4; }
.room-fair p:empty { display: none; }
.room-features { margin-top: 2px; font-size: 12.5px; }
.room-features > summary { margin-bottom: 0; font-size: 12px; font-weight: 600; }
.room-features[open] > summary { margin-bottom: 8px; }
.room-features .field { max-width: 190px; margin-top: 10px; }
.room-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.room-checks label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.room-checks input { margin: 0; }
.explain {
    margin: 4px 0 12px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--theme-surface-muted);
    font-size: 12.5px;
    line-height: 1.5;
}

.explain > summary { margin-bottom: 0; }
.explain[open] > summary { margin-bottom: 8px; }
.explain p,
.explain dl { max-width: 75ch; }
.explain dt { font-weight: 700; margin-top: 8px; }
.explain dd { margin: 0; color: var(--muted); }
.explain dd + dd { margin-top: 3px; }
.explain dd.formula { color: var(--text); font-weight: 600; }
.results-panel .explain { margin: 12px 0 16px; }
.fair-missing {
    margin: 4px 0 12px;
    padding: 8px 10px;
    border: 1px solid var(--theme-warning);
    border-radius: 8px;
    background: var(--theme-warning-soft);
    line-height: 1.45;
}

.fair-missing:empty { display: none; }

/* Status & Tagebuch */
.status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.status-ends { padding-top: 10px; border-top: 1px dashed var(--border); margin-top: 10px; }

.status-chip {
    min-height: 34px;
    padding: 5px 12px;
    border: 2px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.status-chip:hover { border-color: var(--primary); color: var(--primary-strong); }
.status-chip.is-been { border-color: var(--theme-accent-border); background: var(--primary-light); }
.status-chip.is-been::before { content: "✓ "; }
.status-chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary); color: #fff; }
.chip-out:hover { border-color: var(--theme-danger); color: var(--theme-danger); }
.chip-out[aria-pressed="true"] { border-color: var(--theme-danger); background: var(--theme-danger-soft); color: var(--theme-danger); }
.chip-hold[aria-pressed="true"] { border-color: var(--theme-warning); background: var(--theme-warning-soft); color: var(--theme-warning-text); }
.chip-done[aria-pressed="true"] { border-color: var(--theme-success); background: var(--theme-success-soft); color: var(--theme-success); }

.status-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; line-height: 1.45; }
.btn-small { min-height: 30px; padding: 3px 10px; font-size: 12px; }
.btn[hidden] { display: none; }

.status-tag {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-strong);
    background: var(--primary-light);
}

.status-tag.status-out { color: var(--theme-danger); background: var(--theme-danger-soft); }
.status-tag.status-hold { color: var(--theme-warning-text); background: var(--theme-warning-soft); }
.status-tag.status-done { color: var(--theme-success); background: var(--theme-success-soft); }

.card-status { margin-top: 8px; font-size: 12px; }
.card-why { margin-top: 4px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.card-out:not(:hover):not(:focus) { opacity: 0.7; }

.diary-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.diary-list { display: flex; flex-direction: column; gap: 12px; }
.diary-list:not(:empty) { margin: 8px 0 10px; }
.diary-entry { padding-left: 12px; border-left: 3px solid var(--theme-accent-border); }
.diary-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.diary-head input { flex: 0 0 150px; min-height: 34px; padding: 4px 8px; }
input[type="date"] { color-scheme: var(--date-scheme, light); }   /* sonst ist das Kalender-Symbol dunkel auf dunkel */
.diary-tag { flex: 1; min-width: 0; }
.diary-entry textarea { field-sizing: content; min-height: 56px; }

/* Angebot mit KI übernehmen */
.offer > summary { margin-bottom: 0; }
.offer[open] > summary { margin-bottom: 8px; }
.offer-steps { margin: 0 0 12px; padding-left: 20px; list-style: decimal; line-height: 1.5; }
.offer-preview { margin: 12px 0; }
.offer-prompt {
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: var(--theme-font-mono);
    font-size: 12px;
}
.offer textarea { font-family: var(--theme-font-mono); font-size: 12px; margin-bottom: 8px; }
.offer-error { margin-bottom: 8px; color: var(--theme-danger); }
.offer-error:empty { display: none; }
.offer-status { margin-bottom: 8px; line-height: 1.45; }

/* Übertragen per Einmal-Link */
.transfer { margin-bottom: 20px; }
.transfer-text { margin-bottom: 10px; line-height: 1.45; max-width: 75ch; }
.transfer-start { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.transfer-start .field { flex: 0 1 280px; }
.transfer-link { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
/* Heller Rand auch im dunklen Design, sonst lässt sich der Code nicht scannen. */
.transfer-qr { flex: none; width: 196px; height: 196px; padding: 10px; border-radius: 8px; background: #fff; }
.transfer-share { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 10px; line-height: 1.45; }
.transfer-changes { margin: 0 0 10px; padding-left: 20px; line-height: 1.5; overflow-wrap: anywhere; }
.transfer-undo { margin-top: 12px; }

/* Private Nebenkosten (Meine Finanzen) und Staffelmiete */
.cost-row,
.step {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 32px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.step { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) 32px; }
.cost-row { grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr) minmax(0, 1.1fr) minmax(0, 1.8fr) minmax(0, 0.8fr) 32px; }
.cost-split { display: flex; gap: 8px; min-width: 0; }
.cost-split select { flex: 1 1 0; }
.cost-split .input-wrap { flex: 0 0 84px; }
.cost-split .input-wrap[hidden] { display: none; }
.cost-mine { font-variant-numeric: tabular-nums; text-align: right; }
.cost-row:not(.room-head) .cost-mine { font-size: 13px; font-weight: 600; }
.cost-persons { margin: 4px 0 12px; }
.cost-total { font-weight: 600; }
.cost-total:empty { display: none; }
.cost-row .input-wrap input,
.step .input-wrap input { padding-right: 30px; }
.cost-row .unit,
.step .unit { right: 8px; }

.cost-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.cost-foot .btn-add { width: auto; flex: 1 1 160px; }

.group-hint {
    margin: -4px 0 10px;
    line-height: 1.45;
}

.steps-hint { margin-top: 14px; }
.costs { max-width: 980px; }

@media (max-width: 760px) {
    .cost-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--border);
    }
    .cost-row.room-head { display: none; }
    .cost-row > input,
    .cost-row > .cost-heat-name { grid-column: 1 / 3; grid-row: 1; }
    .cost-row > .icon-btn { grid-column: 3; grid-row: 1; }
    .cost-row > .input-wrap { grid-column: 1; }
    .cost-row > select { grid-column: 2 / -1; }
    .cost-split,
    .cost-row > .cost-mine { grid-column: 1 / -1; }
    .cost-row > .cost-mine::before { content: attr(data-who); font-weight: 400; color: var(--muted); }
}

/* Private Nebenkosten je Wohnung an-/abwählen */
.cost-checks {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cost-check {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 2px 10px;
    align-items: center;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.cost-check:hover { background: var(--theme-surface-muted); }
.cost-check input { margin: 0; }
.cost-name { overflow-wrap: anywhere; }
.cost-amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.cost-state { grid-column: 2 / -1; }
.cost-state:empty { display: none; }
.cost-check.is-covered .cost-name,
.cost-check.is-covered .cost-amount { color: var(--muted); text-decoration: line-through; }
.cost-sum { margin: 0 0 8px; font-weight: 600; }
.cost-sum:empty { display: none; }
.cost-single { margin-bottom: 12px; }
.cost-single > p { margin: 8px 0 4px; }
.cost-heating { margin-top: 18px; }
.cost-heating .cost-sum { margin-top: 8px; }
.cost-heating .field[hidden] { display: none; }
.cost-heat-title { margin-top: 20px; }
.cost-heat-name { font-weight: 600; }

/* Art der Wohnung (Kauf / Miete) auf den Karten */
.kind-tag {
    display: inline-block;
    vertical-align: 1px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 2px;
    color: var(--primary-strong);
    background: var(--primary-light);
}

.kind-tag.kind-rent {
    color: var(--theme-text);
    background: var(--theme-surface-muted);
    border: 1px solid var(--border);
}

.calc.rent-plan td { text-align: right; }

/* Wünsche & Bedingungen */
.people { max-width: 620px; }

.person {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) 36px minmax(0, 1fr) 32px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.person-me { display: flex; justify-content: center; }
.person .input-wrap input { padding-right: 30px; }
.person .unit { right: 8px; }
.person-more {
    margin: 0 0 8px;
    padding-left: 12px;
    border-left: 3px solid var(--border);
    font-size: 12.5px;
}

.person-more > summary { cursor: pointer; color: var(--muted); }
.person-more > .person-incl { margin: 8px 0; padding-left: 0; border-left: 0; }

.person-incl {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 0 0 14px;
    padding-left: 12px;
    border-left: 3px solid var(--border);
    font-size: 12.5px;
    line-height: 1.4;
}

.person-incl label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.person-incl label:has(:disabled) { color: var(--muted); cursor: default; }
.person-incl input { flex: none; margin: 0; }
.person-places {
    margin: 0 0 14px;
    padding-left: 12px;
    border-left: 3px solid var(--border);
    font-size: 12.5px;
}

.place {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr) 32px;
    gap: 8px;
    align-items: center;
    margin: 6px 0;
}

.person-places .btn { display: block; margin-top: 4px; padding: 4px 10px; font-size: 12.5px; min-height: 32px; }
.distance-note { margin-top: 10px; line-height: 1.45; }
.incl-left { flex-basis: 100%; }
.incl-left:empty { display: none; }
.people-sum { font-weight: 600; margin-top: 10px; }
.people-sum:empty { display: none; }

.wish-group { margin-top: 18px; }

.wish-row,
.rate-row {
    display: grid;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.wish-row { grid-template-columns: minmax(0, 1fr) repeat(var(--cols, 2), 104px) 32px; }
.rate-row { grid-template-columns: minmax(0, 1fr) repeat(var(--cols, 2), minmax(0, 170px)); align-items: start; }

.rate-row:not(.wish-head) {
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.rate-text .field-hint { display: block; margin-top: 2px; }
.rate-text { padding-top: 9px; overflow-wrap: anywhere; line-height: 1.4; }

.wish-head {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    margin-bottom: 4px;
}

.wish-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

/* Zweite Zeile je Wunsch: für alle gleich oder Ort je Person */
.wish-scope {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-bottom: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

.wish-scope select {
    width: auto;
    max-width: 100%;
    min-height: 32px;
    padding-top: 4px;
    padding-bottom: 4px;
    font-size: 12.5px;
}

.wish-place { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.wish-place select { min-width: 0; }

.wish-row .input-wrap input { padding-right: 30px; }
.wish-row .unit { right: 8px; }

.cell-label {
    display: none;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
}

.wish-cell.missing input,
.wish-cell.missing select {
    border-color: var(--theme-warning);
    background: var(--theme-warning-soft);
}

.wish-cell.must input {
    border-color: var(--primary);
    font-weight: 800;
}

.wish-cell.ko select {
    border-color: var(--theme-danger);
    background: var(--theme-danger-soft);
}

.wish-status:not(:empty) { margin-top: 16px; }
.rate-list { margin-top: 14px; }

@media (max-width: 620px) {
    .wish-row { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)) 32px; }
    .wish-row > .wish-text { grid-column: 1 / -1; }
    .rate-row { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
    .rate-row > .rate-text { grid-column: 1 / -1; padding-top: 0; }
    .wish-head { display: none; }
    .cell-label { display: block; }
}

/* Darlehen */
.loan {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-top: 14px;
    background: var(--theme-surface-muted);
}

.loan-head {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.loan-name { font-weight: 700; }

.auto-amount {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 12px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.loan-out {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--muted);
}

.loan-out b { color: var(--text); }

/* Diagramm */
.chart-box { margin-top: 8px; }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 8px;
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.key {
    display: inline-block;
    width: 16px;
    height: 0;
    border-top: 2px solid;
    border-radius: 2px;
}

.key.s1 { border-color: var(--series-1); }
.key.s2 { border-color: var(--series-2); }
.key.s3 { border-color: var(--series-3); }
.key.ref { border-color: var(--muted); border-top-style: dashed; }
.key-none { border-color: transparent; }

.chart-area {
    position: relative;
}

.chart-area svg { display: block; overflow: visible; }

.chart-area .grid { stroke: var(--border); stroke-width: 1; }
.chart-area .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-area .end-label { fill: var(--text); font-size: 11.5px; font-weight: 600; }
.chart-area .fixed { stroke: var(--theme-gray-400); stroke-dasharray: 4 4; }
.chart-area .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area .line.s1 { stroke: var(--series-1); }
.chart-area .line.s2 { stroke: var(--series-2); }
.chart-area .line.s3 { stroke: var(--series-3); }
.chart-area .line.ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-area .dot { stroke: var(--surface); stroke-width: 2; }
.chart-area .dot.s1 { fill: var(--series-1); }
.chart-area .dot.s2 { fill: var(--series-2); }
.chart-area .dot.s3 { fill: var(--series-3); }
.chart-area .dot.ref { fill: var(--muted); }
.chart-area .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart-area .hit { fill: transparent; cursor: crosshair; touch-action: pan-y; }

.tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--theme-shadow);
    padding: 8px 10px;
    font-size: 12px;
    min-width: 180px;
    z-index: 2;
}

.tip-title { font-weight: 700; color: var(--muted); margin-bottom: 4px; }

.tip-row {
    display: grid;
    grid-template-columns: 16px auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 1px 0;
}

.tip-row b { text-align: right; color: var(--theme-text-strong); font-variant-numeric: tabular-nums; }
.tip-row span:last-child { color: var(--muted); }
.tip-net { border-top: 1px solid var(--border); margin-top: 3px; padding-top: 4px; }

/* Tilgungsplan */
details { margin-top: 16px; }

summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--primary-strong);
    margin-bottom: 10px;
}

.plan th,
.plan td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
    font-size: 12.5px;
}

.plan thead th { background: var(--theme-surface-muted); color: var(--muted); font-weight: 700; }
.plan tr.mark td { background: var(--primary-light); font-weight: 700; }

/* ── Responsiv ── */

@media (max-width: 900px) {
    .detail-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
    .panel { padding: 16px 14px; }
    .span-2 { grid-column: auto; }
    .tiles-2 { grid-template-columns: minmax(0, 1fr); }
    .tile-value { font-size: 19px; }
    .room {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 28px;
    }
    .room-fair { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
    .room > .icon-btn { grid-column: 3; grid-row: 1; }
    .room > .input-wrap { grid-row: 2; }
    .room.room-head,
    .step.room-head { display: none; }
    .person { grid-template-columns: minmax(0, 1.2fr) 28px minmax(0, 1fr) 28px; }
    .page-head h1 { font-size: 24px; }
}
