a, .btn-link {
    color: var(--accent-primary);
}

.btn-primary {
    color: var(--text-bright);
    background-color: var(--accent-primary);
    border-color: var(--accent-primary-strong);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--text-bright), 0 0 0 0.25rem var(--accent-primary-strong);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}

.invalid {
    outline: 1px solid var(--danger);
}

.validation-message {
    color: var(--danger);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

#app-loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    background: var(--bg-primary);
}

.app-loading-spinner {
    width: 48px;
    height: 48px;
    margin: 16px auto 0;
    border: 4px solid transparent;
    border-top-color: var(--loading-progress);
    border-radius: 50%;
    animation: app-loading-spin 0.8s linear infinite;
}

@keyframes app-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.marker-stale {
    opacity: 0.35 !important;
    filter: grayscale(80%);
    transition: opacity 0.5s ease, filter 0.5s ease;
}

/* GeoJSON marker hover label — match style of DOM reader labels */
.marker-hover-label .maplibregl-popup-content {
    background: var(--bg-panel);
    color: var(--text-bright);
    font-size: 11px;
    font-family: Arial, sans-serif;
    padding: 2px 6px;
    border-radius: 3px;
    box-shadow: var(--shadow-soft);
    border: none;
}

.marker-hover-label .maplibregl-popup-tip {
    border-right-color: var(--bg-panel);
}


.appbar-left {
    display: flex;
    flex: 0 1 calc(var(--mud-drawer-width-left, 240px) - 24px);
    min-width: 0;
}

.appbar-logo-slot {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    min-width: 0;
    margin: 0 1em;
    transform: translateX(-6px);
}

.appbar-logo {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    max-height: 32px;
    margin: 0;
    object-fit: contain;
}

.appbar-brand-text {
    flex: 0 1 auto;
    min-width: 0;
    padding: 0;
}

.language-select--mobile {
    display: none;
}

.login-logo {
    display: block;
    width: 180px;
    max-width: 100%;
    height: auto;
    margin: 0 auto 1rem;
}

.login-form input:-webkit-autofill,
.login-form input:-webkit-autofill:hover,
.login-form input:-webkit-autofill:focus,
.login-form input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--mud-palette-text-primary);
    caret-color: var(--mud-palette-text-primary);
    box-shadow: 0 0 0 1000px var(--mud-palette-surface) inset;
}

/* Keep MudBlazor controls readable across all configured brand palettes. */
.mud-input-control:not(.mud-input-error):hover .mud-input-outlined-border {
    border-color: var(--mud-palette-primary);
}

.mud-input-control:not(.mud-input-error):hover .mud-input-underline::before,
.mud-input-control:not(.mud-input-error):hover .mud-input-underline::after {
    border-bottom-color: var(--mud-palette-primary);
}

.mud-button-root:disabled,
.mud-button-root.mud-disabled,
.mud-icon-button:disabled,
.mud-icon-button.mud-disabled {
    color: var(--mud-palette-action-disabled) !important;
    background-color: var(--mud-palette-action-disabled-background);
    opacity: 1;
}

.mud-disabled .mud-input-slot,
.mud-disabled .mud-input-label,
.mud-disabled .mud-input-adornment,
.mud-disabled .mud-icon-root,
.mud-disabled .mud-typography,
.mud-disabled .mud-checkbox-icon,
.mud-disabled .mud-radio-icons,
.mud-disabled .mud-switch-track {
    color: var(--mud-palette-text-disabled) !important;
}

.mud-input-control.mud-disabled .mud-input-outlined-border {
    border-color: var(--mud-palette-action-disabled) !important;
}

.mud-data-grid .mud-icon-button:not(:disabled),
.mud-data-grid .mud-button-root:not(:disabled) {
    color: var(--mud-palette-action-default);
}

.mud-data-grid .mud-icon-button:not(:disabled):hover,
.mud-data-grid .mud-button-root:not(:disabled):hover {
    background-color: var(--mud-palette-action-default-hover);
}

.mud-data-grid .mud-table-head th,
.mud-data-grid .mud-table-row td {
    border-color: var(--mud-palette-table-lines);
}

.mud-data-grid .mud-table-row:hover {
    background-color: var(--mud-palette-table-hover) !important;
}

.maplibregl-popup {
    font-family: Arial, sans-serif;
}

.maplibregl-popup-content {
    padding: 30px 15px 10px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.popup-data-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 4px 10px;
    margin: 0;
    padding: 0;
}

