:root {
    color-scheme: light;
    --page: #f3f3f0;
    --card: #fcfcfb;
    --line: #e1e0d9;
    --axis: #c3c2b7;
    --ink: #0b0b0b;
    --ink2: #52514e;
    --muted: #6f6d68;
    --accent: #2a78d6;
    --soft: #ebeae5;
    /* Status (Ampel) - nur fuer Bewertungen nach Regelwerk, immer mit Symbol und Text */
    --good: #0ca30c;
    --warn: #fab219;
    --crit: #d03b3b;
    /* Datenreihen */
    --series-1: #2a78d6;
    --cat-1: #2a78d6;
    --cat-2: #eb6834;
    --cat-3: #1baf7a;
    --cat-4: #eda100;
    --ord-1: #86b6ef;
    --ord-2: #2a78d6;
    --ord-3: #104281;
    /* Kennzeichnung offener Punkte */
    --tag-open-bg: #fbecc0;
    --tag-open-ink: #5b4300;
    --tag-ass-bg: #d6e6f8;
    --tag-ass-ink: #16405f;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --page: #0d0d0d;
        --card: #1a1a19;
        --line: #2c2c2a;
        --axis: #383835;
        --ink: #ffffff;
        --ink2: #c3c2b7;
        --muted: #9a988f;
        --accent: #3987e5;
        --soft: #262624;
        --series-1: #3987e5;
        --cat-1: #3987e5;
        --cat-2: #d95926;
        --cat-3: #199e70;
        --cat-4: #c98500;
        --ord-1: #184f95;
        --ord-2: #3987e5;
        --ord-3: #9ec5f4;
        --tag-open-bg: #4a3a0c;
        --tag-open-ink: #f6dd93;
        --tag-ass-bg: #173452;
        --tag-ass-ink: #bcd8f5;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d;
    --card: #1a1a19;
    --line: #2c2c2a;
    --axis: #383835;
    --ink: #ffffff;
    --ink2: #c3c2b7;
    --muted: #9a988f;
    --accent: #3987e5;
    --soft: #262624;
    --series-1: #3987e5;
    --cat-1: #3987e5;
    --cat-2: #d95926;
    --cat-3: #199e70;
    --cat-4: #c98500;
    --ord-1: #184f95;
    --ord-2: #3987e5;
    --ord-3: #9ec5f4;
    --tag-open-bg: #4a3a0c;
    --tag-open-ink: #f6dd93;
    --tag-ass-bg: #173452;
    --tag-ass-ink: #bcd8f5;
}

* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font:
        15px/1.45 system-ui,
        -apple-system,
        "Segoe UI",
        sans-serif;
}
.wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* Kopf und Filterzeile */
header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    justify-content: space-between;
    align-items: flex-end;
}
h1 {
    font-size: 22px;
    margin: 0;
}
.asof {
    font-size: 13px;
    color: var(--ink2);
    margin-top: 2px;
}
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
label.f {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--ink2);
}
select,
button {
    font: inherit;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--axis);
    border-radius: 6px;
    padding: 6px 10px;
    min-height: 36px;
}
button {
    cursor: pointer;
}
button:hover {
    background: var(--soft);
}
button.small {
    font-size: 12px;
    min-height: 28px;
    padding: 3px 8px;
}
:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.note {
    background: var(--soft);
    border-left: 4px solid var(--accent);
    padding: 8px 12px;
    margin: 14px 0 6px;
    font-size: 13px;
    color: var(--ink2);
}
.legend-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
    color: var(--ink2);
    margin: 6px 0 0;
}
.scope {
    font-size: 13px;
    color: var(--ink2);
    margin: 10px 0 0;
}

/* Sektionen */
h2 {
    font-size: 16px;
    margin: 26px 0 8px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
h2 small {
    font-weight: 400;
    font-size: 12px;
    color: var(--muted);
}
.grid {
    display: grid;
    gap: 12px;
}
.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cols-top {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}
.span-2 {
    grid-column: span 2;
}
@media (max-width: 980px) {
    .cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 720px) {
    .cols-2,
    .cols-3,
    .cols-top {
        grid-template-columns: minmax(0, 1fr);
    }
    .span-2 {
        grid-column: auto;
    }
}

/* Widget */
.w {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
.w.ext {
    border: 2px dashed var(--axis);
    background: transparent;
}
.wh {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.wh h3 {
    font-size: 14px;
    margin: 0;
}
.kno {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-right: 6px;
}
.wa {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.sub {
    font-size: 12px;
    color: var(--ink2);
    margin: 0;
}
.ch {
    position: relative;
    height: 220px;
}
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.tag {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--tag-open-bg);
    color: var(--tag-open-ink);
    white-space: nowrap;
}
.tag.ass {
    background: var(--tag-ass-bg);
    color: var(--tag-ass-ink);
}
.tag.ext {
    background: transparent;
    border: 1px dashed var(--axis);
    color: var(--ink2);
}

/* Ampel-Symbol: Farbe + Symbol + Text, nie nur Farbe */
.st {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}
.st.G {
    background: var(--good);
    color: #fff;
}
.st.A {
    background: var(--warn);
    color: #0b0b0b;
}
.st.R {
    background: var(--crit);
    color: #fff;
}
.st.big {
    width: 34px;
    height: 34px;
    font-size: 20px;
}

/* Gesamt-Status */
.overall {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th,
td {
    text-align: left;
    padding: 5px 6px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
th {
    font-weight: 600;
    color: var(--ink2);
    font-size: 12px;
}
td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.kpis td:first-child {
    width: 26px;
}
.trend {
    color: var(--ink2);
    white-space: nowrap;
}
.scroll {
    overflow-x: auto;
}
.rule {
    font-size: 12px;
    color: var(--muted);
    margin: 0;
}

/* Karte */
#map {
    width: 100%;
    height: 320px;
    display: block;
    background: var(--soft);
    border-radius: 6px;
}
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 12px;
    color: var(--ink2);
}
.map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Tabellenansicht je Widget */
.tv {
    display: none;
}
.w.show-table .tv {
    display: block;
}
.w.show-table .ch {
    display: none;
}

/* Drill-down */
dialog {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    width: min(820px, calc(100% - 32px));
    padding: 16px;
}
dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}
.dh {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.dh h3 {
    margin: 0;
    font-size: 16px;
}
.hide {
    display: none !important;
}
