:root {
    --panel-radius: 14px;
    --soft-shadow: 0 6px 18px rgba(0, 0, 0, .06);
    --rand: rgba(0, 0, 0, .08);
}

body {
    line-height: 1.55;
    background: #f6f7f9;
}

.app-nav .nav-link.active {
    font-weight: 600;
    color: var(--bs-primary) !important;
}

/* Karten/Kacheln */
.panel {
    background: #fff;
    border: 1px solid var(--rand);
    border-radius: var(--panel-radius);
    box-shadow: var(--soft-shadow);
    padding: 16px 18px;
}

.panel-titel {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .25rem;
}

.panel-untertitel {
    font-size: .85rem;
    color: var(--bs-secondary-color);
    margin-bottom: .75rem;
}

.seitenkopf h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.seitenkopf p {
    color: var(--bs-secondary-color);
    margin-bottom: 0;
    max-width: 70ch;
}

/* Kennzahlen */
.kpi {
    background: #fff;
    border: 1px solid var(--rand);
    border-radius: var(--panel-radius);
    padding: 14px 16px;
    height: 100%;
}

.kpi .wert {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.kpi .label {
    font-size: .85rem;
    color: var(--bs-secondary-color);
}

/* Bereichskarten auf der Übersicht */
.bereich {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.bereich .bereich-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: .75rem;
}

.bereich ul {
    padding-left: 1.1rem;
    color: var(--bs-secondary-color);
    font-size: .92rem;
}

.bereich .aktionen {
    margin-top: auto;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

/* Hinweise */
.hinweis {
    background: #eef4ff;
    border: 1px solid #d6e4ff;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: .9rem;
}

.hinweis.warnung {
    background: #fff8e6;
    border-color: #ffe3a3;
}

/* Diagramme */
.chart-box {
    position: relative;
    height: 320px;
}

.chart-box.hoch {
    height: 460px;
}

.chart-box.niedrig {
    height: 220px;
}

/* Karten */
.flaechenkarte {
    height: 460px;
    border-radius: 10px;
    background: #eef1f4;
}

.leaflet-container {
    font: inherit;
}

.legende {
    background: rgba(255, 255, 255, .92);
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    font-size: .8rem;
    line-height: 1.4;
}

.legende i {
    display: inline-block;
    width: 14px;
    height: 12px;
    margin-right: 6px;
    vertical-align: -1px;
    border-radius: 2px;
}

.filterleiste {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filterleiste .form-label {
    font-size: .8rem;
    margin-bottom: 2px;
    color: var(--bs-secondary-color);
}

.chip {
    border: 1px solid var(--rand);
    background: #fff;
    border-radius: 999px;
    padding: 3px 12px;
    font-size: .85rem;
    cursor: pointer;
}

.chip.aktiv {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

table.daten td, table.daten th {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

table.daten td.text, table.daten th.text {
    white-space: normal;
}

table.daten tr.ausgewaehlt td {
    background: #eef4ff;
}

.lade-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .5);
    z-index: 1000;
}

.lade-overlay.sichtbar {
    display: flex;
}

/* Trefferliste der Delikt-Suche */
.suchtreffer {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1100;
    max-height: 360px;
    overflow-y: auto;
    display: none;
}

.suchtreffer.offen {
    display: block;
}

.suchtreffer .list-group-item {
    font-size: .88rem;
    padding: .4rem .75rem;
}

.suchtreffer .list-group-item.active-treffer {
    background: #eef4ff;
}

/* Kein Fokusrahmen um angeklickte Kartenflächen */
.leaflet-interactive:focus {
    outline: none;
}

/* Stau-Kalender (Wochentag × Uhrzeit) */
.kalender {
    border-collapse: separate;
    border-spacing: 2px;
    width: 100%;
    table-layout: fixed;
    font-size: .72rem;
}

.kalender th {
    font-weight: 500;
    color: var(--bs-secondary-color);
    text-align: center;
    padding: 0;
}

.kalender th.tag {
    width: 2.4rem;
    text-align: left;
}

.kalender td {
    height: 26px;
    border-radius: 3px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    cursor: default;
}

.kalender td.wenig {
    opacity: .45;
}

.kalender td.leer {
    background: repeating-linear-gradient(45deg, #f1f3f5, #f1f3f5 3px, #e9ecef 3px, #e9ecef 6px);
}

.kalender td.jetzt {
    outline: 2px solid #111827;
    outline-offset: -1px;
}

@media (max-width: 768px) {
    .kalender td span {
        display: none;
    }
}

/* Unternavigation und Reiter */
.unternav .nav-link {
    padding: .3rem .85rem;
    font-size: .9rem;
}

.reiter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.reiter .chip {
    padding: 5px 14px;
}

.ansicht[hidden] {
    display: none !important;
}

/* CSV-Knopf oben rechts in einem Panel */
.panel {
    position: relative;
}

.csv-knopf {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: .72rem;
    padding: 1px 7px;
    line-height: 1.4;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: #fff;
    color: var(--bs-secondary-color);
}

.csv-knopf:hover {
    color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.panel:has(> .csv-knopf) > .panel-titel,
.panel:has(> .csv-knopf) > div > div > .panel-titel {
    padding-right: 3rem;
}

/* Jahreskalender (Monate × Tage) */
.jahreskalender {
    border-collapse: separate;
    border-spacing: 2px;
    width: 100%;
    table-layout: fixed;
    font-size: .7rem;
}

.jahreskalender th {
    font-weight: 500;
    color: var(--bs-secondary-color);
    text-align: center;
    padding: 0;
}

.jahreskalender th.monat {
    width: 2.2rem;
    text-align: left;
}

.jahreskalender td {
    height: 22px;
    border-radius: 3px;
    padding: 0;
}

.jahreskalender td.wert {
    cursor: pointer;
}

.jahreskalender td.wert:hover {
    outline: 2px solid #111827;
    outline-offset: -1px;
}

.jahreskalender td.fehlt {
    background: #f1f3f5;
}

.farblegende {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: var(--bs-secondary-color);
}

.farblegende .verlauf {
    height: 10px;
    width: 160px;
    border-radius: 3px;
}

/* Heat-Tabelle (z. B. SAIDI Land × Jahr) */
table.heat td {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-size: .78rem;
    padding: 3px 4px;
    white-space: nowrap;
}

table.heat th {
    font-size: .78rem;
    font-weight: 500;
    white-space: nowrap;
}

table.heat tr.de td, table.heat tr.de th {
    font-weight: 700;
    border-top: 2px solid #adb5bd;
}

.tabelle-scroll {
    max-height: 520px;
    overflow: auto;
}

.tabelle-scroll thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

tr.klickbar {
    cursor: pointer;
}

tr.klickbar:hover td {
    background: #f4f7fd;
}

/* Kopfzeilen mit Auswahlfeld rechts: Platz für den CSV-Knopf lassen */
.panel:has(> .csv-knopf) > .d-flex.justify-content-between:first-of-type {
    padding-right: 2.8rem;
}

/* zweiter Knopf (PNG) links neben dem CSV-Knopf */
.panel > .bild-knopf {
    right: 52px;
}

.panel:has(> .bild-knopf) > .d-flex.justify-content-between:first-of-type {
    padding-right: 5.6rem;
}

.panel:has(> .bild-knopf) > .panel-titel {
    padding-right: 6rem;
}
/* Ergebnis der Rechner (Geld & Inflation) */
.ergebnis-zahl {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
@media (max-width: 576px) {
    .ergebnis-zahl {
        font-size: 1.7rem;
    }
}

/* Chronik der Themenseiten: Nummern passen zu den Markierungen im Diagramm */
.chronik {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

@media (min-width: 1200px) {
    .chronik {
        max-height: 440px;
        overflow-y: auto;
    }
}

.chronik li {
    display: flex;
    gap: .6rem;
    padding: .35rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.chronik li:last-child {
    border-bottom: 0;
}

.chronik .nr {
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    background: #111827;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: .1rem;
}

/* Kreis-Steckbrief: Lage im Bundesvergleich */
.profil-zeile {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) minmax(0, 1.2fr);
    gap: .75rem;
    align-items: center;
    padding: .3rem 0;
    font-size: .85rem;
    border-bottom: 1px solid rgba(0, 0, 0, .05);
}

.profil-balken {
    position: relative;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, #dbeafe, #93c5fd, #2563eb);
}

.profil-median {
    position: absolute;
    left: 50%;
    top: -3px;
    bottom: -3px;
    width: 1px;
    background: rgba(17, 24, 39, .45);
}

.profil-punkt {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: #f59e0b;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

.profil-punkt-legende {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 5px;
    border-radius: 50%;
    vertical-align: -1px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

@media (max-width: 576px) {
    .profil-zeile {
        grid-template-columns: 1fr 1fr;
    }

    .profil-name {
        grid-column: 1 / -1;
    }
}

/* Klimastreifen: ein Streifen je Jahr, gefärbt nach der Abweichung vom Mittel 1961–1990 */
.streifen {
    display: flex;
    height: 130px;
    border-radius: 10px;
    overflow: hidden;
}

.streifen span {
    flex: 1 1 0;
    min-width: 0;
}

.streifen-achse {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    color: #6b7280;
    margin-top: 4px;
}

@media (max-width: 576px) {
    .streifen {
        height: 90px;
    }
}

/* Europa im Vergleich */
.profil-liste {
    list-style: none;
    padding: 0;
    margin: 0;
}

.profil-liste li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--rand);
    font-size: .9rem;
}

.profil-liste li:last-child {
    border-bottom: 0;
}

.profil-liste .platz {
    text-align: right;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
}

.profil-liste a {
    text-decoration: none;
}

.profil-tabelle tbody tr[data-id] {
    cursor: pointer;
}

.profil-tabelle th.gruppe {
    background: var(--bs-tertiary-bg);
    font-weight: 600;
}

.lage {
    position: relative;
    height: 14px;
    min-width: 120px;
}

.lage .spanne {
    position: absolute;
    left: 0;
    right: 0;
    top: 5px;
    height: 4px;
    border-radius: 2px;
    background: #e5e7eb;
}

.lage .eu {
    position: absolute;
    top: 1px;
    width: 2px;
    height: 12px;
    background: #6b7280;
}

.lage .punkt {
    position: absolute;
    top: 2px;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-radius: 50%;
    background: #f59e0b;
    border: 1px solid #fff;
}

.erwartung-karte {
    border: 1px solid var(--rand);
    border-radius: 10px;
    padding: 10px 12px;
    height: 100%;
    cursor: pointer;
    font-size: .9rem;
}

.erwartung-karte:hover, .zusammenhang-karte:hover {
    border-color: #93b4f0;
    background: #f8fbff;
}

.erwartung-karte .pfeil {
    font-weight: 700;
    margin-right: 4px;
}

.schluesse {
    padding-left: 1.1rem;
    margin: 0;
}

.schluesse li {
    margin-bottom: .55rem;
}

.kennwert {
    background: var(--bs-tertiary-bg);
    border-radius: 8px;
    padding: 6px 8px;
    text-align: center;
    height: 100%;
}

.kennwert .wert {
    font-weight: 700;
    font-size: 1.05rem;
}

.kennwert .label {
    font-size: .72rem;
    color: var(--bs-secondary-color);
    line-height: 1.2;
}

.zusammenhang-karte {
    background: #fff;
    border: 1px solid var(--rand);
    border-radius: var(--panel-radius);
    padding: 14px 16px;
    height: 100%;
    cursor: pointer;
}

.zusammenhang-karte .satz {
    font-weight: 500;
    margin-bottom: .5rem;
}

.zusammenhang-karte .marke {
    display: inline-block;
    font-size: .75rem;
    border-radius: 999px;
    padding: 1px 8px;
    margin-right: 4px;
    background: var(--bs-tertiary-bg);
}

.zusammenhang-karte .marke.bleibt {
    background: #dcfce7;
    color: #166534;
}

.zusammenhang-karte .marke.wohlstand {
    background: #fef3c7;
    color: #92400e;
}

/* Einbetten: dritter Knopf links neben PNG und CSV */
.panel > .einbetten-knopf {
    right: 92px;
}

.panel:has(> .einbetten-knopf) > .d-flex.justify-content-between:first-of-type {
    padding-right: 8.4rem;
}

.panel:has(> .einbetten-knopf) > .panel-titel {
    padding-right: 8.8rem;
}

.einbetten-box {
    margin-top: .75rem;
    padding: 10px 12px;
    border: 1px solid #d6e4ff;
    border-radius: 10px;
    background: #eef4ff;
}

/* Eingebettete Ansicht: nur das gewählte Panel und die Quelle */
html.eingebettet body {
    background: #fff;
    min-height: 0 !important;
}

html.eingebettet body > *:not(#einbettung) {
    display: none !important;
}

#einbettung {
    padding: 6px;
}

#einbettung > .panel {
    box-shadow: none;
}

.einbettung-quelle {
    font-size: .75rem;
    color: #6b7280;
    padding: 6px 4px 0;
}

/* Europa: Umfeld in der Rangliste und Ländervergleich */
.profil-tabelle tr.offen td {
    background: #f8fbff;
}

.umfeld-zeile td {
    background: #f8fbff;
    white-space: normal !important;
    padding: 10px 12px !important;
}

.umfeld-liste {
    list-style: none;
    padding: 0;
    margin: 0;
    min-width: 240px;
}

.umfeld-liste li {
    display: flex;
    gap: 8px;
    padding: 2px 6px;
    border-radius: 4px;
}

.umfeld-liste li.eigen {
    background: #fef3c7;
}

.umfeld-liste li.luecke {
    color: var(--bs-secondary-color);
    font-style: italic;
}

.umfeld-liste .rang {
    width: 2.2em;
    text-align: right;
    color: var(--bs-secondary-color);
}

.umfeld-liste .wert {
    margin-left: auto;
    padding-left: 12px;
}

.umfeld-liste a {
    text-decoration: none;
}

.umfeld-text {
    max-width: 380px;
}

.vergleich-land {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--rand);
    border-left: 4px solid var(--farbe);
    border-radius: 8px;
    padding: 4px 6px 4px 8px;
}

.vergleich-land .form-select {
    width: auto;
    border: 0;
    padding-left: 4px;
}

.farbpunkt {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--farbe);
    margin-right: 6px;
    vertical-align: baseline;
}

.vergleich-bilanz {
    border-left: 4px solid var(--farbe);
    text-align: left;
}

.vergleich-tabelle tbody tr[data-id] {
    cursor: pointer;
}

.vergleich-tabelle th.gruppe {
    background: var(--bs-tertiary-bg);
    font-weight: 600;
}

.vergleich-tabelle .platz-klein {
    font-size: .72rem;
    color: var(--bs-secondary-color);
}

.vergleich-tabelle td:first-child {
    white-space: normal;
    min-width: 150px;
}

.vergleich-tabelle .lage {
    min-width: 180px;
}

/* Kennzahl-Spalte bleibt beim seitlichen Wischen stehen */
@media (max-width: 767.98px) {
    .vergleich-tabelle td:first-child, .vergleich-tabelle thead th:first-child {
        position: sticky;
        left: 0;
        background: #fff;
        z-index: 1;
        min-width: 120px;
        max-width: 140px;
    }
}

.vergleich-tabelle th.gruppe span {
    position: sticky;
    left: 8px;
}

/* Farbpunkt vor einer Tabellenzeile (Legende) */
.legende-punkt {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 2px;
    vertical-align: -1px;
}

/* Neu in den Daten */
.neu-eintrag {
    padding: .55rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.neu-eintrag:last-child {
    border-bottom: 0;
}

.neu-titel {
    font-weight: 600;
    text-decoration: none;
}

.neu-titel:hover {
    text-decoration: underline;
}

.neu-meta {
    font-size: .75rem;
    color: var(--bs-secondary-color);
}

.neu-raster .neu-eintrag {
    padding-right: 1rem;
}

@media (min-width: 768px) {
    .neu-raster .neu-eintrag:nth-last-child(-n+2) {
        border-bottom: 0;
    }
}

@media (min-width: 1200px) {
    .neu-raster .neu-eintrag:nth-last-child(-n+4) {
        border-bottom: 0;
    }
}

/* Auf dem Handy nur die vier neuesten */
@media (max-width: 767.98px) {
    .neu-raster .neu-eintrag:nth-child(n+5) {
        display: none;
    }

    .neu-raster .neu-eintrag:nth-child(4) {
        border-bottom: 0;
    }
}

/* Regionen: „Wo würde ich gern wohnen?“ – je Kriterium Bezeichnung und Gewicht in einer Zeile */
.wunsch-liste {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
    align-items: center;
}

.wunsch-liste label {
    font-size: .88rem;
}

.wunsch-liste select {
    width: 9.5rem;
}

.wunsch-liste select.gewaehlt {
    border-color: var(--bs-primary);
    font-weight: 600;
}
