* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#notification-bar {
    background-color: rgba(33, 33, 33, 0.9);
    color: white;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2000;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 0 10px;
}

#notification-bar a {
    color: #90CAF9;
    font-weight: bold;
    text-decoration: none;
}

#notification-bar a:hover {
    text-decoration: underline;
    color: #BBDEFB;
}

#map {
    width: 100%;
    height: calc(100vh - 32px);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #228B22;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
    color: #333;
}

.error-message {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: #f44336;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    z-index: 1000;
    display: none;
}

.error-message.show {
    display: block;
}

.leaflet-popup-content {
    min-width: 280px;
    max-width: 350px;
}

.popup-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 40px;
}

.popup-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #228B22;
    border-radius: 50%;
    animation: popup-spin 0.8s linear infinite;
}

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

.sssi-popup h3 {
    margin: 0 0 8px 0;
    color: #228B22;
    font-size: 16px;
}

.sssi-popup p {
    margin: 4px 0;
    font-size: 14px;
    color: #333;
}

.sssi-popup .reference {
    color: #666;
    font-family: monospace;
}

.sssi-popup a {
    display: inline-block;
    margin-top: 8px;
    color: #1976D2;
    text-decoration: none;
}

.sssi-popup a:hover {
    text-decoration: underline;
}

.sssi-popup .pdf-links {
    margin: 8px 0;
    display: flex;
    gap: 12px;
}

.sssi-popup .pdf-links a {
    margin: 0;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 3px;
    font-size: 12px;
    color: #333;
}

.sssi-popup .pdf-links a:hover {
    background: #e0e0e0;
}

.sssi-popup .features-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.sssi-popup .features-section h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #333;
}

.sssi-popup .features-list {
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}

.sssi-popup .feature-item {
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
}

.sssi-popup .feature-item:last-child {
    border-bottom: none;
}

.sssi-popup .feature-name {
    font-weight: 500;
    color: #333;
}

.sssi-popup .feature-condition {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    margin-left: 4px;
}

.sssi-popup .condition-favourable {
    background: #c8e6c9;
    color: #2e7d32;
}

.sssi-popup .condition-unfavourable {
    background: #ffcdd2;
    color: #c62828;
}

.sssi-popup .condition-recovering {
    background: #fff3e0;
    color: #ef6c00;
}

.sssi-popup .condition-unknown {
    background: #e0e0e0;
    color: #616161;
}

.sssi-popup .no-data {
    color: #999;
    font-style: italic;
    font-size: 12px;
}

.sssi-popup .wildlife-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #FFF8E1;
    border: 1px solid #FFB300;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
}

.sssi-popup .wildlife-warning .icon {
    font-size: 20px;
    line-height: 1;
}

.sssi-popup .wildlife-warning .text {
    flex: 1;
}

.sssi-popup .wildlife-warning .title {
    font-weight: 600;
    color: #E65100;
    font-size: 12px;
    margin-bottom: 2px;
}

.sssi-popup .wildlife-warning .detail {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
}

.sssi-popup .wildlife-warning .advice {
    font-size: 11px;
    color: #BF360C;
    font-weight: 500;
}

.sssi-popup .drone-ok {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #E3F2FD;
    border: 1px solid #64B5F6;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
}

.sssi-popup .drone-ok .icon {
    font-size: 20px;
}

.sssi-popup .drone-ok .text {
    font-size: 12px;
    color: #1565C0;
}

.sssi-popup .feature-wildlife {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 9px;
    margin-left: 4px;
    background: #FFCDD2;
    color: #C62828;
}

.sssi-popup .feature-insect {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 9px;
    margin-left: 4px;
    background: #E1BEE7;
    color: #7B1FA2;
}

.sssi-popup .insect-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #F3E5F5;
    border: 1px solid #CE93D8;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
}

.sssi-popup .insect-warning .icon {
    font-size: 20px;
    line-height: 1;
}

.sssi-popup .insect-warning .text {
    flex: 1;
}

.sssi-popup .insect-warning .title {
    font-weight: 600;
    color: #7B1FA2;
    font-size: 12px;
    margin-bottom: 2px;
}

.sssi-popup .insect-warning .detail {
    font-size: 11px;
    color: #666;
}

.sssi-popup .wales-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #FFEBEE;
    border: 1px solid #EF5350;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
}

.sssi-popup .wales-warning .icon {
    font-size: 20px;
    line-height: 1;
}

.sssi-popup .wales-warning .text {
    flex: 1;
}

