/* Layer panel: reduced, flat list styling */
.leaflet-control-layers {
    width: min(380px, calc(100vw - 24px));
    min-width: 280px;
    max-width: 380px;
    max-height: min(78vh, calc(100vh - var(--nav-height, 0px) - 28px));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0 !important;
    border-radius: 22px;
    border: 1px solid rgba(15,23,42,0.08);
    background: rgba(255,255,255,0.96) !important;
    box-shadow: 0 18px 42px rgba(15,23,42,0.16), 0 6px 14px rgba(15,23,42,0.08);
    backdrop-filter: blur(18px);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    color: #0f172a;
}

.leaflet-left .leaflet-control.leaflet-control-layers {
    margin-left: 8px !important;
}

.leaflet-control-layers-expanded {
    padding: 0 !important;
}

.leaflet-control-layers:not(.leaflet-control-layers-expanded) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-height: none !important;
    backdrop-filter: none;
    min-width: 0;
    width: auto;
    max-width: none;
    align-items: flex-start;
}

.leaflet-control-layers:not(.leaflet-control-layers-expanded) form,
.leaflet-control-layers:not(.leaflet-control-layers-expanded) .layers-panel-header,
.leaflet-control-layers:not(.leaflet-control-layers-expanded) .layers-panel-toolbar,
.leaflet-control-layers:not(.leaflet-control-layers-expanded) .layers-panel-tabs,
.leaflet-control-layers:not(.leaflet-control-layers-expanded) .layers-operator-view {
    display: none !important;
}

.leaflet-control-layers .leaflet-control-layers-toggle {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(15,23,42,0.08);
    background: #ffffff url('../images/BxBxsLayer.svg') center center / 22px 22px no-repeat !important;
    box-shadow: 0 8px 18px rgba(15,23,42,0.14);
    display: inline-block;
    cursor: pointer;
    margin: 0 !important;
}

.leaflet-control-layers .leaflet-control-layers-toggle:hover {
    box-shadow: 0 12px 24px rgba(15,23,42,0.18);
}

.leaflet-control-layers.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
    display: none !important;
}

.leaflet-control-layers form {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
}

.leaflet-control-layers form[hidden] {
    display: none !important;
}

.leaflet-control-layers.layers-panel-mode-operators form,
.leaflet-control-layers.layers-panel-mode-operators .leaflet-control-layers-list,
.leaflet-control-layers.layers-panel-mode-operators .leaflet-control-layers-base,
.leaflet-control-layers.layers-panel-mode-operators .leaflet-control-layers-overlays {
    display: none !important;
}

.leaflet-control-layers.layers-panel-mode-sparten .layers-operator-view,
.layers-operator-view[hidden] {
    display: none !important;
}

.leaflet-control-layers.layers-panel-mode-operators .layers-operator-view {
    display: flex !important;
}

.layers-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 12px;
    padding: 24px 24px 18px;
    background:
        linear-gradient(180deg, rgba(248,250,252,0.98) 0%, rgba(255,255,255,0.96) 100%);
    border-bottom: 1px solid rgba(15,23,42,0.06);
}

.layers-panel-heading {
    min-width: 0;
    flex: 1 1 auto;
    display: grid;
    gap: 5px;
}

.layers-panel-title-row {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-width: 0;
    width: 100%;
    color: #0f172a;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.layers-panel-icon {
    width: 18px;
    height: 18px;
    opacity: 0.9;
    flex: 0 0 auto;
}

.layers-panel-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(15,23,42,0.06);
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

.layers-panel-subtitle {
    font-size: 12px;
    color: #64748b;
}

.layers-panel-header .close-btn {
    border: none;
    background: rgba(15,23,42,0.04);
    color: #64748b;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    margin-left: auto;
}

.layers-panel-header .close-btn:hover {
    background: rgba(15,23,42,0.08);
    color: #0f172a;
}

.layers-panel-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px 0;
    background: rgba(255,255,255,0.92);
}

.layers-panel-tab {
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(15,23,42,0.08);
    background: rgba(248,250,252,0.9);
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition:
        background-color 0.16s ease,
        border-color 0.16s ease,
        color 0.16s ease,
        box-shadow 0.16s ease;
}