.popup-data-grid .label {
    color: var(--mud-palette-text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: normal;
}

.popup-data-grid .value {
    color: var(--mud-palette-text-primary);
    text-align: right;
    white-space: nowrap;
}

.popup-data-grid .value.highlight {
    font-weight: bold;
}

.maplibregl-popup-close-button {
    width: auto;
    height: auto;
    padding: 4px 6px;
    top: 1px;
    right: 1px;
    font-size: 20px;
    line-height: 20px;
    color: var(--mud-palette-text-primary) !important;
}

.maplibregl-popup-close-button:hover {
    color: var(--mud-palette-primary) !important;
    background-color: var(--mud-palette-action-default-hover) !important;
}

/* Map filters intentionally stay light for map readability, including dark brands. */
.map-filter-popup {
    max-height: 80vh;
    width: 340px;
    overflow-y: auto;
    background: #ffffff !important;
    color: #1f2937 !important;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    padding: 12px;
    --mud-palette-primary: #475569;
    --mud-palette-primary-hover: rgba(71, 85, 105, 0.12);
    --mud-palette-secondary: #64748b;
    --mud-palette-secondary-hover: rgba(100, 116, 139, 0.12);
    --mud-palette-background: #ffffff;
    --mud-palette-background-gray: #f8fafc;
    --mud-palette-surface: #ffffff;
    --mud-palette-text-primary: #1f2937;
    --mud-palette-text-secondary: #475569;
    --mud-palette-action-default: #475569;
    --mud-palette-action-default-hover: rgba(71, 85, 105, 0.08);
    --mud-palette-lines-default: #e2e8f0;
    --mud-palette-lines-inputs: #94a3b8;
}

.map-filter-popup .popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.map-filter-popup .filters-popup-content {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.map-filter-popup .filters-popup-content .mud-expand-panel {
    box-shadow: none !important;
    margin-bottom: 2px;
}

.map-filter-popup .filters-popup-content .mud-expand-panel-header {
    min-height: 40px !important;
    padding: 0 8px !important;
    background: #f8fafc;
    color: #1f2937 !important;
}

.map-filter-popup .filters-popup-content .mud-expand-panel-header .mud-typography,
.map-filter-popup .filters-popup-content .mud-expand-panel-header .mud-icon-root {
    color: #1f2937 !important;
}

.map-filter-popup .filters-popup-content .mud-expand-panel-content {
    padding: 2px 8px 8px !important;
    background: #ffffff;
    color: #1f2937;
}

.map-filter-popup .filters-popup-content .mud-expand-panel-content .mud-typography-body1,
.map-filter-popup .popup-header .mud-typography {
    color: #1f2937;
}

.analysis-map-layout {
    display: flex;
    gap: 16px;
    height: calc(100vh - 150px);
    position: relative;
}

.analysis-map-layout__map {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.analysis-map-layout__map .map-wrapper {
    width: 100%;
    height: 100%;
}

.analysis-map-layout__map .map-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.analysis-map-layout__panel {
    flex: 0 0 400px;
    width: 400px;
    min-height: 0;
    box-sizing: border-box;
    padding: 20px;
    overflow-y: auto;
    scrollbar-width: none;
    background: var(--bg-panel);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.analysis-map-layout__panel-header {
    display: none;
}

.analysis-map-layout__toggle {
    display: none !important;
}

.analysis-map-layout__section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.analysis-map-layout__section:last-child {
    border-bottom: none;
}

@media (max-width: 768px) {
    .analysis-map-layout {
        display: block;
        height: calc(100dvh - 150px);
        min-height: 300px;
    }

    .analysis-map-layout__map,
    .analysis-map-layout__map .map-wrapper,
    .analysis-map-layout__map .map-container {
        height: 100%;
    }

    .analysis-map-layout__panel {
        display: none;
        position: absolute;
        inset: 0;
        z-index: 4;
        width: auto;
        padding: 16px;
        border-radius: 8px;
    }

    .analysis-map-layout--panel-open .analysis-map-layout__panel {
        display: block;
    }

    .analysis-map-layout__panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
    }

    .analysis-map-layout__toggle {
        display: inline-flex !important;
        position: absolute !important;
        top: 12px;
        right: 12px;
        z-index: 5;
    }

    .analysis-map-layout--panel-open .analysis-map-layout__toggle {
        display: none !important;
    }

    .main-appbar .appbar-left {
        flex: 0 0 auto;
    }

    .main-appbar .appbar-brand-text .mud-typography-caption {
        display: none;
    }

    .main-appbar .appbar-brand-text {
        flex: 1 1 auto;
        min-width: 0;
    }

    .main-appbar .appbar-brand-text .mud-typography-h6 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .main-appbar .language-select--desktop {
        display: none;
    }

    .main-appbar .language-select--mobile {
        display: inline-flex;
    }

    .location-events-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .location-events-actions .mud-button-root {
        width: 100%;
        white-space: normal;
    }

    .mud-dialog {
        width: calc(100vw - 32px) !important;
        max-width: calc(100vw - 32px) !important;
        max-height: calc(100dvh - 32px);
        margin: 16px;
    }

    .mud-dialog .mud-dialog-content {
        padding: 16px;
    }
}

.location-events-actions {
    display: flex;
    gap: 8px;
}
