:root {
    /* PnB_Search Design System Colors */
    --primary-color: #1754cf;
    --primary-dark: #1240a8;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-dark: #111621;
    --bg-card: rgba(17, 22, 33, 0.75);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --sidebar-width: 320px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-dark);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Authentication Overlay */
#authWrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    /* Flex by default, toggled by JS */
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#authWrapper::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle at 50% 50%, rgba(23, 84, 207, 0.15), transparent 60%);
    animation: pulse 15s infinite ease-in-out;
    pointer-events: none;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 0.5;
    }
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 10;
    position: relative;
}

.login-header h2 {
    text-align: center;
    margin: 0 0 8px 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
}

.login-header .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
    background: rgba(30, 41, 59, 0.7);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    color: #fca5a5;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 20px;
    display: none;
}

.error-message.active {
    display: block;
}

/* Checkbox specific */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.checkbox-group input {
    width: auto;
}

.checkbox-group label {
    margin-bottom: 0;
    text-transform: none;
    font-weight: 400;
}


/* Main Application Layout */
#mainContent {
    display: none;
    /* Hidden by default until auth */
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
}

#sidebar {
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
}

.sidebar-content {
    padding: 24px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 20px;
}

.sidebar-header h1 {
    margin: 0;
    font-size: 20px;
    color: white;
    font-weight: 700;
}

.sidebar-header p {
    margin: 4px 0 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* User Profile Section in Sidebar */
.user-profile {
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.6);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-email {
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: white;
}


/* Map Area */
#map {
    width: 100%;
    height: 100%;
}


/* Filters */
.filter-group {
    margin-bottom: 30px;
}

.filter-group h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.filter-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.filter-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.filter-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-left: 8px;
    font-size: 14px;
    color: var(--text-primary);
    width: 100%;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* Stats */
.stats-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 12px;
}

.stats-panel h3 {
    margin-top: 0;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-val {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 24px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Leaflet Popups (Dark Mode) */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.leaflet-popup-content h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: white;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.popup-row {
    font-size: 13px;
    margin-bottom: 4px;
    color: #cbd5e1;
}

.popup-row strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.popup-row.meta {
    margin-top: 10px;
    font-size: 11px;
    color: #64748b;
    border-top: 1px solid var(--border-color);
    padding-top: 5px;
}