.layers-panel-tab:hover {
    background: rgba(241,245,249,0.96);
    border-color: rgba(15,23,42,0.14);
    color: #0f172a;
}

.layers-panel-tab.is-active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(15,23,42,0.18);
}

.layers-panel-toolbar {
    display: none !important;
}

.layers-panel-search {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 12px;
    border-radius: 14px;
    border: 1px solid rgba(15,23,42,0.08);
    background: #f8fafc;
}

.layers-panel-search:focus-within {
    border-color: rgba(37,99,235,0.35);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.08);
}

.layers-panel-search-icon {
    color: #94a3b8;
    font-size: 14px;
    flex: 0 0 auto;
}

.layers-panel-search-input {
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    color: #0f172a;
    font: inherit;
}

.layers-panel-search-input::placeholder {
    color: #94a3b8;
}

.layers-panel-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.layers-toolbar-chip {
    border: 1px solid rgba(15,23,42,0.08);
    background: #ffffff;
    color: #334155;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.01em;
}

.layers-toolbar-chip:hover {
    background: rgba(15,23,42,0.04);
    border-color: rgba(15,23,42,0.14);
}

.layers-panel-empty {
    padding: 12px 2px 0;
    font-size: 12px;
    color: #64748b;
}

.leaflet-control-layers-list {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 24px 24px !important;
    white-space: normal;
}

.layers-operator-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 24px 24px;
    overflow: hidden;
}

.layers-operator-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.layers-operator-list {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

.layers-operator-empty {
    padding: 4px 0 0;
    font-size: 12px;
    color: #64748b;
}

.layers-operator-group {
    margin: 0;
}

.layers-operator-group + .layers-operator-group {
    margin-top: 2px;
}

.layers-operator-group-heading {
    padding-top: 14px;
    padding-bottom: 6px;
}

.layers-operator-group:first-child .layers-operator-group-heading {
    padding-top: 2px;
}

.layers-operator-group-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.layers-operator-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 0;
    padding: 7px 0;
    cursor: pointer;
}

.layers-operator-copy {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.layers-operator-title {
    min-width: 0;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    color: #0f172a;
}

.layers-operator-row.is-off .layers-operator-title,
.layers-operator-row.is-off .layers-entry-text,
.layers-operator-row.is-off .legend-line {
    opacity: 0.58;
}

.leaflet-control-layers-scrollbar {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 0;
}

.leaflet-control-layers-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.leaflet-control-layers-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.45);
    border-radius: 999px;
}

.leaflet-control-layers-overlays .leaflet-layerstree-node,
.leaflet-control-layers-base .leaflet-layerstree-node {
    padding: 0;
}

.leaflet-control-layers-list ul,
.leaflet-control-layers-list ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.leaflet-control-layers-list li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.leaflet-control-layers label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.leaflet-layerstree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.leaflet-layerstree-header > span:last-child,
.layers-tree-header-content {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    display: block;
}

.leaflet-layerstree-header-label {
    display: block !important;
    width: 100%;
    min-width: 0;
}

.layers-node-group-header {
    display: flex !important;
    width: 100%;
}

.leaflet-layerstree-header-name {
    min-width: 0;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    color: inherit;
}

