:root {
    --bg: #0a0a0f;
    --bg2: #111118;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #94a3b8;

    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.12);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.12);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: -30%;
    left: -20%;
    width: 100vw;
    height: 100vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.07) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Header ── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-bottom: 1px solid var(--border);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.2rem;
    color: var(--text);
}

.header-logo strong {
    color: var(--accent);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 99px;
    border: 1px solid;
}

.status-badge.online {
    color: var(--green);
    background: var(--green-bg);
    border-color: rgba(16, 185, 129, 0.2);
}

.status-badge.offline {
    color: var(--text-muted);
    background: var(--surface);
    border-color: var(--border);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    gap: 12px;
    padding: 15px 20px;
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(10, 10, 15, 0.3);
}

.stats-bar::-webkit-scrollbar {
    display: none;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 99px;
    background: var(--surface);
    border: 1px solid var(--border);
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
}

/* ── Main Layout ── */
.main-content {
    padding: 10px 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 750px;
    margin: 0 auto;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin: 25px 0 8px 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::after {
    content: '';
    height: 1px;
    background: var(--border);
    flex: 1;
}

/* ── Cards ── */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.glass-card.no-pad {
    padding: 0;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-icon {
    color: var(--accent);
}

/* Grid stats */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.metric-block {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metric-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}

.metric-value small {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.6;
}

.accent-yellow .metric-value {
    color: var(--yellow);
}

.accent-green .metric-value {
    color: var(--green);
}

.accent-blue .metric-value {
    color: var(--blue);
}

.mono {
    font-family: monospace;
    font-size: 0.8rem !important;
}

/* Buttons & Controls */
.controls-row {
    display: flex;
    gap: 12px;
    margin-top: 5px;
}

.ctrl-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    border: none;
    border-radius: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.ctrl-start {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.ctrl-stop {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ctrl-btn:active {
    transform: scale(0.96);
}

.ctrl-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.card-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
}

.card-inline-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.badge-count {
    background: var(--accent);
    color: white;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 800;
}

.session-label {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Map Area */
.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

#map {
    width: 100%;
    background: #0a0a0f !important;
}

.leaflet-tile-pane {
    filter: brightness(0.6) saturate(0.5);
}

/* Switch Toggle */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.toggle-track {
    width: 38px;
    height: 18px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    position: relative;
}

.toggle-thumb {
    width: 12px;
    height: 12px;
    background: #64748b;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: 0.2s;
}

input:checked+.toggle-track {
    background: var(--accent-glow);
}

input:checked+.toggle-track .toggle-thumb {
    transform: translateX(20px);
    background: var(--accent);
}

input {
    display: none;
}

/* Charts & Selects */
.chart-wrap {
    height: 180px;
}

.dark-select,
.dark-select-sm {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    outline: none;
    margin-bottom: 10px;
}

.btn-row {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.action-blue {
    background: var(--blue-bg);
    color: var(--blue);
    border-color: rgba(59, 130, 246, 0.3);
}

.action-purple {
    background: var(--purple-bg);
    color: var(--purple);
    border-color: rgba(168, 85, 247, 0.3);
}

.action-green {
    background: var(--green-bg);
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.3);
}

/* Settings */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-of-type {
    border-bottom: none;
}

.settings-label {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.dark-select-sm {
    width: auto;
    padding: 8px 15px;
    margin-bottom: 0;
    font-size: 0.85rem;
}

/* Progress Bar */
.speedtest-progress {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 9px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: 0.2s;
}

#speedtest-status {
    font-size: 0.8rem;
    text-align: center;
    color: var(--text-muted);
}

.hidden {
    display: none;
}