:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --secondary: #8B5CF6;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #06B6D4;

    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-card: #334155;
    --bg-hover: #475569;

    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --gradient-success: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    --gradient-danger: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 150ms;
    --transition-base: 300ms;
    --transition-slow: 500ms;
}

[data-theme="light"] {
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-card: #F1F5F9;
    --bg-hover: #E2E8F0;

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px 0;
}

[data-theme="light"] header {
    background: rgba(248, 250, 252, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

nav {
    display: flex;
    gap: 32px;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
    position: relative;
}

nav a:hover {
    color: var(--primary);
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width var(--transition-fast);
}

nav a:hover::after {
    width: 100%;
}

.theme-toggle {
    background: var(--bg-card);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

main {
    padding-top: 100px;
    padding-bottom: 80px;
}

.hero {
    text-align: center;
    padding: 80px 0;
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 20px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 40px;
}

.speed-bars {
    width: 100%;
    max-width: 600px;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.speed-bar-item {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.speed-bar-label {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
}

.speed-bar-container {
    position: relative;
    height: 48px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.speed-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    transition: width 0.3s ease-out;
    min-width: 0;
}

.speed-bar-fill.upload {
    background: linear-gradient(90deg, #10b981 0%, #06b6d4 100%);
}

.speed-bar-value {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.action-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 24px;
}

.btn {
    padding: 16px 48px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-lg);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn.hidden {
    display: none;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.btn:hover::after {
    transform: translateX(100%);
}

#statusMessage {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 48px;
}

section {
    margin-bottom: 100px;
    position: relative;
}

.section-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 32px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

.metric-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
    border: 1px solid transparent;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.metric-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-xl);
}

.metric-card:hover::before {
    opacity: 1;
}

.metric-card.testing {
    border-color: var(--warning);
}

.metric-card.testing::before {
    background: var(--warning);
    opacity: 1;
    animation: progress 1.5s ease-in-out infinite;
}

.metric-card.completed::before {
    opacity: 1;
}

@keyframes progress {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.metric-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.metric-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 36px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.metric-value.animating {
    animation: shimmer 1s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.metric-rating {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    width: 0%;
    transition: width var(--transition-base);
}

.progress-text {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    min-height: 18px;
}

.category-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 12px;
}

.category-tab {
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.category-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary);
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.app-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.app-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.app-card.testing {
    border-color: var(--warning);
    animation: pulse-border 1s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--warning); }
    50% { border-color: transparent; }
}

.app-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.app-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.latency-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
    margin-bottom: 8px;
}

.status-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    color: white;
    display: inline-block;
}

#latencyStatus {
    margin-bottom: 24px;
    color: var(--text-secondary);
}

.category-content {
    display: none;
}

.category-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
    margin-bottom: 48px;
    padding-bottom: 24px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.test-all-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 24px;
}

.test-all-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.history-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 32px;
}

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

.history-header h3 {
    font-size: 24px;
    font-weight: 700;
}

.btn-clear {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-clear:hover {
    opacity: 0.8;
}

#historyList {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition-fast);
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-time {
    color: var(--text-secondary);
    font-size: 14px;
}

.history-stats {
    display: flex;
    gap: 24px;
}

.history-stats .stat {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-primary);
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

footer {
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 32px 0;
    text-align: center;
}

.footer-content {
    color: var(--text-secondary);
    font-size: 14px;
}

.footer-content a {
    color: var(--primary);
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}

#networkInfo {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 32px;
    }

    .hero p {
        font-size: 16px;
    }

    .speed-gauge {
        width: 240px;
        height: 240px;
    }

    .gauge-value {
        font-size: 48px;
    }

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

    .apps-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .category-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    nav {
        display: none;
    }

    .btn {
        padding: 12px 32px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 28px;
    }

    .speed-gauge {
        width: 200px;
        height: 200px;
    }

    .gauge-value {
        font-size: 36px;
    }

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

.node-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 24px 0;
}

.node-selector label {
    font-size: 16px;
    color: var(--text-secondary);
}

.node-select {
    padding: 12px 20px;
    font-size: 16px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--bg-hover);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 250px;
}

.node-select:hover {
    border-color: var(--primary);
}

.node-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-refresh {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 2px solid var(--bg-hover);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    transition: all var(--transition-fast);
}

.btn-refresh:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.05);
}

.current-node {
    margin-top: 16px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: inline-block;
}

.node-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.node-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.node-province {
    font-size: 14px;
    color: var(--text-secondary);
}
