:root {
    --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --app-background: #f5f7fb;
    --card-background: #ffffff;
    --card-subtle: #f8f9fb;
    --text-primary: #1f2933;
    --text-muted: #637381;
    --border-color: #e5e8ef;
    --accent: #e3000f;
    --radius-lg: 18px;
    --radius-sm: 12px;
    --shadow-soft: 0 18px 32px -12px rgba(15, 23, 42, 0.28);
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--app-background);
    font-family: var(--font-family);
    color: var(--text-primary);
}

.app-shell {
    min-height: 100vh;
    padding: 32px 40px 48px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: var(--app-background);
}

.card {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
}

.header {
    padding: 28px 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 22px 44px -20px rgba(227, 0, 15, 0.65);
    position: relative;
    overflow: hidden;
}

.header .auth-header {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    gap: 12px;
}

.header .auth-header .username {
    color: #fff;
}

.header .auth-header .logout-link {
    color: #fff;
}

.header .auth-header .logout-link:hover {
    opacity: 0.85;
}

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

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 0 28px;
}

.app-header-title-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.app-title {
    margin: 0 24px 0 0;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text-primary);
    line-height: 1.2;
}

.back-to-landing-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    margin: 4px 0 12px 0;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
}

.back-to-landing-btn:hover {
    background: var(--card-subtle);
    text-decoration: none;
}

.back-arrow {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.spd-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
    margin-left: auto;
    margin-right: 0;
    margin-top: 24px;
}

.app-subtitle {
    margin: 0;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.82);
}

.control-bar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 8px 28px;
}

.rlp-control-bar {
    padding: 0 0 12px 0;
    margin-bottom: 8px;
}

.rlp-control-bar .control-item--inline {
    width: 100%;
}

.rlp-control-bar .control-dropdown {
    min-width: 0;
}

.control-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-item--inline {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.control-item--inline .control-dropdown {
    flex: 1;
    min-width: 300px;
}

.control-item--button {
    max-width: 160px;
}

.control-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
}

.control-label-inline {
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

.control-dropdown .Select-control {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: none !important;
    min-height: 44px;
    background: #ffffff;
}

.control-dropdown .Select-value,
.control-dropdown .Select-placeholder,
.control-dropdown .Select-input {
    font-size: 14px;
    color: var(--text-primary);
}

/* Custom look for the weekly ranking dropdown value. */
.ranking-week-dropdown .Select-control {
    height: 44px;
    border: 2px solid rgba(227, 0, 15, 0.28);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #fff7f8 100%);
}

.ranking-week-dropdown .Select--single > .Select-control .Select-value {
    height: 42px;
    line-height: 42px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--accent);
}

.ranking-week-dropdown .Select--single > .Select-control .Select-value .Select-value-label {
    display: block;
    max-width: 100%;
    padding: 0;
    line-height: 42px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-week-dropdown .Select-placeholder {
    line-height: 42px;
    color: var(--text-muted);
}

.ghost-button {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.0);
    background: rgba(227, 0, 15, 0.1);
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.4px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.ghost-button:hover {
    background: rgba(227, 0, 15, 0.18);
}

.content-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 24px;
}

.map-column,
.insight-column {
    display: flex;
}

.map-column {
    flex-direction: column;
}