.sssi-popup .wales-warning .title {
    font-weight: 600;
    color: #C62828;
    font-size: 12px;
    margin-bottom: 2px;
}

.sssi-popup .wales-warning .detail {
    font-size: 11px;
    color: #666;
}

.info-panel {
    position: fixed;
    top: 42px;
    right: 10px;
    background: white;
    padding: 12px 16px;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 500;
    max-width: 250px;
}

.info-panel h1 {
    font-size: 14px;
    margin: 0 0 8px 0;
    color: #333;
}

.info-panel p {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.site-count {
    font-weight: bold;
    color: #1565C0;
}

.layer-toggles {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.layer-toggles h3 {
    font-size: 11px;
    color: #666;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 0;
}

.layer-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.toggle-label {
    flex: 1;
}

.toggle-info {
    color: #999;
    font-size: 12px;
    cursor: help;
}

.legend {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.legend h3 {
    font-size: 11px;
    color: #666;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend.hidden {
    display: none;
}

.legend-note {
    font-size: 10px;
    color: #999;
    margin-top: 8px;
}

.legend-desc {
    font-size: 10px;
    color: #666;
    margin: -2px 0 6px 24px;
    font-style: italic;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    margin: 4px 0;
}

.legend-item.filter-checkbox {
    cursor: pointer;
    padding: 2px 4px;
    margin: 2px -4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.legend-item.filter-checkbox:hover {
    background: #f0f0f0;
}

.legend-item.filter-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.legend-item.filter-checkbox.disabled {
    opacity: 0.4;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 2px solid;
}

.legend-grey {
    background: #BDBDBD;
    border-color: #757575;
}

.legend-blue {
    background: #64B5F6;
    border-color: #1565C0;
}

.legend-amber {
    background: #FFB74D;
    border-color: #E65100;
}

.legend-purple {
    background: #CE93D8;
    border-color: #7B1FA2;
}

.legend-red {
    background: #EF5350;
    border-color: #C62828;
}

.legend-orange {
    background: #FFA726;
    border-color: #E65100;
}

.legend-yellow {
    background: #FFEE58;
    border-color: #F9A825;
}

/* UAS Airspace Popup */
.uas-popup h3 {
    margin: 0 0 8px 0;
    font-size: 15px;
}

.uas-popup h3.frz {
    color: #C62828;
}

.uas-popup h3.danger {
    color: #C62828;
}

.uas-popup h3.restricted {
    color: #F9A825;
}

.uas-popup .category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.uas-popup .category-badge.frz {
    background: #FFCDD2;
    color: #C62828;
}

.uas-popup .category-badge.danger {
    background: #FFCDD2;
    color: #C62828;
}

.uas-popup .category-badge.prohibited {
    background: #FFCDD2;
    color: #C62828;
}

.uas-popup .category-badge.restricted {
    background: #FFF9C4;
    color: #F57F17;
}

.uas-popup .altitude-info {
    background: #F5F5F5;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 12px;
}

.uas-popup .altitude-info strong {
    color: #333;
}

.uas-popup .activity {
    font-size: 12px;
    color: #666;
    margin: 8px 0;
}

.uas-popup .contact {
    font-size: 11px;
    color: #999;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

/* UAS List Popup (for overlapping features) */
.uas-popup-container .leaflet-popup-content {
    margin: 0;
    min-width: 320px;
    max-width: 400px;
}

.uas-list-popup {
    padding: 0;
}

.uas-list-header {
    padding: 12px 16px;
    background: #F5F5F5;
    border-bottom: 1px solid #E0E0E0;
}

.uas-list-header strong {
    font-size: 14px;
    color: #333;
}

.uas-list-hint {
    font-size: 11px;
    color: #666;
    margin: 4px 0 0 0;
}

.uas-features-list {
    max-height: 380px;
    overflow-y: auto;
}

/* Individual feature item in list */
.uas-feature-item {
    border-bottom: 1px solid #E0E0E0;
}

.uas-feature-item:last-child {
    border-bottom: none;
}

.uas-feature-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    background: #FAFAFA;
    transition: background 0.15s;
}

.uas-feature-header:hover {
    background: #F0F0F0;
}

.uas-feature-header .category-badge {
    flex-shrink: 0;
}

.uas-feature-header .feature-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uas-feature-header .feature-name.frz {
    color: #C62828;
}

.uas-feature-header .feature-name.danger {
    color: #C62828;
}

.uas-feature-header .feature-name.restricted {
    color: #F57F17;
}

.uas-feature-header .feature-name.sssi {
    color: #228B22;
}

/* SSSI badges in combined popup */
.category-badge.sssi {
    background: #E8F5E9;
    color: #2E7D32;
}

.category-badge.sssi-wildlife {
    background: #FFF3E0;
    color: #E65100;
}

.category-badge.sssi-insects {
    background: #F3E5F5;
    color: #7B1FA2;
}

/* SSSI item styling in list */
.sssi-item .uas-feature-details {
    padding: 0;
}

.sssi-item .uas-feature-details .sssi-popup {
    padding: 12px;
}

.sssi-item.expanded .uas-feature-header {
    background: #E8F5E9;
}

.uas-feature-header .expand-icon {
    color: #999;
    font-size: 10px;
    flex-shrink: 0;
}

/* Feature details (collapsible) */
.uas-feature-details {
    display: none;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #E8E8E8;
}

.uas-feature-item.expanded .uas-feature-details {
    display: block;
}

.uas-feature-item.expanded .uas-feature-header {
    background: #E3F2FD;
}

/* FRZ warning in details */
.uas-feature-details .frz-warning {
    color: #C62828;
    background: #FFEBEE;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
}

/* Danger area warning in details */
.uas-feature-details .danger-warning {
    color: #C62828;
    background: #FFEBEE;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
}

/* Restricted area warning in details */
.uas-feature-details .restricted-warning {
    color: #F57F17;
    background: #FFFDE7;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
}

/* Raw source data section */
.raw-data-section {
    margin-top: 12px;
    border-top: 1px solid #E0E0E0;
    padding-top: 8px;
}

.raw-data-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 6px 8px;
    background: #F5F5F5;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    transition: background 0.15s;
}

.raw-data-header:hover {
    background: #EEEEEE;
}

.raw-data-content {
    display: none;
    margin-top: 8px;
}

.raw-data-content pre {
    font-size: 10px;
    font-family: 'Consolas', 'Monaco', monospace;
    background: #F9F9F9;
    border: 1px solid #E0E0E0;
    border-radius: 4px;
    padding: 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
    color: #555;
    line-height: 1.4;
}

.toolbar {
    position: fixed;
    top: 42px;
    left: 60px;
    z-index: 500;
    display: flex;
    gap: 8px;
}

.toolbar-btn {
    width: 40px;
    height: 40px;
    background: white;
    border: none;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s;
}

.toolbar-btn:hover {
    background: #f5f5f5;
}

.toolbar-btn:active {
    background: #e0e0e0;
}

.toolbar-btn.locating {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { background: white; }
    50% { background: #E3F2FD; }
}

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(33, 33, 33, 0.9);
    color: #fff;
    padding: 8px 220px 8px 16px;
    font-size: 12px;
    z-index: 400;
}

.status-bar a {
    color: #90CAF9;
    text-decoration: none;
}

.status-bar a:hover {
    text-decoration: underline;
}

.status-line {
    text-align: center;
}

.status-divider {
    color: #666;
    margin: 0 8px;
}

.sssi-popup .collected-date {
    font-size: 11px;
    color: #9e9e9e;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

/* Mobile legend toggle button - hidden on desktop */
.mobile-legend-btn {
    display: none;
    position: fixed;
    top: 42px;
    right: 10px;
    z-index: 500;
}

@media (max-width: 600px) {
    .mobile-legend-btn {
        display: flex;
    }

    .info-panel {
        display: none !important;
        position: fixed;
        top: 90px;
        right: 10px;
        left: 10px;
        max-width: none;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        z-index: 600;
    }

    .info-panel.visible {
        display: block !important;
    }

    .toolbar {
        top: 42px;
        left: 50px;
    }

    .status-bar {
        padding: 8px 12px 28px 12px;
        font-size: 11px;
    }

    .status-divider {
        display: none;
    }

    .status-line {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .leaflet-popup-content {
        min-width: 200px;
        max-width: 280px;
    }

    .sssi-popup h3 {
        font-size: 14px;
    }

    .sssi-popup .features-list {
        max-height: 150px;
    }

    .sssi-popup .feature-item {
        font-size: 11px;
    }

    .leaflet-control-attribution {
        position: fixed !important;
        bottom: 85px !important;
        right: 0 !important;
        background: rgba(255,255,255,0.8) !important;
        padding: 2px 8px !important;
        font-size: 10px !important;
    }
}
