:root {
    --bg-deep: #050508;
    --bg-dark: #0f0f15;
    --bg-glass: rgba(15, 15, 23, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent: #ff3e3e;
    --accent-glow: rgba(255, 62, 62, 0.4);
    --text-main: #e2e2e7;
    --text-dim: #a1a1aa;

    --mag-low: #4ade80;
    --mag-mid: #facc15;
    --mag-high: #fb923c;
    --mag-deep: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-deep);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: 70px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    z-index: 1000;
    padding: 0 2rem;
    display: flex;
    align-items: center;
}

.header-inner {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand h1 {
    font-size: 1.25rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pulse-icon {
    font-size: 1.5rem;
    animation: alarm 2s infinite;
}

@keyframes alarm {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }

    100% {
        opacity: 0.5;
        transform: scale(1);
    }
}

.metrics {
    display: flex;
    gap: 3rem;
}

.metric {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.metric .label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

/* Map */
#map {
    flex: 1;
    z-index: 1;
    background: #0b0b0f;
}

.leaflet-tile-pane {
    filter: grayscale(1) invert(0.9) brightness(0.85);
}

/* Sidebar */
.sidebar {
    position: absolute;
    top: 90px;
    left: 20px;
    width: 320px;
    max-height: calc(100vh - 130px);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.quake-list {
    overflow-y: auto;
    padding: 1rem;
}

.quake-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
}

.quake-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-glass);
    transform: translateX(4px);
}

.quake-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.quake-mag {
    font-weight: 700;
    font-size: 1rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.quake-place {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quake-time {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Legend */
.legend {
    position: absolute;
    bottom: 30px;
    right: 20px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    z-index: 1000;
}

.legend-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.scale-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.color-dot.m1 {
    background: var(--mag-low);
}

.color-dot.m3 {
    background: var(--mag-mid);
}

.color-dot.m5 {
    background: var(--mag-high);
}

.color-dot.m7 {
    background: var(--mag-deep);
}

/* Loader */
.loader-bg {
    position: fixed;
    inset: 0;
    background: var(--bg-deep);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.5s;
}

.loader-bg.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.ripple {
    width: 80px;
    height: 80px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: ripple 1.5s infinite;
}

@keyframes ripple {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Popups */
.leaflet-popup-content-wrapper {
    background: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
}

.leaflet-popup-tip {
    background: var(--bg-dark);
}

.popup-card h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.popup-card p {
    font-size: 0.85rem;
    margin: 0.2rem 0;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .header {
        height: 60px;
        padding: 0 1rem;
    }

    .brand h1 {
        font-size: 0.9rem;
    }

    .pulse-icon {
        font-size: 1.2rem;
    }

    .metrics {
        gap: 1rem;
    }

    .metric .label {
        font-size: 0.6rem;
    }

    .metric .value {
        font-size: 0.9rem;
    }

    /* Sidebar becomes a small collapsible panel at bottom */
    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 180px;
        border-radius: 16px 16px 0 0;
        z-index: 1001;
    }

    .sidebar-header {
        padding: 0.75rem 1rem;
    }

    .sidebar-header h2 {
        font-size: 0.85rem;
    }

    .quake-list {
        padding: 0.5rem 1rem;
        display: flex;
        gap: 0.75rem;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .quake-item {
        min-width: 200px;
        flex-shrink: 0;
        padding: 0.75rem;
        margin-bottom: 0;
    }

    .quake-item:hover {
        transform: none;
    }

    /* Legend */
    .legend {
        bottom: 190px;
        right: 10px;
        padding: 0.75rem;
    }

    .legend-title {
        font-size: 0.65rem;
        margin-bottom: 0.5rem;
    }

    .scale-item {
        font-size: 0.7rem;
        gap: 0.5rem;
        margin-bottom: 0.25rem;
    }

    .color-dot {
        width: 8px;
        height: 8px;
    }
}

@media (max-width: 480px) {
    .brand h1 {
        display: none;
    }

    .metrics {
        gap: 0.75rem;
    }

    .metric .label {
        font-size: 0.55rem;
    }

    .metric .value {
        font-size: 0.8rem;
    }

    .sidebar {
        max-height: 150px;
    }

    .legend {
        bottom: 160px;
    }
}