/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 浅色主题 */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f5;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #6366f1;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    /* 深色主题 */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --accent-color: #60a5fa;
    --accent-hover: #3b82f6;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    --danger-color: #f87171;
    --info-color: #818cf8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

/* 布局 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* 头部导航 */
.header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

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

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-color), var(--info-color));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

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

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 6px;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

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

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

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* 主题切换按钮 */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 概览卡片 */
.overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 24px 0;
}

.overview-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.overview-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.overview-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.overview-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.overview-value.success {
    color: var(--success-color);
}

.overview-value.warning {
    color: var(--warning-color);
}

.overview-value.danger {
    color: var(--danger-color);
}

.overview-sub {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* 控制面板 */
.control-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

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

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

.refresh-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

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

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

/* 客户端列表 */
.client-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.client-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    border-left: 4px solid var(--success-color);
}

.client-card.offline {
    border-left-color: var(--danger-color);
    opacity: 0.7;
}

.client-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

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

.client-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.client-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-online .status-dot {
    background-color: var(--success-color);
}

.status-online {
    color: var(--success-color);
}

.status-offline .status-dot {
    background-color: var(--danger-color);
}

.status-offline {
    color: var(--danger-color);
}

.client-info {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.8;
}

.client-info-row {
    display: flex;
    justify-content: space-between;
}

.client-info-label {
    color: var(--text-tertiary);
}

/* 进度条 */
.metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

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

.metric-value {
    color: var(--text-primary);
    font-weight: 500;
}

.progress-bar {
    height: 6px;
    background-color: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-fill.cpu {
    background: linear-gradient(90deg, var(--accent-color), var(--info-color));
}

.progress-fill.memory {
    background: linear-gradient(90deg, var(--success-color), #059669);
}

.progress-fill.disk {
    background: linear-gradient(90deg, var(--warning-color), #d97706);
}

.progress-fill.high {
    background: linear-gradient(90deg, var(--danger-color), #dc2626);
}

/* 网络流量信息 */
.client-network {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.network-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.network-arrow {
    font-weight: 600;
}

.network-arrow.up {
    color: #8b5cf6;
}

.network-arrow.down {
    color: #06b6d4;
}

.network-speed {
    color: var(--text-primary);
    font-weight: 500;
}

.network-total {
    color: var(--text-tertiary);
    font-size: 0.7rem;
}

/* 详情页 */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.back-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 详情卡片网格 */
.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.detail-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.detail-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* 指标网格 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.metric-card {
    padding: 16px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.metric-card-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.metric-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-card-sub {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* 图表容器 */
.chart-container {
    position: relative;
    height: 300px;
    margin-top: 16px;
}

/* 时间段选择 */
.period-tabs {
    display: flex;
    gap: 4px;
    background-color: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.period-tab {
    padding: 6px 12px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.period-tab.active {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* 磁盘列表 */
.disk-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.disk-item {
    padding: 12px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.disk-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.disk-name {
    font-weight: 500;
    color: var(--text-primary);
}

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

/* 在线率卡片 */
.uptime-card {
    text-align: center;
}

.uptime-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--success-color);
    margin: 16px 0 8px;
}

.uptime-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.uptime-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.uptime-stat {
    padding: 12px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.uptime-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.uptime-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 加载状态 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1rem;
    margin-bottom: 8px;
}

.empty-state-sub {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .overview {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

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

    .header-inner {
        height: 56px;
    }

    .logo {
        font-size: 1.125rem;
    }

    .overview-value {
        font-size: 1.5rem;
    }

    .detail-title {
        font-size: 1.25rem;
    }

    .chart-container {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .overview {
        grid-template-columns: 1fr;
    }

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

    .control-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .control-left,
    .control-right {
        justify-content: space-between;
    }
}

/* 工具类 */
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }
.text-info { color: var(--info-color); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
