:root {
    --primary-color: #2563eb;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --hover-bg: #f3f4f6;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.main-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

/* 左側信息面板 */
.info-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}


h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.refresh-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.refresh-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

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

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 連接信息卡片 */
.connection-info {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.connection-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.info-value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 15px;
}

.info-extra {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* IPv6 測試卡片 */
.ipv6-test {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.ipv6-test h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.ipv6-score {
    display: flex;
    gap: 20px;
    align-items: center;
}

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.score-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.score-label {
    font-size: 12px;
    font-weight: 500;
}

.score-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.test-name {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.test-result {
    font-size: 13px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.test-pass {
    background: rgba(5, 150, 105, 0.1);
    color: var(--success-color);
}

.test-fail {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error-color);
}

.test-partial {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning-color);
}


/* 右側測試面板 */
.test-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.test-panel h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    height: calc(100vh - 160px);
    overflow-y: auto;
    padding-right: 8px;
}


.test-grid::-webkit-scrollbar {
    width: 4px;
}

.test-grid::-webkit-scrollbar-track {
    background: transparent;
}

.test-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.plan-group {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    height: fit-content;
}

.plan-header {
    padding: 12px 16px;
    background: var(--hover-bg);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.plan-badge.free { background: #dbeafe; color: #1e40af; }
.plan-badge.pro { background: #fed7aa; color: #c2410c; }
.plan-badge.business { background: #e9d5ff; color: #7c2d12; }
.plan-badge.enterprise { background: #dcfce7; color: #166534; }

.plan-rows {
    background: var(--card-bg);
}

.test-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.15s ease;
    cursor: pointer;
    align-items: center;
}

.test-row:last-child {
    border-bottom: none;
}

.test-row:hover {
    background: var(--hover-bg);
    transform: translateX(2px);
}

.col-service {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.col-latency {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
}

.col-node {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

/* 延遲狀態顏色 */
.latency-good { 
    color: var(--success-color);
    background: rgba(5, 150, 105, 0.1);
    padding: 3px 6px;
    border-radius: 4px;
}

.latency-medium { 
    color: var(--warning-color);
    background: rgba(217, 119, 6, 0.1);
    padding: 3px 6px;
    border-radius: 4px;
}

.latency-bad { 
    color: var(--error-color);
    background: rgba(220, 38, 38, 0.1);
    padding: 3px 6px;
    border-radius: 4px;
}

.latency-testing { 
    color: var(--text-muted);
    background: var(--hover-bg);
    padding: 3px 6px;
    border-radius: 4px;
    animation: pulse 2s infinite;
}

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

/* 響應式設計 */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 350px 1fr;
        gap: 20px;
    }
    
    .test-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 768px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }
    
    .container {
        padding: 12px;
        height: auto;
        overflow: visible;
        max-width: 100%;
    }
    
    .page-header {
        margin-bottom: 16px;
        padding: 16px;
    }
    
    .page-header h1 {
        font-size: 1.3rem;
    }
    
    .refresh-btn {
        width: 36px;
        height: 36px;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
        gap: 16px;
        height: auto;
        overflow: visible;
    }
    
    .test-panel {
        order: 1;
    }
    
    .info-panel {
        order: 2;
    }
    
    .test-grid {
        height: auto;
        overflow: visible;
        grid-template-columns: 1fr;
        gap: 12px;
        max-height: none;
    }
    
    .test-row {
        grid-template-columns: 2fr 1fr 1fr;
        padding: 10px 12px;
    }
    
    .col-node {
        font-size: 11px;
        text-align: center;
    }
    
    .ipv6-score {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .score-circle {
        width: 100px;
        height: 100px;
    }
    
    .score-value {
        font-size: 28px;
    }
    
    .info-grid {
        gap: 12px;
    }
    
    .info-item {
        padding-bottom: 8px;
    }
}