/* KWP-Portal – Gestaltung angelehnt an den Auftritt der energie schwaben (Navy, Orange, klare Karten, Pillen-Schaltflächen).
   Schrift: „Univers Next“ ist lizenzpflichtig und wird nicht mitgeliefert; ist sie installiert, wird sie verwendet,
   sonst die systemeigene Helvetica/Arial. Hell/Dunkel über <html data-theme> (theme.js). */

:root {
    --es-navy: #003366;
    --es-navy-2: #17385f;
    --es-orange: #ff9900;
    --es-orange-2: #e84e10;
    --es-orange-text: #b35c00;
    --es-blue: #2b6ea2;
    --es-blue-2: #004098;
    --es-green: #008830;
    --es-gradient: linear-gradient(147.14deg, #f90, #f90 50%, #e84e10);
    --es-gradient-green: linear-gradient(147.14deg, #60b11f 6.95%, #008830 93.05%);
    --es-gradient-navy: linear-gradient(135deg, #003366 0%, #17385f 55%, #004098 100%);

    --bg: #f2f2f5;
    --surface: #ffffff;
    --surface-2: #fafafc;
    --surface-3: #ecf2f5;
    --text: #1c1c28;
    --text-muted: #5b666d;
    --heading: #003366;
    --link: #004098;
    --border: #cfd6da;
    --border-soft: #e3e9ed;
    --shadow: 0 0 2px rgba(40, 41, 61, .04), 0 4px 8px rgba(96, 97, 112, .16);
    --shadow-strong: 0 2px 4px rgba(40, 41, 61, .08), 0 12px 24px rgba(96, 97, 112, .2);
    --focus: 0 0 0 3px rgba(255, 153, 0, .45);
    --danger: #c62828;
    --success: #1b7f3a;
    --warning-bg: #fff4e0;
    --map-bg: #f7f8f5;
    --map-land: #eef1ea;
    --radius: 8px;
    --radius-lg: 12px;
    --header-h: 72px;
    --font: "Univers Next", "Univers", "Helvetica Neue", Helvetica, Arial, sans-serif;

    /* Syncfusion (Fluent 2) an die Hausfarben anpassen */
    --color-sf-primary: #004098;
    --color-sf-primary-light: #b8cdea;
    --color-sf-primary-lighter: #e8eff9;
    --color-sf-primary-dark: #003366;
    --color-sf-primary-darker: #002244;
    --color-sf-primary-label-color: #004098;

    /* Tokens der Info- und Update-Dialoge (appsolvia-Veredelung) auf die Hausfarben abgebildet; sie folgen hell/dunkel,
       weil <html data-theme> die Grundfarben oben umstellt. */
    --text-label: var(--heading);
    --text-heading: var(--heading);
    --text-body: var(--text);
    --text-accent: var(--es-orange-text);
    --text-accent-hover: var(--es-orange-2);
    --text-on-primary: #ffffff;
    --surface-card: var(--surface);
    --surface-tint: var(--surface-3);
    --surface-pressed: var(--surface-3);
    --border-default: var(--border);
    --border-strong: var(--border);
    --border-tint: var(--border-soft);
    --font-body: var(--font);
    --font-heading: var(--font);
    --radius-4: 4px;
    --radius-8: var(--radius);
    --focus-color: var(--es-orange);
    --shadow-10: var(--shadow-strong);
    --disabled-bg: var(--surface-3);
    --disabled-fg: var(--text-muted);
    --button-primary: var(--es-orange);
    --button-primary-hover: var(--es-orange-2);
    --button-primary-active: var(--es-orange-2);
    --backdrop: rgba(0, 20, 40, .5);
    --success-fg: var(--success);
    --gradient-02: var(--es-gradient-navy);
}

[data-theme="dark"] {
    --bg: #0d1b2a;
    --surface: #13263a;
    --surface-2: #172d44;
    --surface-3: #1c3550;
    --text: #e8edf2;
    --text-muted: #a5b3bf;
    --heading: #ffffff;
    --link: #8fbaf0;
    --border: #2d4a66;
    --border-soft: #213a54;
    --shadow: 0 0 2px rgba(0, 0, 0, .4), 0 4px 10px rgba(0, 0, 0, .35);
    --shadow-strong: 0 2px 6px rgba(0, 0, 0, .45), 0 14px 28px rgba(0, 0, 0, .45);
    --es-orange-text: #ffb347;
    --warning-bg: #3a2a10;
    --map-bg: #0f2133;
    --map-land: #142a40;
    --danger: #ff7b7b;
    --success: #6fd08c;

    --color-sf-primary: #8fbaf0;
    --color-sf-primary-text-color: #0d1b2a;
    --color-sf-primary-light: #2f5680;
    --color-sf-primary-lighter: #1c3550;
    --color-sf-primary-dark: #b5d2f5;
    --color-sf-primary-label-color: #8fbaf0;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    color: var(--heading);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.2;
    margin: 0 0 .5rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 .75rem; }

a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--es-orange-2); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
/* Blazor setzt nach der Navigation den Fokus auf die Überschrift (FocusOnNavigate) – für Screenreader, ohne sichtbaren Rahmen. */
h1:focus, h1:focus-visible { outline: none; box-shadow: none; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.muted { color: var(--text-muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

/* ---------- Kopfzeile ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    box-shadow: 0 2px 10px rgba(0, 51, 102, .08);
    border-bottom: 1px solid var(--border-soft);
}

.app-header__inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: var(--header-h);
}

.brand {
    display: flex;
    align-items: center;
    gap: .875rem;
    text-decoration: none;
    color: var(--es-navy-2);
    flex-shrink: 0;
}

[data-theme="dark"] .brand { color: #fff; }

.brand__logo { height: 34px; width: auto; display: block; }

.brand__product {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    padding-left: .875rem;
    line-height: 1.1;
}

.brand__name { font-weight: 700; font-size: 1.05rem; color: var(--heading); letter-spacing: -.01em; }
.brand__claim { font-size: .72rem; color: var(--text-muted); }

.main-nav { display: flex; align-items: stretch; height: 100%; gap: .25rem; margin-left: .75rem; }

.main-nav a {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: 0 .9rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: .95rem;
    border-bottom: 4px solid transparent;
    border-top: 4px solid transparent;
}

.main-nav a:hover { color: var(--es-orange-text); }
.main-nav a.active { color: var(--es-orange-text); border-bottom-color: var(--es-orange); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.icon-button, .app-info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--heading);
    cursor: pointer;
    padding: 0;
    transition: background .15s, border-color .15s;
}

.icon-button:hover, .app-info-button:hover { border-color: var(--es-orange); background: var(--surface-2); }

.user-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .75rem .25rem .25rem;
    border: 1px solid var(--border);
    border-radius: 40px;
    background: var(--surface);
    color: var(--text);
    font-size: .875rem;
    cursor: pointer;
    max-width: 260px;
}

.user-chip__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--es-navy);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.user-chip__text { display: flex; flex-direction: column; line-height: 1.1; overflow: hidden; text-align: left; }
.user-chip__name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: .72rem; color: var(--text-muted); }

.user-menu { position: relative; }

.user-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-strong);
    padding: .5rem;
    z-index: 120;
}

.user-menu__panel a, .user-menu__panel button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: .5rem;
    padding: .55rem .75rem;
    border-radius: 6px;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
}

.user-menu__panel a:hover, .user-menu__panel button:hover { background: var(--surface-3); color: var(--text); }
.user-menu__panel hr { border: 0; border-top: 1px solid var(--border-soft); margin: .35rem 0; }
.user-menu__meta { padding: .5rem .75rem; font-size: .8rem; color: var(--text-muted); }

.demo-banner {
    background: var(--warning-bg);
    color: var(--text);
    font-size: .82rem;
    text-align: center;
    padding: .3rem 1rem;
    border-bottom: 1px solid var(--border-soft);
}

/* Tab-Leiste auf schmalen Bildschirmen */
.tab-bar { display: none; }

/* ---------- Seite ---------- */

.page {
    max-width: 1680px;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 2.5rem;
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head__actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }

.app-footer {
    max-width: 1680px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2rem;
    font-size: .8rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
}

.app-footer a { color: var(--text-muted); }

/* ---------- Karten (Cards) ---------- */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem;
    min-width: 0;
}

.card + .card { margin-top: 1rem; }

.card__title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--heading);
    margin: 0 0 .75rem;
}

.card__title .hint { margin-left: auto; font-weight: 400; font-size: .78rem; color: var(--text-muted); }

/* ---------- Schaltflächen (wie energie-schwaben.de) ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 44px;
    padding: .6rem 1.4rem;
    border-radius: 40px;
    border: 0;
    font: inherit;
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s;
    white-space: nowrap;
}

.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary { background: var(--es-gradient); color: #fff; }
.btn-primary:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 8px 18px rgba(232, 78, 16, .35); }

.btn-secondary {
    color: var(--heading);
    background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--es-gradient) border-box;
    border: 2px solid transparent;
}

.btn-secondary:hover { color: var(--heading); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(255, 153, 0, .25); }

.btn-tertiary {
    background: none;
    color: var(--es-orange-text);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: .82rem;
    padding: .4rem .25rem;
    min-height: 36px;
}

.btn-tertiary:hover { color: var(--es-orange-2); text-decoration: underline; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-small { min-height: 34px; padding: .35rem .9rem; font-size: .85rem; }

/* ---------- Gemeindekopf ---------- */

.gemeinde-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.25rem;
    align-items: center;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.gemeinde-head::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--es-gradient);
}

