:root {
    --ha-background: #171717;
    --ha-foreground: #fafafa;
    --ha-panel: #262626;
    --ha-secondary: #404040;
    --ha-muted: #a3a3a3;
    --ha-border: rgba(255, 255, 255, 0.10);
    --ha-ring: #737373;
    --ha-highlight: #ffaa00;
    --ha-danger: #df3f3f;
    --ha-radius-lg: 7px;
    --ha-radius-md: 6px;
    --ha-radius-sm: 4px;
    --ha-font-heading: Montserrat, "Avenir Next", "Segoe UI", sans-serif;
    --ha-font-body: "Noto Sans", "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body,
#react-entry-point,
.app-shell {
    min-height: 100%;
    background: var(--ha-background) !important;
    color: var(--ha-foreground);
    font-family: var(--ha-font-body);
}

body {
    margin: 0;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--ha-font-heading);
}

.main-layout {
    min-height: 100vh;
}

.map-column {
    min-width: 0;
}

.sidebar-column {
    border-right: 1px solid var(--ha-border);
}

.map-container {
    position: relative;
    background: var(--ha-background);
}

.map-loading-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.map-loading-indicator {
    position: relative;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--ha-foreground);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.lighthouse-loader {
    position: relative;
    width: 64px;
    height: 100px;
}

.lighthouse-loader-base,
.lighthouse-loader-active {
    position: absolute;
    left: 0;
    bottom: 0;
    display: block;
    width: 64px;
    height: 100px;
    object-fit: contain;
}

.lighthouse-loader-base {
    opacity: 0.18;
}

.lighthouse-loader-active {
    opacity: 1 !important;
}

.lighthouse-loader-fill {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 0;
    overflow: hidden;
    animation: lighthouse-fill 0.9s ease-out forwards;
}

@keyframes lighthouse-fill {
    0% {
        height: 0;
    }

    100% {
        height: 100%;
    }
}

.geometry-attribution {
    position: absolute;
    z-index: 500;
    right: 8px;
    bottom: 8px;
    padding: 4px 6px;
    border: 1px solid var(--ha-border);
    border-radius: var(--ha-radius-sm);
    background: rgba(23, 23, 23, 0.92);
    color: var(--ha-muted);
    font-size: 10px;
    line-height: 1.2;
}

.geometry-attribution a {
    color: var(--ha-muted);
    text-decoration-color: rgba(255, 170, 0, 0.72);
    text-underline-offset: 0.2em;
}

.geometry-attribution a:hover {
    color: var(--ha-highlight);
}

.sidebar-panel {
    background: var(--ha-panel) !important;
    color: var(--ha-foreground) !important;
    font-family: var(--ha-font-body) !important;
    padding: 16px !important;
    scrollbar-color: var(--ha-secondary) var(--ha-panel);
}

.product-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 0;
}

.product-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    object-fit: contain;
}

.product-heading {
    min-width: 0;
}

.section-label {
    color: var(--ha-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.4;
    text-transform: uppercase;
}

.product-title {
    margin: 0;
    color: var(--ha-foreground);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.15;
}

.section-label {
    margin-bottom: 8px;
}

.dataset-switch-wrapper {
    margin-bottom: 16px;
}

.dataset-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--ha-border);
    border-radius: var(--ha-radius-lg);
    background: var(--ha-background);
    font-size: 13px;
}