.layers-group-title-fallback {
    min-width: 0;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.leaflet-control-layers .leaflet-layerstree-header label.layers-sparte-item {
    display: flex !important;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    cursor: pointer;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    font-size: 13px;
    font-weight: 400;
    color: #0f172a;
}

.leaflet-control-layers .leaflet-layerstree-header label.layers-sparte-item:hover {
    background: transparent;
}

.leaflet-layerstree-header-label > span,
.layers-sparte-item > span:last-child {
    min-width: 0;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    color: inherit;
}

.layers-sparte-item.is-off {
    opacity: 0.45;
}

.leaflet-layerstree-header-name.is-off,
.layers-node-group > .leaflet-layerstree-header .leaflet-layerstree-header-label.is-off,
.layers-node-group > .leaflet-layerstree-header .leaflet-layerstree-header-label > span.is-off {
    opacity: 0.45;
}

.layers-sparte-actions {
    display: inline-flex;
    align-items: center;
    gap: 0;
    flex: 0 0 auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.layers-sparte-row:hover .layers-sparte-actions,
.layers-operator-row:hover .layers-sparte-actions,
.layers-sparte-row:focus-within .layers-sparte-actions,
.layers-operator-row:focus-within .layers-sparte-actions,
.layers-sparte-actions:focus-within {
    opacity: 1;
    visibility: visible;
}

.layers-entry-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
}

.layers-node-leaf {
    margin: 0;
}

.layers-node-leaf > .leaflet-layerstree-header {
    min-height: 0;
    padding: 7px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: none;
}

.layers-node-leaf > .leaflet-layerstree-header:hover,
.layers-node-leaf > .leaflet-layerstree-header:focus-within {
    background: transparent;
    box-shadow: none;
}

.layers-node-leaf.is-layer-active > .leaflet-layerstree-header {
    background: transparent;
}

.layers-node-leaf .leaflet-layerstree-header-label > span {
    color: #0f172a;
    font-weight: 400;
    font-size: 13px;
}

.layers-node-leaf.is-layer-active .leaflet-layerstree-header-label > span,
.layers-node-leaf.is-layer-active .layers-sparte-item,
.layers-node-leaf.is-layer-active .layers-sparte-item > span:last-child,
.layers-node-leaf.is-layer-active .layers-entry-text {
    color: #0f172a;
}

.layers-node-group {
    margin: 0;
}

.layers-node-group > .leaflet-layerstree-header {
    min-height: 0;
    padding: 14px 0 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.layers-node-group > .leaflet-layerstree-header.is-group-partial .leaflet-layerstree-header-name,
.layers-node-group > .leaflet-layerstree-header.is-group-partial .leaflet-layerstree-header-label,
.layers-node-group > .leaflet-layerstree-header.is-group-partial .leaflet-layerstree-header-label > span {
    opacity: 0.72;
}

.layers-node-group:first-child > .leaflet-layerstree-header {
    padding-top: 2px;
}

.layers-node-group > .leaflet-layerstree-header:hover,
.layers-node-group > .leaflet-layerstree-header:focus-within {
    background: transparent;
}

.layers-node-group > .leaflet-layerstree-header .leaflet-layerstree-header-label,
.layers-node-group > .leaflet-layerstree-header .leaflet-layerstree-header-label > span,
.layers-node-group > .leaflet-layerstree-header .leaflet-layerstree-header-name,
.layers-node-group > .leaflet-layerstree-header.layers-node-group-header .leaflet-layerstree-header-name {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: #0f172a;
    opacity: 1 !important;
    visibility: visible !important;
}

.layers-node-group > .leaflet-layerstree-header .layers-sparte-actions {
    opacity: 1;
    visibility: visible;
}

.layers-group-count {
    display: none !important;
}

.layers-node-group > .leaflet-layerstree-children {
    margin: 0;
    padding: 0;
    border: 0;
}

.layers-manual-group-header {
    margin: 0;
    padding: 14px 0 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0;
    color: #0f172a;
}

.layers-manual-group-title {
    min-width: 0;
    flex: 1 1 auto;
}

.layers-manual-group-header .layers-sparte-actions {
    opacity: 1;
    visibility: visible;
}

.layers-manual-group-header.is-group-partial .layers-manual-group-title,
.layers-manual-group-title.is-off {
    opacity: 0.72;
}

.layers-manual-group-header .eye-toggle {
    width: 32px;
    height: 32px;
    background-color: transparent;
}

.layers-manual-group-header:first-child {
    padding-top: 2px;
}

.leaflet-layerstree-children,
.leaflet-layerstree-children-nopad {
    padding-left: 0 !important;
}

.leaflet-layerstree-header-pointer {
    display: none !important;
}

.layers-tree-header-pointerwrap,
.leaflet-layerstree-header-space {
    display: none !important;
}

.layers-node-leaf .leaflet-layerstree-header-pointer {
    display: none;
}

.leaflet-layerstree-header-pointer span {
    font-weight: 700;
    line-height: 1;
}

.layers-node-header.is-search-match {
    box-shadow: none;
}

.layers-search-hidden {
    display: none !important;
}

.layers-mode-hidden {
    display: none !important;
}

.leaflet-layerstree-node.layers-category-empty > .leaflet-layerstree-header .leaflet-layerstree-header-label > span {
    color: #94a3b8;
}

.leaflet-layerstree-node.layers-category-empty > .leaflet-layerstree-header .layers-group-count {
    display: none;
}

.eye-hidden-input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.eye-toggle {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    appearance: none;
    border-radius: 8px;
    border: 0;
    background-color: transparent;
    box-shadow: none;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 18px 18px;
    cursor: pointer;
    transition:
        opacity 0.16s ease,
        background-color 0.16s ease;
}

.eye-toggle.is-on {
    background-image: url('../images/IconoirEyeEmpty.svg');
    opacity: 0.92;
}

.eye-toggle.is-off {
    background-image: url('../images/IconoirEyeOff.svg');
    opacity: 0.7;
}

.eye-toggle.is-mixed {
    background-image: url('../images/IconoirEyeEmpty.svg');
    opacity: 0.78;
}

.eye-toggle:hover {
    background-color: rgba(15,23,42,0.06);
}

.layers-node-group > .leaflet-layerstree-header .eye-toggle {
    width: 32px;
    height: 32px;
    background-color: transparent;
}

.eye-toggle:focus-visible {
    outline: none;
    background-color: rgba(15,23,42,0.08);
}

.legend-line {
    display: inline-block;
    width: 14px;
    height: 4px;
    border-radius: 999px;
    margin-right: 0;
    vertical-align: middle;
    flex: 0 0 auto;
}

.legend-line-dashed {
    background: repeating-linear-gradient(
        90deg,
        var(--legend-color, currentColor) 0 7px,
        transparent 7px 11px
    ) !important;
}

.legend-point {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 0;
    border-radius: 999px;
    vertical-align: middle;
    background: var(--legend-color, currentColor);
    box-shadow: 0 0 0 1px rgba(15,23,42,0.08);
    flex: 0 0 auto;
}

.legend-polygon {
    display: inline-block;
    width: 10px;
    height: 8px;
    margin-right: 0;
    vertical-align: middle;
    background: var(--legend-color, currentColor);
    border: 2px solid var(--legend-color, currentColor);
    border-radius: 3px;
    box-sizing: border-box;
    opacity: 0.35;
    flex: 0 0 auto;
}

.leaflet-control-layers.layers-default-open .leaflet-layerstree-children.leaflet-layerstree-hide {
    display: block !important;
}

.leaflet-control-layers.layers-default-open .leaflet-layerstree-header-pointer .leaflet-layerstree-opened {
    display: inline !important;
}

.leaflet-control-layers.layers-default-open .leaflet-layerstree-header-pointer .leaflet-layerstree-closed {
    display: none !important;
}

.leaflet-container.cursor-pointer {
    cursor: pointer;
}

@media (max-width: 860px) {
    .leaflet-control-layers {
        width: min(420px, calc(100vw - 20px));
        min-width: 0;
        max-width: calc(100vw - 20px);
        border-radius: 20px;
    }

    .layers-panel-header {
        padding: 18px 18px 14px;
    }

    .layers-panel-tabs {
        padding: 12px 18px 0;
    }

    .leaflet-control-layers-list {
        padding-left: 16px !important;
        padding-right: 16px !important;
        padding-bottom: 18px !important;
    }

    .layers-operator-view {
        padding: 12px 18px 18px;
    }

    .layers-sparte-actions {
        opacity: 1;
        visibility: visible;
    }
}

/* Map loading spinner (small, unobtrusive) */
.map-loading-holder {
    position: absolute;
    top: calc(var(--nav-height, 0px) + 12px);
    right: 12px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: 0 4px 10px rgba(15,23,42,0.12);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
}

.map-loading-holder.is-visible {
    display: inline-flex;
}

.map-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(15,23,42,0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: mapspin 0.9s linear infinite;
}

@keyframes mapspin {
    to { transform: rotate(360deg); }
}