.wappen { width: 64px; height: 75px; display: flex; align-items: center; justify-content: center; }
.wappen svg, .wappen img { width: 100%; height: 100%; object-fit: contain; }
.wappen--klein { width: 40px; height: 47px; }

.gemeinde-head__name { margin: 0; font-size: 1.6rem; }
.gemeinde-head__meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }
.gemeinde-head__actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .15rem .6rem;
    border-radius: 40px;
    font-size: .75rem;
    font-weight: 700;
    background: var(--surface-3);
    color: var(--heading);
    white-space: nowrap;
}

.badge--orange { background: #fff0d9; color: #8a4600; }
.badge--green { background: #e3f4e6; color: #10612a; }
.badge--demo { background: #fde7c2; color: #7a3c00; }
[data-theme="dark"] .badge--orange, [data-theme="dark"] .badge--demo { background: #4a3210; color: #ffd39a; }
[data-theme="dark"] .badge--green { background: #173d26; color: #a6e3b6; }

/* ---------- Prozessschritte (Tabs als Chevrons) ---------- */

.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    filter: drop-shadow(0 2px 4px rgba(0, 51, 102, .12));
}

.steps li { min-width: 0; }

.step {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    height: 64px;
    padding: 0 1.5rem 0 2.4rem;
    border: 0;
    background: var(--surface);
    color: var(--heading);
    font: inherit;
    text-align: left;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 50%, calc(100% - 22px) 100%, 0 100%, 22px 50%);
    margin-right: -14px;
    transition: background .15s;
}

.steps li:first-child .step { clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 50%, calc(100% - 22px) 100%, 0 100%); padding-left: 1.25rem; border-radius: var(--radius) 0 0 var(--radius); }
.steps li:last-child .step { margin-right: 0; }

.step:hover { background: var(--surface-3); }

.step__nr {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--es-orange);
    color: var(--es-orange-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.step__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.step__title { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step__sub { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.step__kurz { display: none; }
.step--active { background: var(--es-navy); color: #fff; }
.step--active:hover { background: var(--es-navy); }
.step--active .step__nr { background: var(--es-gradient); border-color: transparent; color: #fff; }
.step--active .step__sub { color: rgba(255, 255, 255, .78); }
[data-theme="dark"] .step--active { background: #1f4f80; }

/* ---------- Wärmeplan-Raster ---------- */

.plan {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr) 400px;
    grid-template-areas: "ebenen karte werte";
    gap: 1rem;
    align-items: start;
}

.plan__ebenen { grid-area: ebenen; }
.plan__karte { grid-area: karte; min-width: 0; }
.plan__werte { grid-area: werte; min-width: 0; }

.plan-unten { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; margin-top: 1rem; }

/* ---------- Ebenensteuerung ---------- */

.ebenen-gruppe + .ebenen-gruppe { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border-soft); }

.ebenen-gruppe__titel {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin: 0 0 .5rem;
}

.ebene {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem .5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: .9rem;
    user-select: none;
}

.ebene:hover { background: var(--surface-3); }
.ebene input { accent-color: var(--es-navy); width: 18px; height: 18px; margin: 0; flex-shrink: 0; cursor: pointer; }
[data-theme="dark"] .ebene input { accent-color: var(--es-orange); }
.ebene__swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, .15); }
.ebene__swatch--line { height: 4px; border-radius: 2px; border: 0; }
.ebene__text { flex: 1; min-width: 0; }
.ebene--aktiv { font-weight: 700; color: var(--heading); }

/* ---------- Legende ---------- */

.legende { display: flex; flex-direction: column; gap: .3rem; font-size: .84rem; }
.legende__block + .legende__block { margin-top: .75rem; }
.legende__titel { font-weight: 700; font-size: .82rem; color: var(--heading); margin-bottom: .3rem; }
.legende__einheit { font-weight: 400; color: var(--text-muted); }
.legende__eintrag { display: flex; align-items: center; gap: .5rem; line-height: 1.25; }
.legende__farbe { width: 16px; height: 12px; border-radius: 2px; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, .12); }
.legende__linie { width: 18px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.legende__linie--gestrichelt { background-image: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 10px) !important; }
.legende__punkt { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.legende__anzahl { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.legende__verlauf { height: 12px; border-radius: 3px; background: linear-gradient(90deg, rgba(255,255,178,.4), #fed976, #feb24c, #fd8d3c, #f03b20, #bd0026, #800026); }
.legende__skala { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-muted); }

/* ---------- Karte ---------- */

.karte-card { padding: 0; overflow: hidden; position: relative; }

.karte-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border-soft);
}

.karte-toolbar__titel { font-weight: 700; color: var(--heading); margin-right: auto; display: flex; align-items: center; gap: .5rem; min-width: 0; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .35rem .2rem .7rem;
    border-radius: 40px;
    background: var(--es-navy);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}

.chip button { border: 0; background: rgba(255, 255, 255, .2); color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; line-height: 1; padding: 0; }

.karte {
    position: relative;
    height: 600px;
    background: var(--map-bg);
}

.karte .e-maps, .karte .sf-maps { background: transparent; }

.karte-hinweis {
    position: absolute;
    left: .75rem;
    bottom: .6rem;
    font-size: .72rem;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    padding: .15rem .5rem;
    border-radius: 4px;
    pointer-events: none;
}

.karte-massstab {
    position: absolute;
    right: .75rem;
    bottom: .6rem;
    font-size: .72rem;
    color: var(--text-muted);
    pointer-events: none;
}

.karte-modus {
    position: absolute;
    left: 50%;
    top: .75rem;
    transform: translateX(-50%);
    background: var(--es-navy);
    color: #fff;
    padding: .4rem .9rem;
    border-radius: 40px;
    font-size: .85rem;
    font-weight: 700;
    box-shadow: var(--shadow-strong);
    z-index: 5;
}

.steckbrief {
    position: absolute;
    top: .75rem;
    right: .75rem;
    width: min(340px, calc(100% - 1.5rem));
    max-height: calc(100% - 1.5rem);
    overflow: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-strong);
    padding: 1rem 1.1rem;
    z-index: 6;
    font-size: .88rem;
}

.steckbrief h3 { padding-right: 2rem; margin-bottom: .2rem; }
.steckbrief__close { position: absolute; top: .6rem; right: .6rem; width: 32px; height: 32px; }
.steckbrief dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: .75rem 0 0; }
.steckbrief dt { color: var(--text-muted); }
.steckbrief dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.steckbrief__hinweis { margin-top: .75rem; font-size: .75rem; color: var(--text-muted); }

.regler {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1.25rem 1rem;
    border-top: 1px solid var(--border-soft);
}

.regler__label { font-weight: 700; color: var(--heading); font-size: .9rem; white-space: nowrap; }
.regler__wert { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--heading); min-width: 6.5rem; text-align: right; font-size: 1.05rem; }
.regler__wert--gross { font-size: 1.6rem; color: var(--es-orange-text); }
.regler .e-slider-container { padding-top: .35rem; }

.play {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: var(--es-gradient);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ---------- Kennzahlen ---------- */

.kennzahlen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }

.kennzahl {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .85rem 1rem;
    border-top: 4px solid var(--es-navy);
    min-width: 0;
}

.kennzahl--orange { border-top-color: var(--es-orange); }
.kennzahl--green { border-top-color: var(--es-green); }
.kennzahl--blue { border-top-color: var(--es-blue); }
[data-theme="dark"] .kennzahl { border-top-color: #4d86c4; }
[data-theme="dark"] .kennzahl--orange { border-top-color: var(--es-orange); }
[data-theme="dark"] .kennzahl--green { border-top-color: #48b26a; }

.kennzahl__label { font-size: .76rem; color: var(--text-muted); line-height: 1.25; }
.kennzahl__wert { font-size: 1.45rem; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: .15rem; white-space: nowrap; }
.kennzahl__einheit { font-size: .8rem; font-weight: 400; color: var(--text-muted); margin-left: .2rem; }
.kennzahl__trend { font-size: .76rem; margin-top: .1rem; color: var(--text-muted); }
.kennzahl__trend--gut { color: var(--success); font-weight: 700; }

.diagramm { min-height: 250px; }
.diagramm + .diagramm { margin-top: .5rem; }

/* ---------- Text und Anmerkungen ---------- */

.infotext p { color: var(--text); }
.infotext h3 { margin-top: 1rem; }

.erklaerung {
    background: var(--surface-2);
    border-left: 4px solid var(--es-orange);
    padding: .75rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: .92rem;
    margin-bottom: 1rem;
}

.anmerkungen { display: flex; flex-direction: column; gap: .75rem; }

.anmerkung {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: .65rem .85rem;
    background: var(--surface-2);
}

.anmerkung__kopf { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .78rem; color: var(--text-muted); align-items: center; }
.anmerkung__autor { font-weight: 700; color: var(--heading); }
.anmerkung__text { margin: .35rem 0 0; white-space: pre-wrap; font-size: .92rem; }
.anmerkung__ort { color: var(--es-orange-text); font-weight: 700; }

.formzeile { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .85rem; }
.formzeile label, .formzeile .label { font-weight: 700; font-size: .85rem; color: var(--heading); }
.formzeile .hilfe { font-size: .78rem; color: var(--text-muted); }

.eingabe, textarea.eingabe, select.eingabe {
    width: 100%;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
}

.eingabe:focus { border-color: var(--es-navy); box-shadow: var(--focus); outline: none; }
textarea.eingabe { min-height: 90px; resize: vertical; }

.aktionen { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.meldung {
    padding: .7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .92rem;
    border: 1px solid transparent;
}

.meldung--fehler { background: #fdecec; border-color: #f3b4b4; color: #8b1a1a; }
.meldung--ok { background: #e6f5ea; border-color: #a9dcb7; color: #145c2c; }
.meldung--info { background: var(--warning-bg); border-color: #f5cf8f; color: var(--text); }
[data-theme="dark"] .meldung--fehler { background: #3d1717; border-color: #7a2d2d; color: #ffc4c4; }
[data-theme="dark"] .meldung--ok { background: #123222; border-color: #2c6b45; color: #b8ebc7; }

.leer { text-align: center; color: var(--text-muted); padding: 2rem 1rem; }

/* ---------- Startseite (Gemeinden) ---------- */

.hero {
    background: var(--es-gradient-navy);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 2rem 2.25rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.hero h1 { color: #fff; font-size: 2rem; margin-bottom: .5rem; }
.hero p { max-width: 760px; color: rgba(255, 255, 255, .88); font-size: 1.05rem; margin: 0; }
.hero::after {
    content: "";
    position: absolute;
    right: -80px;
    top: -80px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 153, 0, .55), rgba(232, 78, 16, 0) 70%);
}

.gemeinden { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }

.gemeinde-karte {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    border: 2px solid transparent;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.gemeinde-karte:hover { transform: translateY(-3px); box-shadow: var(--shadow-strong); border-color: var(--es-orange); color: var(--text); }
.gemeinde-karte__kopf { display: flex; gap: 1rem; align-items: center; }
.gemeinde-karte__name { font-weight: 700; font-size: 1.15rem; color: var(--heading); }
.gemeinde-karte__werte { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; border-top: 1px solid var(--border-soft); padding-top: .75rem; }
.gemeinde-karte__wert { font-weight: 700; color: var(--heading); font-size: 1.05rem; }
.gemeinde-karte__label { font-size: .72rem; color: var(--text-muted); }

/* ---------- Tabellen und Verwaltung ---------- */

.tabelle { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabelle th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: .5rem .6rem; border-bottom: 2px solid var(--border-soft); }
.tabelle td { padding: .55rem .6rem; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.tabelle td.zahl, .tabelle th.zahl { text-align: right; font-variant-numeric: tabular-nums; }

.zwei-spalten { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.drei-spalten { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }

.ebenen-status { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }

.ebenen-status__eintrag {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: .75rem .9rem;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.ebenen-status__eintrag strong { color: var(--heading); }

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--surface-2);
}

/* ---------- Anmeldung (statische Seiten) ---------- */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr);
}

.auth__bild {
    background: var(--es-gradient-navy);
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.auth__bild h1 { color: #fff; font-size: 2.2rem; max-width: 520px; }
.auth__bild p { color: rgba(255, 255, 255, .85); max-width: 520px; font-size: 1.05rem; }
.auth__bild .brand { color: #fff; }
.auth__bild .brand__product { border-left-color: rgba(255, 255, 255, .35); }
.auth__bild .brand__name { color: #fff; }
.auth__bild .brand__claim { color: rgba(255, 255, 255, .75); }

.auth__punkte { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .6rem; }
.auth__punkte li { display: flex; gap: .6rem; align-items: flex-start; color: rgba(255, 255, 255, .92); }
.auth__punkte li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--es-orange); margin-top: .45rem; flex-shrink: 0; }

.auth__deko { position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 153, 0, .5), rgba(232, 78, 16, 0) 70%); }

.auth__form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--bg); }
.auth__box { width: 100%; max-width: 420px; }
.auth__box .card { padding: 1.75rem; }
.auth__box h2 { font-size: 1.5rem; }

.demo-zugaenge { margin-top: 1.25rem; }
.demo-zugaenge form { margin: 0; }
.demo-zugang {
    display: flex;
    width: 100%;
    align-items: center;
    gap: .75rem;
    padding: .7rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    margin-top: .5rem;
}

.demo-zugang:hover { border-color: var(--es-orange); box-shadow: var(--shadow); }
.demo-zugang strong { display: block; color: var(--heading); }
.demo-zugang span { font-size: .8rem; color: var(--text-muted); }
.demo-zugang span.user-chip__avatar { color: #fff; font-size: .78rem; font-weight: 700; flex: none; }

.trenner { display: flex; align-items: center; gap: .75rem; color: var(--text-muted); font-size: .8rem; margin: 1.25rem 0 .25rem; }
.trenner::before, .trenner::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.auth__links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: center; margin-top: 1rem; font-size: .8rem; }
.auth__links a { color: var(--text-muted); }

.validation-message, .feld-fehler { color: var(--danger); font-size: .8rem; }
.validation-summary-errors ul, ul.validation-errors { margin: 0 0 1rem; padding-left: 1.1rem; color: var(--danger); font-size: .88rem; }

/* ---------- Einstellungen ---------- */

.optionen { display: flex; flex-wrap: wrap; gap: .5rem; }

.option {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1rem;
    border-radius: 40px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
    text-decoration: none;
    cursor: pointer;
}

.option:hover { color: var(--text); border-color: var(--es-orange); }
.option--aktiv, .option--aktiv:hover { border-color: var(--es-navy); background: var(--es-navy); color: #fff; font-weight: 700; }
[data-theme="dark"] .option--aktiv { background: #2c5f96; border-color: #2c5f96; }

/* ---------- Formulare und Code in der Verwaltung ---------- */

.checkzeile { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; cursor: pointer; }
.checkzeile input { width: 18px; height: 18px; accent-color: var(--es-navy); flex: none; }

pre.code {
    margin: 0 0 1rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border);
    background: var(--surface-2, #f5f7f9);
    color: var(--text);
    font: .85rem/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    white-space: pre;
}

/* ---------- Syncfusion-Feinschliff ---------- */

input[type="file"] { font: inherit; font-size: .85rem; color: var(--text-muted); max-width: 100%; }
input[type="file"]::file-selector-button {
    margin-right: .75rem;
    padding: .45rem 1rem;
    border-radius: 40px;
    border: 2px solid var(--es-orange);
    background: transparent;
    color: var(--heading);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--es-orange-2); }

.e-dialog .e-footer-content .e-btn { border-radius: 40px; min-height: 40px; padding: .45rem 1.2rem; font-weight: 700; text-transform: none; }
.e-dialog .e-footer-content .e-btn.e-primary { background: var(--es-gradient); border: 0; color: #fff; }
.e-dialog .e-footer-content .e-btn.e-primary:hover { box-shadow: 0 6px 14px rgba(232, 78, 16, .3); }
.e-dialog .e-footer-content .e-btn:not(.e-primary):not(.btn-danger-text) { background: transparent; border: 2px solid var(--es-orange); color: var(--heading); }
.e-dialog .e-dlg-header { color: var(--heading); font-weight: 700; }
.e-dialog .e-footer-content .e-btn.btn-danger-text { color: var(--danger); background: transparent; border-color: transparent; margin-right: auto; }
.e-dialog .e-footer-content .e-btn.btn-danger-text:hover { background: rgba(200, 16, 46, .08); }

.e-chart text, .e-accumulationchart text { font-family: var(--font) !important; }
.e-grid { font-family: var(--font); }
.e-grid .e-headercell { font-weight: 700; }
.e-slider-container .e-slider .e-handle { background: var(--es-orange) !important; border-color: #fff !important; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.e-slider-container .e-slider .e-range { background: var(--es-orange) !important; }
.e-slider-container .e-scale .e-tick .e-tick-value { font-family: var(--font); font-size: 11px; }
.e-toast-container .e-toast { font-family: var(--font); }
.e-dialog { font-family: var(--font); }

/* ---------- Breakpoints ---------- */

@media (max-width: 1400px) {
    .plan { grid-template-columns: 260px minmax(0, 1fr); grid-template-areas: "ebenen karte" "werte werte"; }
    .plan__werte { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
    .plan__werte .kennzahlen { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; }
    .plan__werte .card + .card { margin-top: 0; }
}

@media (max-width: 1080px) {
    .plan { grid-template-columns: minmax(0, 1fr); grid-template-areas: "karte" "ebenen" "werte"; }
    .plan-unten { grid-template-columns: minmax(0, 1fr); }
    .main-nav a { padding: 0 .6rem; }
    .brand__product { display: none; }
}

@media (max-width: 860px) {
    :root { --header-h: 60px; }
    .main-nav { display: none; }
    .brand__logo { height: 28px; }
    .user-chip__text { display: none; }
    .user-chip { padding: .2rem; }
    .tab-bar {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        background: var(--surface);
        border-top: 1px solid var(--border-soft);
        box-shadow: 0 -2px 10px rgba(0, 51, 102, .08);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .tab-bar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: .15rem;
        padding: .5rem .25rem .45rem;
        font-size: .7rem;
        font-weight: 700;
        color: var(--text-muted);
        text-decoration: none;
        border-top: 3px solid transparent;
    }
    .tab-bar a.active { color: var(--es-orange-text); border-top-color: var(--es-orange); }
    body { padding-bottom: 70px; }
    .page { padding: 1rem .75rem 2rem; }
    .gemeinde-head { grid-template-columns: auto minmax(0, 1fr); padding: .9rem 1rem; }
    .gemeinde-head .badge { white-space: normal; }
    .gemeinde-head .wappen:not(.wappen--klein) { width: 52px; height: 61px; }
    .gemeinde-head__actions { grid-column: 1 / -1; justify-content: flex-start; }
    .gemeinde-head__name { font-size: 1.25rem; }
    .step { height: 54px; padding: 0 .75rem 0 1.6rem; gap: .45rem; }
    .steps li:first-child .step { padding-left: .75rem; }
    .step__sub { display: none; }
    .step__nr { width: 28px; height: 28px; font-size: .85rem; }
    .step__title { font-size: .85rem; }
    .karte { height: 440px; }
    .plan__werte { grid-template-columns: minmax(0, 1fr); }
    .plan__werte .kennzahlen { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .zwei-spalten, .drei-spalten { grid-template-columns: minmax(0, 1fr); }
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth__bild { padding: 1.5rem; }
    .auth__bild h1 { font-size: 1.5rem; }
    .auth__punkte, .auth__bild p.auth__lang { display: none; }
    .regler { grid-template-columns: 1fr auto; }
    .regler__label { grid-column: 1 / -1; }
    .hero { padding: 1.4rem; }
    .hero h1 { font-size: 1.5rem; }
}

@media (max-width: 520px) {
    .step__title { display: none; }
    .step__kurz { display: inline; font-weight: 700; font-size: .8rem; }
    .steps li .step { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%); margin-right: -8px; padding-left: 1.2rem; }
    .steps li:first-child .step { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%); }
    .step__nr { display: none; }
    .kennzahl__wert { font-size: 1.2rem; }
    .gemeinde-head .btn { padding: .5rem .9rem; font-size: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
    .app-header, .tab-bar, .app-footer, .plan__ebenen, .regler, .gemeinde-head__actions, .karte-toolbar .btn { display: none !important; }
    body { background: #fff; padding: 0; }
    .card, .kennzahl, .gemeinde-head { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------- Kartenmarker ---------- */

.karten-marker {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--farbe);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: translate(0, 0);
}

.karten-marker--anmerkung { border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.karten-marker--anmerkung span { transform: rotate(45deg); }
