/* Gemeinsames Erscheinungsbild der vier Arbeitsbereiche. */
:root {
    --dashboard-bg: #f6f7f9;
    --dashboard-surface: #ffffff;
    --dashboard-border: #d8dee5;
    --dashboard-text: #253746;
    --dashboard-muted: #607080;
    --dashboard-accent: #4a6da7;
}

.site-footer {
    position: fixed;
    right: 16px;
    bottom: 10px;
    z-index: 1100;
    padding: 5px 10px;
    border: 1px solid var(--dashboard-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    color: var(--dashboard-muted);
    font-size: 0.78rem;
}

.site-footer a,
.legal-back-link {
    color: var(--dashboard-accent);
    text-decoration: none;
}

.site-footer a:hover,
.legal-back-link:hover {
    text-decoration: underline;
}

.legal-page {
    min-height: calc(100vh - 48px);
    padding: 48px 20px 72px;
    color: var(--dashboard-text);
}

.legal-page-inner {
    max-width: 760px;
    margin: 0 auto;
    line-height: 1.6;
}

.legal-page h1 {
    margin: 18px 0 24px;
    font-size: 2rem;
}

.legal-page h2 {
    margin: 26px 0 8px;
    font-size: 1.2rem;
}

.legal-page p,
.legal-page ul {
    margin: 0 0 14px;
}

@media (max-width: 767px) {
    .site-footer { right: 8px; bottom: 8px; }
    .legal-page { padding: 32px 16px 68px; }
}

.tab-parent {
    border-bottom: 1px solid var(--dashboard-border);
    background: var(--dashboard-surface);
}

.tab {
    color: var(--dashboard-muted);
    font-weight: 600;
    padding: 11px 18px;
}

.tab--selected {
    color: var(--dashboard-text) !important;
    border-top: 3px solid var(--dashboard-accent) !important;
    background: var(--dashboard-surface) !important;
}

/* Standard Layout für größere Bildschirme */
@media (min-width: 768px) {
    #map {
        width: 100%;
        height: 100%;
    }

    /* Tab 1: Karte & Info nebeneinander */
    #map-container {
        flex: 0 0 66%;
        width: 66%;
        float: left;
    }

    .right-container {
        flex: 1 1 34%;
        width: 34%;
        float: right;
        padding: 10px;
    }

    .toggle-buttons {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* Tab 3 has its own grid so Tab 1's float/width rules cannot affect it. */
.tab3-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.tab2-layout,
.tab3-page,
.tab4-layout {
    background: var(--dashboard-bg);
}

.tab2-layout > div {
    background: var(--dashboard-surface);
}

.tab3-page {
    padding: 16px;
}

.tab3-layout {
    gap: 16px;
}

.tab3-layout > .map-pane,
.tab3-layout > .tab3-right-container {
    border: 1px solid var(--dashboard-border);
    border-radius: 10px;
    background: var(--dashboard-surface);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.tab3-layout > .tab3-right-container {
    overflow-y: auto;
}

#middle-container {
    background: var(--dashboard-surface);
    border-left: 1px solid var(--dashboard-border);
}

.tab-section-title {
    margin: 0 0 12px;
    color: var(--dashboard-text);
    font-size: 1.2rem;
    font-weight: 700;
}

.tab3-intro {
    margin: -5px 0 16px;
    color: var(--dashboard-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.tab3-layout > .map-pane,
.tab3-layout > .tab3-right-container {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Tab 4: Vergleich */
.tab4-layout {
    --tab4-comparison-columns: minmax(0, 1fr) minmax(210px, 0.55fr) minmax(0, 1fr);
    height: calc(100vh - 48px);
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    padding: 18px;
    background: #f6f7f9;
}

.tab4-header {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.tab4-independent-selectors {
    display: grid;
    grid-template-columns: var(--tab4-comparison-columns);
    gap: 16px;
    margin-bottom: 14px;
}

.tab4-selector-bridge {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    gap: 9px;
    color: #607080;
}

.tab4-bridge-link {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab4-selector-bridge span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #6687a6;
    color: white;
    font-size: 0.78rem;
    font-weight: 700;
}

.tab4-selector-bridge span:nth-of-type(2) {
    background: #a76767;
}

.tab4-selector-bridge strong {
    font-size: 1.3rem;
}

.tab4-bridge-metric {
    flex: 0 0 auto;
}

.tab4-bridge-metric .btn {
    min-width: 38px;
}

.tab4-selection-panel {
    min-width: 0;
    padding: 14px;
    border: 1px solid #d8dee5;
    border-top: 4px solid #6687a6;
    border-radius: 10px;
    background: white;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.04);
}

.tab4-selection-panel-b {
    border-top-color: #a76767;
}

.tab4-selection-panel h4 {
    margin: 0 0 10px;
    font-size: 1.05rem;
}

.tab4-selection-panel > label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.82rem;
    font-weight: 700;
}

.tab4-selection-label {
    margin-top: 11px;
}

.tab4-single-site-hint {
    align-items: flex-start;
    margin-top: 11px;
    padding: 8px;
    border-radius: 7px;
    background: #f2f6fa;
}

.tab4-button-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.tab4-button-filters label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.tab4-button-group {
    display: flex;
    width: 100%;
}

.tab4-button-group .btn {
    flex: 1 1 0;
    white-space: normal;
}

.tab4-button-group .tab4-option-unavailable:not(.active) {
    color: #7a7f85;
    background: #e2e5e8;
    border-color: #c9cdd1;
    border-style: dashed;
    cursor: pointer;
    opacity: 0.72;
}

.tab4-button-group .tab4-option-unavailable:not(.active):hover {
    color: #495057;
    background: #d6dade;
    opacity: 1;
}

.tab4-filter {
    min-width: 0;
}

.tab4-filter label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.tab4-qualification-hint {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin: -3px 0 12px;
    padding: 9px 12px;
    border: 1px solid #cfe2ff;
    border-radius: 8px;
    background: #eef6ff;
}

.tab4-qualification-title {
    display: flex;
    flex-direction: column;
    color: #415a77;
    font-size: 0.82rem;
    font-weight: 700;
}

.tab4-qualification-title span {
    color: #60758a;
    font-size: 0.72rem;
    font-weight: 400;
}

.tab4-qualification-item {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.tab4-qualification-item > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: 0.78rem;
    line-height: 1.25;
}

.tab4-qualification-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab4-qualification-item span:not(.tab4-qualification-letter) {
    color: #52606d;
}

.tab4-qualification-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 50%;
    background: #0d6efd;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

.tab4-pies {
    display: grid;
    grid-template-columns: var(--tab4-comparison-columns);
    gap: 16px;
}

.tab4-diagram-card-a,
.tab4-diagram-card-b {
    border-top: 4px solid #6687a6;
}

.tab4-diagram-card-b {
    border-top-color: #a76767;
}

.tab4-focus-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    background: linear-gradient(180deg, #fff, #f7f9fc);
}

.tab4-focus-placeholder {
    padding: 20px;
    color: #6c757d;
    text-align: center;
}

.tab4-focus-placeholder-title {
    margin-bottom: 8px;
    color: #34495e;
    font-size: 1.05rem;
    font-weight: 700;
}

.tab4-focus-placeholder-text,
.tab4-focus-hint {
    font-size: 0.78rem;
    line-height: 1.35;
}

.tab4-focus-content {
    width: 100%;
    padding: 12px;
    text-align: center;
}

.tab4-focus-swatch {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
}

.tab4-focus-parent {
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.tab4-focus-content h4 {
    margin: 7px 0 16px;
    font-size: 1rem;
    line-height: 1.25;
}

.tab4-focus-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.tab4-focus-values > div,
.tab4-focus-delta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 7px;
    background: white;
}

.tab4-focus-values span,
.tab4-focus-delta span {
    color: #6c757d;
    font-size: 0.7rem;
}

.tab4-focus-delta {
    margin: 9px 0 12px;
}

.tab4-metric-bar {
    display: grid;
    grid-template-columns: var(--tab4-comparison-columns);
    gap: 16px;
    margin: 0 0 10px;
}

.tab4-metric-control {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 7px;
    border: 1px solid #dbe1e7;
    border-radius: 8px;
    background: white;
}

.tab4-metric-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #495057;
}

.tab4-cross-school-warning {
    margin: 0 0 12px;
    border-left: 5px solid #e0a800;
}

.tab4-metric-switch .form-check {
    margin: 0;
    padding: 0;
}

.tab4-card {
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: white;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tab4-card .dash-graph {
    height: 360px;
    max-height: 360px;
    overflow: hidden;
}

.tab4-total {
    min-height: 24px;
    text-align: center;
    font-weight: 600;
    color: #34495e;
}

.tab4-difference {
    margin-top: 16px;
}

.tab4-difference .dash-graph {
    height: auto;
    max-height: none;
}

.tab4-table-wrap {
    overflow-x: auto;
}

.tab4-table-wrap h4 {
    margin: 4px 0 12px;
}

.tab4-table-key {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-bottom: 14px;
    padding: 9px 12px;
    border-radius: 7px;
    background: #eef2f6;
    color: #495057;
    font-size: 0.9rem;
}

.tab4-table-key > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab4-legend-solid,
.tab4-legend-striped {
    display: inline-block;
    width: 24px;
    height: 9px;
    border: 1px solid #667;
    border-radius: 3px;
    background: #6687a6;
}

.tab4-legend-striped {
    background: repeating-linear-gradient(135deg, #6687a6 0, #6687a6 4px, #fff 4px, #fff 7px);
}

.tab4-category-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.tab4-category-section {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
}

.tab4-category-section h5 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    font-size: 1rem;
    font-weight: 700;
}

.tab4-visual-item {
    padding: 9px 10px 10px;
    border-bottom: 1px solid #e8eaed;
}

.tab4-visual-item:last-child {
    border-bottom: 0;
}

.tab4-visual-item:hover {
    background: #f7faff;
}

.tab4-visual-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.tab4-visual-name {
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
}

.tab4-visual-difference {
    flex: 0 0 auto;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.tab4-bar-line {
    display: grid;
    grid-template-columns: 16px minmax(40px, 1fr) 70px;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.tab4-bar-label {
    color: #495057;
    font-size: 0.75rem;
    font-weight: 700;
}

.tab4-bar-track {
    height: 10px;
    overflow: hidden;
    border: 1px solid #ccd1d6;
    border-radius: 5px;
    background: #edf0f2;
}

.tab4-bar-track > div {
    height: 100%;
    min-width: 0;
}

.tab4-bar-track-b > div {
    background: repeating-linear-gradient(135deg, var(--bar-color) 0, var(--bar-color) 4px, #fff 4px, #fff 7px);
}

.tab4-bar-value {
    font-size: 0.75rem;
    text-align: right;
    white-space: nowrap;
}

.tab4-difference-positive {
    color: #157347;
    background: #d1e7dd;
    font-weight: 700;
}

.tab4-difference-negative {
    color: #b02a37;
    background: #f8d7da;
    font-weight: 700;
}

.tab4-difference-equal {
    color: #6c757d;
    background: #e9ecef;
}

/* Layout für mobile Geräte: Spalten untereinander stapeln */
@media (max-width: 767px) {
    #map-container,
    .map-pane {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        float: none !important;
        height: 50vh !important;
    }

    #map {
        width: 100% !important;
        height: 100% !important;
    }

    .right-container {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        float: none !important;
        height: auto !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
        padding: 10px !important;
    }

    .tab3-layout {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 50vh minmax(0, auto);
        overflow-y: auto !important;
    }

    .tab3-layout > .tab3-right-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
        padding: 10px !important;
    }

    .tab4-layout {
        height: calc(100vh - 48px);
        padding: 10px;
    }

    .tab4-header,
    .tab4-button-filters,
    .tab4-pies,
    .tab4-independent-selectors {
        grid-template-columns: minmax(0, 1fr);
    }

    .tab4-independent-selectors {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .tab4-independent-selectors > * {
        width: 100%;
        min-width: 0;
    }

    .tab4-selector-bridge {
        min-height: 58px;
        order: 2;
    }

    .tab4-selection-panel-b {
        order: 3;
    }

    .tab4-metric-bar {
        grid-template-columns: minmax(0, 1fr);
    }

    .tab4-metric-control {
        grid-column: 1;
    }

    .tab4-category-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .tab4-focus-card {
        min-height: 220px;
    }

    .toggle-buttons {
        display: block; /* Buttons untereinander */
        margin-top: 10px;
    }

    .pie-chart-container {
        display: block; /* Diagramm unter dem Text */
    }

    .legend-container {
        display: block; /* Legende wird unterhalb angezeigt */
    }

    /* Schalter und Labels vertikal */
    .switch-container {
        display: block;
    }
}