.dataset-switch label {
    position: relative;
    display: flex !important;
    align-items: center;
    min-height: 36px;
    margin: 0 !important;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: var(--ha-radius-md);
    color: var(--ha-muted) !important;
    font-weight: 500 !important;
    line-height: 1.3;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.dataset-switch label:has(input:checked) {
    border-color: rgba(255, 170, 0, 0.68);
    background: var(--ha-secondary);
    color: var(--ha-foreground) !important;
}

.dataset-switch label:hover,
.dataset-switch label:active,
.dataset-switch label:focus-within {
    background: rgba(255, 170, 0, 0.14);
    color: var(--ha-foreground) !important;
}

.dataset-switch input {
    appearance: none;
    width: 16px;
    height: 16px;
    margin: 0 8px 0 0 !important;
    flex: 0 0 16px;
    border: 1px solid var(--ha-muted);
    border-radius: 50%;
    background: transparent;
    box-shadow: none !important;
}

.dataset-switch input:checked {
    border-color: var(--ha-highlight);
    background: var(--ha-highlight);
    box-shadow: inset 0 0 0 3px var(--ha-background) !important;
}

.dataset-switch input:hover,
.dataset-switch input:active,
.dataset-switch input:focus {
    border-color: var(--ha-highlight);
    outline: none !important;
    box-shadow: none;
}

.dataset-switch label:focus-within,
.ha-button:focus-visible,
.text-link:focus-visible,
.brand-link:focus-visible,
.heisel-logo-link:focus-visible {
    outline: 3px solid rgba(115, 115, 115, 0.72) !important;
    outline-offset: 2px;
}

.section-divider {
    margin: 16px 0 !important;
    border: 0 !important;
    border-top: 1px solid var(--ha-border) !important;
    opacity: 1;
}

.section-title {
    margin: 0 0 4px;
    color: var(--ha-foreground);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.35;
}

.update-meta,
.source-line,
.disclaimer-copy,
.brand-links {
    color: var(--ha-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.55;
}

.update-meta {
    min-height: 19px;
    margin-bottom: 4px !important;
}

.source-line {
    margin-bottom: 4px;
}

.source-line-last {
    margin-bottom: 12px;
}

.source-line-nowrap {
    white-space: nowrap;
}

.text-link,
.brand-link {
    text-underline-offset: 0.2em;
}

.text-link {
    color: var(--ha-foreground) !important;
    text-decoration-color: rgba(255, 170, 0, 0.72) !important;
}

.text-link:hover {
    color: var(--ha-highlight) !important;
}

.legend-list {
    display: grid;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: var(--ha-radius-md);
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.legend-swatch {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    margin-right: 8px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--ha-radius-sm);
}

.legend-label {
    color: var(--ha-foreground);
    font-size: 13px;
    line-height: 1.4;
}

.action-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 16px;
}

.button-link {
    display: inline-flex;
    color: var(--ha-foreground) !important;
    text-decoration: none;
}

.button-link:visited,
.button-link:hover,
.button-link:active,
.button-link:focus {
    color: var(--ha-foreground) !important;
    text-decoration: none;
}

.ha-button {
    min-height: 32px;
    margin: 0 !important;
    padding: 5px 10px;
    border: 1px solid var(--ha-border) !important;
    border-radius: var(--ha-radius-lg) !important;
    background: var(--ha-secondary) !important;
    color: var(--ha-foreground) !important;
    font-family: var(--ha-font-body);
    font-size: 13px;
    font-weight: 500;
    transition: background-color 180ms ease, border-color 180ms ease;
}

.ha-button:hover,
.ha-button:active,
.ha-button:visited,
.ha-button:focus {
    border-color: transparent !important;
    background: rgba(255, 170, 0, 0.14) !important;
    color: var(--ha-foreground) !important;
}

.meta-title {
    margin: 0 0 4px;
    color: var(--ha-foreground);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.disclaimer-copy {
    margin: 0;
}

.brand-footer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 16px;
    min-height: 40px;
    margin-bottom: 12px;
}

.heisel-logo-link {
    display: flex;
    align-items: stretch;
    height: 40px;
}

.heisel-logo {
    display: block;
    width: auto;
    height: 40px;
    max-width: 138px;
    object-fit: contain;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 40px;
    min-width: 0;
}

.brand-copy .meta-title {
    margin: 0;
    font-size: 15px;
    line-height: 1.2;
    transform: translateY(-4px);
}

.brand-links {
    margin: 0;
    line-height: 1.2;
    transform: translateY(2px);
}

.brand-link {
    color: var(--ha-highlight) !important;
    font-weight: 700;
    text-decoration: none !important;
}

.db-status-banner:empty {
    display: none;
}

.db-status-banner .alert {
    position: fixed;
    z-index: 1100;
    top: 12px;
    left: 50%;
    max-width: calc(100% - 24px);
    margin: 0 !important;
    transform: translateX(-50%);
    border: 1px solid rgba(223, 63, 63, 0.5);
    border-radius: var(--ha-radius-lg);
    background: #2b2020;
    color: var(--ha-foreground);
    font-size: 13px;
}

.leaflet-control-attribution {
    color: #404040;
    font-family: var(--ha-font-body);
    font-size: 10px;
}

.leaflet-tooltip {
    border: 1px solid var(--ha-border);
    border-radius: var(--ha-radius-md);
    background: var(--ha-panel);
    color: var(--ha-foreground);
    box-shadow: none;
    font-family: var(--ha-font-body);
}

@media (min-width: 768px) {
    .map-column {
        flex: 1 1 auto;
        width: auto;
    }

    .sidebar-column {
        flex: 0 0 440px;
        width: 440px;
    }
}

@media (max-width: 767px) {
    #map-container {
        position: fixed !important;
        z-index: 500 !important;
        top: 0 !important;
        right: 0 !important;
        left: 0 !important;
        height: 38vh !important;
        height: 38dvh !important;
    }

    #sidebar-wrapper {
        height: auto !important;
        margin-top: 38vh !important;
        margin-top: 38dvh !important;
        overflow-y: visible !important;
    }

    .sidebar-column {
        border-right: 0;
    }

    .sidebar-panel {
        padding: 16px 12px 12px !important;
    }

    .product-header {
        margin-bottom: 16px;
    }

    .product-title {
        font-size: 22px;
    }

    .dataset-switch label,
    .ha-button {
        min-height: 40px;
    }

    .source-line-nowrap {
        white-space: normal;
    }

    .action-row {
        flex-wrap: wrap;
    }
}

@media (max-width: 420px) {
    .dataset-switch {
        grid-template-columns: 1fr;
    }

    .brand-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }

    .lighthouse-loader-fill {
        height: 100%;
        animation: none;
    }
}
