:root {
    --bg-main: #0A1219;
    --bg-surface: #121F2B;
    --bg-surface-light: #1A2C3D;

    --primary: #74B9FF;
    /* Speed Blue */
    --secondary: #00CEC9;
    /* Teal */
    --accent: #FDCB6E;
    /* Yellow/Gold */
    --error: #FF7675;

    --text-primary: #FFFFFF;
    --text-secondary: #B2BEC3;
    --text-muted: #636E72;

    --border: #2D3436;

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-round: 50%;

    --shadow-glow: 0 0 20px rgba(116, 185, 255, 0.4);

    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.text-primary {
    color: var(--primary);
}

.text-secondary {
    color: var(--secondary);
}

.text-accent {
    color: var(--accent);
}

.app-layout {
    display: flex;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* Dashboard */
.dashboard {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-main);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--primary);
    font-weight: 400;
}

.network-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-surface);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--secondary);
    border-radius: var(--radius-round);
    box-shadow: 0 0 8px var(--secondary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* Speedometer Section */
.speedometer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 60px;
}

.gauge-container {
    position: relative;
    width: 360px;
    height: 220px;
}

.gauge {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.gauge-track {
    stroke: var(--bg-surface-light);
}

.gauge-ticks line {
    stroke: var(--text-muted);
    stroke-width: 2;
}

.gauge-ticks text {
    fill: var(--text-secondary);
    font-size: 8px;
    font-family: var(--font-mono);
}

.speed-readout {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.speed-value {
    font-family: var(--font-mono);
    font-size: 4.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    transition: color 0.3s;
}

.speed-unit {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 1px;
}

.action-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: -20px;
    gap: 16px;
    z-index: 2;
}

.status-text {
    color: var(--text-secondary);
    font-size: 1rem;
    min-height: 24px;
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.2s ease;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #0984e3);
    color: #fff;
    font-weight: 600;
}

.btn-large {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-round);
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.btn-glow:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(116, 185, 255, 0.5);
}

.btn-glow:active {
    transform: scale(0.95);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 100px;
}

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
    background-color: var(--bg-surface);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    padding: 8px;
}

.btn-icon:hover {
    color: var(--error);
    background-color: rgba(255, 118, 117, 0.1);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.metric-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-color: #3d4a4d;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-round);
    background-color: var(--bg-surface-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-details {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
}

.metric-value small {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Quality Rating */
.quality-rating {
    background: linear-gradient(to right, var(--bg-surface), transparent);
    padding: 32px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    margin-bottom: 40px;
}

.quality-rating h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.rating-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 8px;
    background-color: rgba(0, 206, 201, 0.1);
    color: var(--secondary);
}

.rating-badge.excellent {
    background-color: rgba(0, 206, 201, 0.1);
    color: var(--secondary);
}

.rating-badge.good {
    background-color: rgba(116, 185, 255, 0.1);
    color: var(--primary);
}

.rating-badge.fair {
    background-color: rgba(253, 203, 110, 0.1);
    color: var(--accent);
}

.rating-badge.poor {
    background-color: rgba(255, 118, 117, 0.1);
    color: var(--error);
}

#ratingDesc {
    color: var(--text-muted);
}

.export-controls {
    display: flex;
    justify-content: center;
}

/* Sidebar History */
.sidebar {
    width: 360px;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 32px 24px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.h-stat {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.h-val {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
}

.h-unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.h-down {
    color: var(--primary);
}

.h-up {
    color: var(--secondary);
}

.h-ping {
    color: var(--accent);
}

/* Utility */
.mt-auto {
    margin-top: auto;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        height: 400px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }
}