.map-card {
    padding: 20px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.interactive-map {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid rgba(227, 0, 15, 0.12);
}

.map-footnote {
    font-size: 13px;
    color: var(--text-muted);
}

.selection-label {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    align-items: center;
}

.selection-label code {
    background: rgba(99, 115, 129, 0.1);
    padding: 3px 6px;
    border-radius: 6px;
}

.insights-card {
    padding: 24px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.panel-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeseries-chart,
.topics-chart {
    height: 260px !important;
}

.summary-card {
    background: var(--card-subtle);
    border-radius: var(--radius-sm);
    padding: 20px 22px;
    border: 1px solid rgba(227, 0, 15, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.section-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.topics-card,
.topic-summary-card {
    padding: 20px 22px 18px;
}

.topic-summary-body {
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--card-subtle);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    border: 1px solid rgba(227, 0, 15, 0.08);
    min-height: 240px;
    max-height: 320px;
    overflow-y: auto;
}

.dash-graph .main-svg {
    border-radius: var(--radius-sm);
}

.dash-loading {
    width: 100%;
}

.dash-loading .dash-loading-spinner {
    transform: scale(0.8);
}

@media (max-width: 1280px) {
    .app-shell {
        padding: 24px;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .control-item--button {
        max-width: none;
    }

    .map-card {
        padding: 16px;
    }
}

/* Metrics Cards Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.metric-label-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.metric-value {
    font-size: clamp(14px, 6cqi, 28px);
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
    min-width: 0;
    white-space: nowrap;
}

/* Auth Header */
.auth-header {
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
}

.landing-auth-header {
    justify-content: space-between;
    padding: 12px 28px;
}

.landing-auth-header .auth-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

.landing-auth-header .auth-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.username {
    font-size: 14px;
    color: var(--text-muted);
}

.logout-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.logout-link:hover {
    text-decoration: underline;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(420px, 1fr);
    gap: 24px;
    padding: 8px 28px;
    transition: grid-template-columns 0.25s ease;
    align-items: start;
}

/* Wider right panel when Freitext-Analyse / Wöchentliches Ranking tab is active. */
.main-content--wide-panel {
    grid-template-columns: 1fr 1fr;
}

/* Question-card answer grid — wraps cleanly regardless of panel width. */
.question-answer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
    gap: 5px;
}

.question-answer-cell {
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #e9ecef);
    min-width: 0;
}

.left-column,
.right-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Map Styling */
.map-wrapper {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-soft);
    height: calc(100vh - 280px);
    min-height: 600px;
}

.map-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

.map-overlay-control {
    position: absolute;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-overlay-control--top-right {
    top: 12px;
    right: 12px;
}

.map-overlay-control .control-label-inline {
    font-size: 13px;
}

.map-overlay-control .control-dropdown {
    min-width: 180px;
}

.map-overlay-control .control-item--inline {
    flex-direction: row;
    gap: 8px;
}

.map-overlay-control .control-item--inline .control-dropdown {
    min-width: 180px;
}

.map-overlay-control .Select--single > .Select-control .Select-value {
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-overlay-control .Select-value-label,
.map-overlay-control .Select-option {
    text-align: center;
}

.map-placeholder,
.map-debug {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.map-info,
.selection-label {
    font-size: 14px;
    color: var(--text-muted);
    margin: 8px 0;
}

/* Panel Title */
.panel-title {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Summary Card */
.summary-card {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.summary-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.summary-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.summary-toggle-btn:hover {
    background: var(--card-subtle);
}

.summary-content {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.summary-card--expanded .summary-content {
    max-height: none;
    overflow-y: visible;
}

/* Topics Section */
.topics-section {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
}

.topics-chart-container {
    background: var(--card-background);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.topic-detail-panel {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 20px;
    border: 1px solid var(--border-color);
    max-height: 320px;
    overflow-y: auto;
}

.topic-detail-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.topic-detail-content {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Back Button */
.back-button {
    padding: 10px 20px;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: var(--card-subtle);
    transform: translateX(-2px);
}

/* Back Button in Map (top-left, so it doesn't overlap the Einfärben dropdown) */
.back-button-map {
    position: absolute;
    top: 12px;
    left: 56px;
    z-index: 1000;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(227, 0, 15, 0.25);
    border-radius: 10px;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.back-button-map:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* WKR Search Dropdown on Map */
.wkr-search-dropdown {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-size: 13px;
}

/* Ranking Mode Toggle */
.ranking-mode-toggle {
    display: flex;
    gap: 16px;
}
.ranking-mode-toggle label {
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

/* Debug Section */
.debug-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
}

.debug-pre {
    background: var(--card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
}

/* Login Page */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 24px;
    padding: 40px;
}

.button {
    padding: 12px 32px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all 0.2s ease;
}

.button:hover {
    background: #c5000d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(227, 0, 15, 0.3);
}

@media (max-width: 1280px) {
    .app-shell {
        padding: 24px;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .control-item--button {
        max-width: none;
    }

    .map-card {
        padding: 16px;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .topics-section {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 768px) {
    .control-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .ghost-button {
        margin-top: 8px;
    }

    .topics-grid {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 18px 16px 32px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 16px;
    }
}

/* Top Section: Metrics + Time Series
   Stacks on narrow right panels, side-by-side on wider ones. */
.top-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

@media (min-width: 1500px) {
    .main-content--wide-panel .top-section {
        grid-template-columns: 320px 1fr;
    }
}

.metrics-column {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.time-series-column {
    background: var(--card-background);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border-color);
}

.time-series-chart {
    height: 200px !important;
}

#mitglieder-visits-csv-section {
    margin-bottom: 4px;
}

.visits-csv-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--text-muted);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s ease;
}

.visits-csv-btn:hover {
    background: var(--text-primary);
}

/* Goal Achievement Section */
.goals-section {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.goals-section .section-title {
    margin: 0 0 16px 0;
}

.goals-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.goal-item {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) minmax(60px, 1.2fr) auto;
    gap: 10px;
    align-items: center;
}

.goal-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.goal-bar-container {
    height: 28px;
    background: rgba(99, 115, 129, 0.1);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

.goal-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, rgba(227, 0, 15, 0.75) 100%);
    border-radius: 14px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.goal-text {
    font-size: clamp(10px, 1.3cqi + 6px, 13px);
    font-weight: 700;
    color: var(--accent);
    text-align: right;
    white-space: nowrap;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Custom Tabs Styling */
.custom-tabs {
    margin-bottom: 8px;
    margin-top: 0px;
}

.custom-tabs .tab {
    background: var(--card-subtle);
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 6px 8px;
    font-weight: 600;
    font-size: clamp(9px, 2cqi + 4px, 14px);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: normal;
    line-height: 1.2;
    min-width: 0;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    text-align: center;
}

.custom-tabs .tab:hover {
    background: var(--card-background);
    color: var(--text-primary);
}

.custom-tab--selected {
    background: var(--card-background) !important;
    color: var(--accent) !important;
    border: 1px solid var(--accent) !important;
}

.tab-content {
    padding: 8px 0;
}

/* Disclaimer banner shown when OV boundaries are displayed */
.disclaimer-banner {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
    max-width: 60%;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.96);
    /* white */
    border: 1px solid rgba(227, 0, 15, 0.25);
    /* SPD red soft border */
    color: #E3000F;
    /* SPD red text */
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    /* allow map interactions through */
}

/* Map container to anchor absolute overlays */
.map-container {
    position: relative;
}

/* Optional soft blur on OV paths if supported by browser */
.ov-fuzzy {
    filter: blur(0.6px);
}

/* Info icon tooltips */
.info-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(99, 115, 129, 0.2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    line-height: 16px;
    cursor: help;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.info-icon:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

/* ============================================================================
   LANDING PAGE & DASHBOARD SELECTION STYLES
   ============================================================================ */

.landing-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-family);
}

.landing-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.landing-welcome-section {
    text-align: center;
    margin-bottom: 48px;
}

.landing-spd-mark {
    height: 72px;
    width: auto;
    margin-bottom: 16px;
}

.landing-welcome {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.landing-instruction {
    font-size: 18px;
    color: var(--text-muted);
    margin: 0;
}

/* Dashboard Cards Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    max-width: 900px;
    width: 100%;
}

.dashboard-card {
    display: block;
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 2px solid transparent;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 48px -16px rgba(227, 0, 15, 0.35);
    border-color: var(--accent);
}

.dashboard-card-content {
    padding: 32px;
    text-align: center;
}

.dashboard-card-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--accent);
}

.dashboard-card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.dashboard-card-description {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.login-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.login-card {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 48px;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 16px 0;
}

.login-instruction {
    font-size: 16px;
    color: var(--text-muted);
    margin: 0 0 32px 0;
}

.login-button {
    display: inline-block;
    padding: 14px 32px;
    background: linear-gradient(120deg, var(--accent), rgba(227, 0, 15, 0.85));
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px -6px rgba(227, 0, 15, 0.5);
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -8px rgba(227, 0, 15, 0.6);
}

/* Error Page Styles */
.error-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.error-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.error-card {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 48px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.error-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 16px 0;
}

.error-message {
    font-size: 16px;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.error-suggestion {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 24px 0;
}

.error-details {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
    background: var(--card-subtle);
    padding: 8px 12px;
    border-radius: 6px;
    margin: 0 0 24px 0;
}

.error-back-link {
    display: inline-block;
    padding: 12px 24px;
    background: var(--card-subtle);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.error-back-link:hover {
    background: var(--accent);
    color: white;
}

/* Header Navigation Link */
.header-nav-link {
    color: white;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.2s ease;
}

.header-nav-link:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Header Styles for Landing/Login Pages */
.header-title-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin: 0;
}

.header-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.header-logo {
    height: 48px;
    width: auto;
}

/* RLP Dashboard Specific Styles */
.rlp-dashboard .right-panel {
    padding: 24px;
}

.region-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.region-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.goals-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metrics-container {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* Responsive adjustments for landing page */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .landing-welcome {
        font-size: 24px;
    }

    .landing-instruction {
        font-size: 16px;
    }

    .dashboard-card-content {
        padding: 24px;
    }

    .login-card,
    .error-card {
        padding: 32px 24px;
    }
}

/* ===========================================
   RLP Dashboard Specific Styles
   =========================================== */

/* TzT Besuche Content Container */
.tzt-besuche-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Large KPI Card */
.metric-card-large {
    background: linear-gradient(135deg, rgba(227, 0, 15, 0.03) 0%, rgba(227, 0, 15, 0.08) 100%);
    border-radius: var(--radius-lg);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(227, 0, 15, 0.15);
    text-align: center;
    container-type: inline-size;
    min-width: 0;
}

/* Allow flex children inside KPI cards to shrink below their content size. */
.metric-card-large > * > * {
    min-width: 0;
}

.metric-card-large:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(227, 0, 15, 0.12);
}

.metric-label-large {
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.metric-value-large {
    font-size: clamp(28px, 13cqi, 56px);
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    min-width: 0;
    white-space: nowrap;
}

/* Metrics Row (two cards side by side) */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.metrics-row .metric-card {
    text-align: center;
    padding: 24px 16px;
}

.metrics-row .metric-value {
    font-size: 32px;
}

/* Small KPI Card */
.metric-card-small {
    padding: 12px 16px;
    background: var(--card-subtle);
    text-align: center;
}

.metric-label-small {
    font-size: 11px;
}

.metric-value-small {
    font-size: 20px;
    color: var(--text-primary);
}

/* Ranking Section */
.ranking-section {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.ranking-section .section-title {
    margin: 0 0 16px 0;
    text-align: center;
}

.ranking-chart {
    min-height: 200px;
    height: auto;
}

/* RLP Dashboard Left Column — fixed viewport height so the map never
   shrinks when the right column (e.g. Mobi Planer) has less content. */
.rlp-dashboard .left-column {
    height: calc(100vh - 200px);
    min-height: 600px;
    align-self: start;
}

/* Mitglieder dashboard has an extra control-bar row, so we subtract more. */
.mitglieder-dashboard .left-column {
    height: calc(100vh - 260px);
    min-height: 600px;
    align-self: start;
}

/* Dashboard right column: keep the panel viewport-bound and scroll internally. */
.main-content > .right-column {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    height: calc(100vh - 200px);
    min-height: 600px;
    overflow-y: auto;
    min-width: 0;
    align-self: start;
    container-type: inline-size;
}

/* RLP Panel Title */
.rlp-dashboard .panel-title {
    text-align: center;
    color: var(--accent);
    margin-bottom: 24px;
    font-size: clamp(14px, 6cqi, 28px);
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
}

/* Hide ranking section for restricted users */
.ranking-section[style*="display: none"] {
    display: none !important;
}

/* Responsive for RLP */
@media (max-width: 1280px) {
    .metric-value-large {
        font-size: 42px;
    }

    .metrics-row .metric-value {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .metrics-row {
        grid-template-columns: 1fr;
    }

    .metric-value-large {
        font-size: 36px;
    }

    .metric-card-large {
        padding: 24px 16px;
    }
}

/* ===========================================
   REDESIGNED LANDING PAGE STYLES
   =========================================== */

.landing-page-redesigned {
    min-height: 100vh;
    background: var(--app-background);
}

/* Hero Section */
.landing-hero {
    background: linear-gradient(135deg, rgba(227, 0, 15, 0.04) 0%, rgba(227, 0, 15, 0.10) 100%);
    border-radius: var(--radius-lg);
    padding: 40px;
    margin: 0 auto 24px;
    width: 100%;
    max-width: 1160px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    border: 1px solid rgba(227, 0, 15, 0.12);
    position: relative;
    overflow: hidden;
}

.landing-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(227, 0, 15, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.landing-hero-text {
    position: relative;
    z-index: 1;
    flex: 1;
    text-align: left;
}

.landing-hero-logo {
    position: relative;
    z-index: 1;
    width: min(220px, 28vw);
    min-width: 150px;
    height: auto;
    flex-shrink: 0;
}

.landing-hero-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    line-height: 1.2;
}

.landing-hero-subtitle {
    font-size: 18px;
    color: var(--text-muted);
    margin: 0;
    font-weight: 400;
}

/* Enhanced Content Area */
.landing-content-enhanced {
    padding: 0 0 32px;
}

/* Enhanced Dashboard Grid */
.landing-dashboard-grid {
    margin: 0 auto;
    max-width: 1160px;
    width: 100%;
}

.landing-dashboard-grid .dashboard-card {
    background: linear-gradient(145deg, var(--card-background) 0%, rgba(255, 255, 255, 0.95) 100%);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.landing-dashboard-grid .dashboard-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 28px 56px -20px rgba(227, 0, 15, 0.30);
    border-color: var(--accent);
}

.landing-dashboard-grid .dashboard-card-content {
    padding: 40px 32px;
}

.landing-dashboard-grid .dashboard-card-icon {
    font-size: 56px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(227, 0, 15, 0.75) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing-dashboard-grid .dashboard-card-title {
    font-size: 22px;
    margin-bottom: 14px;
}

.landing-dashboard-grid .dashboard-card-description {
    font-size: 15px;
    line-height: 1.6;
}

/* Responsive for redesigned landing */
@media (max-width: 768px) {
    .landing-hero {
        margin: 0 auto 24px;
        padding: 32px 24px;
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .landing-hero-logo {
        width: min(180px, 55vw);
        min-width: 0;
    }

    .landing-hero-text {
        text-align: left;
    }

    .landing-hero-title {
        font-size: 28px;
    }

    .landing-hero-subtitle {
        font-size: 16px;
    }

    .landing-dashboard-grid {
        margin: 0 auto;
    }

    .landing-dashboard-grid .dashboard-card-content {
        padding: 28px 24px;
    }
}

/* =====================================================================
   MOBI PLANER — Berlin AH 2026
   ===================================================================== */

/* Mode toggle button */
.mode-toggle-container {
    flex-shrink: 0;
}

.mode-toggle-btn {
    padding: 8px 18px;
    border-radius: 20px;
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.mode-toggle-btn:hover {
    background: rgba(227, 0, 15, 0.08);
}

.mode-toggle-btn.active {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(227, 0, 15, 0.3);
}

/* Mobi Planer legend */
.mobi-legend {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 1px solid var(--border-color);
}

/* Mobi Planer WQ summary table */
.mobi-wq-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.mobi-wq-table th {
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    background: #ffffff;
}

.mobi-wq-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
}

.mobi-wq-table tr:hover td {
    background: rgba(227, 0, 15, 0.04);
}

.mobi-wq-table tr.mobi-wq-selected td {
    background: rgba(227, 0, 15, 0.10);
    font-weight: 600;
}

/* Mob class color dots */
.mob-class-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
}

.mob-class-dot--3 { background: #43A047; }
.mob-class-dot--2 { background: #FDD835; }
.mob-class-dot--1 { background: #E53935; }
.mob-class-dot--0 { background: #9e9e9e; }

/* Tür-Klasse badge */
.tuer-klasse-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    min-width: 18px;
    text-align: center;
}

.tuer-klasse-badge--0 { background: #bdbdbd; color: #424242; }
.tuer-klasse-badge--1 { background: #FDD835; color: #424242; }
.tuer-klasse-badge--2 { background: #FB8C00; }
.tuer-klasse-badge--3 { background: #E53935; }
.tuer-klasse-badge--4 { background: #43A047; }

/* Mobi Planer socio-demo card */
.mobi-sd-card {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.mobi-sd-card .sd-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}

.mobi-sd-card .sd-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.mobi-sd-card .sd-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.mobi-sd-card .sd-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Mobi Planer visit summary */
.mobi-visit-summary {
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.mobi-visit-summary .visit-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.mobi-visit-summary .visit-stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.mobi-visit-summary .visit-stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
}

/* KGS36 legend */
.kgs36-legend {
    display: flex;
    gap: 16px;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-muted);
}

.kgs36-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.kgs36-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.kgs36-legend-dot--visited { background: #43A047; }
.kgs36-legend-dot--not-visited { background: #9e9e9e; }

/* Leaflet tooltip transparency */
.leaflet-tooltip {
    background-color: rgba(255, 255, 255, 0.8) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1) !important;
}
.leaflet-tooltip::before {
    border-top-color: rgba(255, 255, 255, 0.8) !important;
}


/* Fix for Leaflet Custom Panes Z-Index and interactions */
.leaflet-ber-wkr-pane-pane {
    z-index: 400 !important;
}

.leaflet-ber-wq-pane-pane {
    z-index: 410 !important;
}

.leaflet-ber-kgs36-pane-pane {
    z-index: 500 !important;
    pointer-events: none !important; /* Let events fall through the pane container */
}

.leaflet-ber-kgs36-pane-pane svg path {
    pointer-events: auto !important; /* But keep the markers themselves interactive */
}

/* Ensure selected WQ polygons do not intercept pointer events */
.wq-selected-poly {
    pointer-events: none !important;
}
