:root {
    --bg-glass: rgba(18, 18, 20, 0.95);
    --border-glass: rgba(255, 255, 255, 0.15);
    --accent: #4cc9f0;
    --text-muted: #99a;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: #050505;
    overflow: hidden;
    color: #fff;
}

#map {
    width: 100%;
    height: 100%;
}

/* UI Panels */
.panel {
    position: absolute;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
    z-index: 20;
    color: #eee;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Top Left Controls */
#controls {
    top: 20px;
    left: 20px;
    width: 340px;
    max-height: 90vh;
    overflow-y: auto;
}

.app-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.live-btn {
    position: absolute;
    right: 15px;

    background: #e63946;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.3s;
}

.live-btn.active {
    opacity: 1;
    box-shadow: 0 0 15px rgba(230, 57, 70, 0.5);
}

.big-time {
    font-size: 36px;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: -1px;
}

.sub-data {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

input[type="range"] {
    width: 100%;
    margin: 15px 0 5px;
    accent-color: var(--accent);
    cursor: pointer;
}

input[type="datetime-local"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
}

/* Styled Select */
select {
    background: #222;
    border: 1px solid #444;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right .7em top 50%;
    background-size: .65em auto;
    padding-right: 20px;
}

select:hover {
    border-color: #666;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    font-size: 12px;
    color: #ccc;
}

.toggle-row input {
    margin: 0;
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* Sidebar */
#sidebar {
    top: 20px;
    right: 20px;
    bottom: 20px;
    width: 420px;
    transform: translateX(120%);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;

    /* moved padding to header instead */
    padding-top: 0;
}

#sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding-top: 16px;
    padding-bottom: 16px;
    margin-bottom: 4px;
    background: var(--bg-glass);
    z-index: 1;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
}

.city-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    line-height: 1.1;
}

.city-badge {
    display: inline-block;
    font-size: 10px;
    background: rgba(76, 201, 240, 0.15);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 6px;
    font-weight: 600;
}

.divider {
    height: 1px;
    background: var(--border-glass);
    margin: 20px 0;
}

.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-val {
    font-size: 18px;
    font-weight: 600;
}

.stat-val.sm {
    font-size: 15px;
}

/* Graph Canvas */
/* Edit: This scales the canvas!
            This breaks the assumption that coordinates on canvas = coordinates in browser / css.
            Which can cause the progress indicator to be offset when using pixels. Use percentages instead.
            */
canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.graph-wrap {
    height: 180px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    position: relative;
    border: 1px solid #333;
}

/* Simple Legend */
.legend {
    display: flex;
    gap: 15px;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 8px;
    justify-content: center;
}

.legend .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.legend .line {
    width: 2px;
    height: 8px;
    display: inline-block;
    margin-right: 4px;
}

/* Map Overlay Legend */
.map-legend {
    margin-top: 15px;
    background: #111;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #333;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 11px;
    color: #eee;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.map-legend.hidden {
    display: none;
}

.legend-chip {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Close Button */
.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    cursor: pointer;
    color: #666;
    transition: 0.2s;
}

.close-btn:hover {
    color: #fff;
}

/* Help Tooltip */
.help-icon {
    color: #666;
    cursor: pointer;
    margin-left: 8px;
    font-size: 12px;
}

.help-icon:hover {
    color: var(--accent);
}

.info-box {
    background: rgba(76, 201, 240, 0.1);
    border-left: 3px solid var(--accent);
    padding: 10px;
    font-size: 12px;
    color: #ccc;
    margin-top: 10px;
    line-height: 1.4;
    display: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* Compact Layout for Mobile Devices */
@media (max-width: 600px) {
    #controls {
        box-sizing: border-box;
        position: absolute;
        top: 5px;
        left: 5px;
        right: 5px;
        max-height: 90vh;
        overflow-y: auto;
        width: auto;
    }

    #sidebar {
        left: 5px;
        top: 5px;
        right: 5px;
        bottom: 5px;
        width: auto;
        transform: translateX(120%);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
    }
}