: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%);

    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[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;
    -webkit-tap-highlight-color: transparent;
}

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

.mobile-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
}

.mobile-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
}

[data-theme="light"] .mobile-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
}

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

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.mobile-nav {
    display: flex;
    padding: 0 16px 12px;
    gap: 8px;
}

.nav-btn {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: 2px solid var(--bg-card);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.nav-btn:active {
    transform: scale(0.98);
}

.mobile-main {
    flex: 1;
    padding: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.gauges-container {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 0 8px;
}

.gauge-wrapper {
    flex: 1;
    max-width: 180px;
}

.speed-gauge {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.speed-gauge::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    opacity: 0.5;
}

.download-gauge::before {
    background: conic-gradient(from 180deg, var(--primary) 0deg, var(--secondary) 180deg, var(--primary) 360deg);
}

.upload-gauge::before {
    background: conic-gradient(from 180deg, #10b981 0deg, #06b6d4 180deg, #10b981 360deg);
}

.gauge-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gauge-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: transparent;
}

.download-gauge .gauge-ring {
    border: 3px solid var(--primary);
    opacity: 0.3;
}

.upload-gauge .gauge-ring {
    border: 3px solid #10b981;
    opacity: 0.3;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.gauge-value {
    font-size: 56px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gauge-label {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.gauge-unit {
    font-size: 20px;
    color: var(--text-muted);
}

.action-area {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 24px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

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

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-primary.hidden,
.btn-secondary.hidden {
    display: none;
}

.btn-icon {
    font-size: 24px;
}

.status-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.metric-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    gap: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.metric-item:active {
    border-color: var(--primary);
}

.metric-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.metric-icon {
    font-size: 24px;
}

.metric-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-data {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

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

.metric-unit {
    font-size: 14px;
    color: var(--text-muted);
}

.metric-rating {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    color: white;
    background: var(--text-muted);
    min-width: 40px;
    text-align: center;
}

.network-info {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px;
}

.section-desc {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.category-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.category-btn {
    flex-shrink: 0;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.apps-section {
    display: none;
}

.apps-section.active {
    display: block;
}

.test-all-btn {
    width: 100%;
    padding: 14px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.test-all-btn:active {
    transform: scale(0.98);
}

.apps-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.app-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    gap: 14px;
    border: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.app-item:active {
    border-color: var(--primary);
    transform: scale(0.98);
}

.app-item.testing {
    border-color: var(--warning);
}

.app-icon {
    font-size: 36px;
}

.app-info {
    flex: 1;
}

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

.app-latency {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    color: white;
}

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

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

.btn-clear {
    padding: 8px 16px;
    background: var(--danger);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.history-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

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

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

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

.mobile-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    text-align: center;
}

[data-theme="light"] .mobile-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.mobile-footer p {
    font-size: 12px;
    color: var(--text-muted);
}

@media (min-width: 768px) {
    .mobile-container {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
    }
}

.mobile-node-selector {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.node-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.btn-refresh {
    padding: 6px 12px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.mobile-node-select {
    width: 100%;
    padding: 12px;
    background: var(--bg-card);
    border: 2px solid var(--bg-hover);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 12px;
}

.mobile-node-select:focus {
    outline: none;
    border-color: var(--primary);
}

.current-node-display {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    padding: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}
