:root {
    --bg: #060a12;
    --surface: #0e1420;
    --surface-2: #131b2c;
    --surface-3: #192236;
    --border: rgba(80, 100, 150, 0.18);
    --border-hi: rgba(100, 165, 255, 0.35);
    --text: #eaf0ff;
    --text-2: #a0b0cc;
    --text-3: #637192;
    --accent: #5e9eff;
    --cyan: #3ce4ff;
    --green: #30e8a8;
    --yellow: #ffd66b;
    --orange: #ff9f5c;
    --red: #ff6484;
    --ring-sz: 86px;
    --r-lg: 18px;
    --r-md: 14px;
    --r-sm: 10px;
}

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

/* 自定义滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 12% 8%, rgba(60, 110, 255, 0.10), transparent 32%),
        radial-gradient(circle at 88% 5%, rgba(60, 228, 255, 0.07), transparent 26%);
    overflow-x: hidden;
}

/* ── 顶栏 ─────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 10px 22px;
    background: rgba(10, 16, 28, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.topbar-main { display: flex; align-items: center; gap: 16px; flex: 1 1 auto; }
.topbar-stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.logo { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.03em; }
.logo span { color: var(--accent); }

.status-badge { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--text-2); }
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 10px rgba(255, 100, 132, 0.55);
    transition: background 0.3s, box-shadow 0.3s;
}
.status-dot.connected {
    background: var(--green);
    box-shadow: 0 0 10px rgba(48, 232, 168, 0.65);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(48, 232, 168, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(48, 232, 168, 0); }
    100% { box-shadow: 0 0 0 0 rgba(48, 232, 168, 0); }
}

.topbar-info { 
    display: flex; align-items: center; gap: 12px;
    font-size: 0.8rem; color: var(--text-3); 
}
.topbar-info b { color: var(--text-2); font-weight: 600; }
.topbar-info .sep { width: 1px; height: 12px; background: var(--border); }

.stat-pill {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.78rem;
    white-space: nowrap;
}
.stat-label { color: var(--text-3); }
.stat-num { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-pill.active .stat-num { color: var(--green); text-shadow: 0 0 8px rgba(48, 232, 168, 0.4); }
.stat-pill.warn .stat-num { color: var(--orange); text-shadow: 0 0 8px rgba(255, 159, 92, 0.4); }

/* ── 主体 ─────────────────────────────────────────── */
.shell {
    max-width: 1680px;
    margin: 0 auto;
    padding: 20px 22px 40px;
}

#no-gpu-msg {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-2);
}
.empty-title { font-size: 1.2rem; margin-bottom: 6px; color: var(--text); }
.empty-sub { font-size: 0.9rem; color: var(--text-3); }

#gpu-cards {
    display: grid;
    /* 核心响应式：最小 360px，自动填充 */
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
    gap: 16px;
}

/* ── GPU 卡片 ─────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.gpu-card {
    background: linear-gradient(160deg, rgba(22, 28, 45, 0.95), rgba(12, 16, 28, 0.95));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 16px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
    animation: fadeInUp 0.5s ease-out backwards;
}
.gpu-card:hover {
    border-color: var(--border-hi);
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 12px 40px rgba(0, 0, 0, 0.35);
}

/* 卡头 */
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.015);
}
.card-name { font-size: 0.95rem; font-weight: 700; }
.card-sub { font-size: 0.74rem; color: var(--text-3); margin-top: 2px; }
.card-badges { display: flex; gap: 6px; flex-shrink: 0; }

.badge {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 999px;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase;
}
.badge.nvidia  { background: rgba(118, 185, 0, 0.14); color: #9ce53b; border: 1px solid rgba(118, 185, 0, 0.2); }
.badge.amd     { background: rgba(255, 80, 80, 0.12); color: #ff8c8c; border: 1px solid rgba(255, 80, 80, 0.18); }
.badge.intel   { background: rgba(0, 150, 255, 0.12); color: #62c5ff; border: 1px solid rgba(0, 150, 255, 0.18); }
.badge.unknown { background: rgba(255, 255, 255, 0.06); color: var(--text-2); border: 1px solid rgba(255, 255, 255, 0.08); }

.meta-row {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 10px 18px 0;
}
.meta-chip {
    font-size: 0.7rem; color: var(--text-3);
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 999px;
}

/* 核心区：左环 + 右指标 */
.card-body {
    display: grid;
    grid-template-columns: var(--ring-sz) 1fr;
    gap: 16px;
    padding: 14px 18px;
    align-items: start;
}

/* 圆环仪表 */
.ring-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.ring-outer {
    position: relative;
    width: var(--ring-sz); height: var(--ring-sz);
}
.ring-outer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: rgba(255, 255, 255, 0.06); stroke-width: 7; }
.ring-fg   { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease, stroke 0.3s; }
.ring-text {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-pct { font-size: 1.25rem; font-weight: 800; line-height: 1; }
.ring-label { font-size: 0.65rem; color: var(--text-3); margin-top: 2px; }

/* 右侧指标 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.st {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 10px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    min-width: 0;
}
.st-label { font-size: 0.68rem; color: var(--text-3); letter-spacing: 0.04em; white-space: nowrap; }
.st-val {
    font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.st-unit { font-size: 0.72rem; font-weight: 500; color: var(--text-3); margin-left: 1px; }
.st-bar {
    height: 4px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden; margin-top: auto;
}
.st-bar-fill {
    height: 100%; border-radius: 999px;
    transition: width 0.4s ease;
}

.fill-accent { background: linear-gradient(90deg, var(--accent), var(--cyan)); box-shadow: 0 0 6px rgba(94, 158, 255, 0.4); }
.fill-green  { background: linear-gradient(90deg, #2ee6a6, #5af5ca); box-shadow: 0 0 6px rgba(46, 230, 166, 0.4); }
.fill-yellow { background: linear-gradient(90deg, #ffd56f, #ffec9c); box-shadow: 0 0 6px rgba(255, 214, 107, 0.4); }
.fill-orange { background: linear-gradient(90deg, #ff9f5a, #ffcb8d); box-shadow: 0 0 6px rgba(255, 159, 90, 0.4); }
.fill-red    { background: linear-gradient(90deg, #ff6484, #ffa0b5); box-shadow: 0 0 6px rgba(255, 100, 132, 0.4); }

/* ── 折叠区：图表 / 进程 / 扩展 ─────────────────── */
.card-expand {
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.15);
}

.expand-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 0.76rem;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    font-family: inherit;
}
.expand-toggle:hover { color: var(--text-2); background: rgba(255, 255, 255, 0.02); }
.expand-toggle .arrow {
    display: inline-block;
    transition: transform 0.25s ease;
    font-size: 0.6rem;
}
.card-expand.open .expand-toggle .arrow { transform: rotate(90deg); }

.expand-body {
    display: none;
    padding: 0 18px 16px;
}
.card-expand.open .expand-body { display: block; animation: fadeInUp 0.3s ease-out; }

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.mini-chart {
    position: relative;
    height: 86px;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: rgba(10, 16, 28, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.03);
}
.mini-chart canvas { width: 100%; height: 100%; }
.mc-label {
    position: absolute; top: 6px; left: 8px;
    font-size: 0.65rem; color: var(--text-3);
    pointer-events: none; z-index: 1;
}
.mc-val {
    position: absolute; top: 5px; right: 8px;
    font-size: 0.75rem; font-weight: 700;
    pointer-events: none; z-index: 1;
}

.proc-table {
    width: 100%; font-size: 0.78rem; border-collapse: collapse; margin-top: 8px;
}
.proc-table th, .proc-table td { padding: 6px 8px; }
.proc-table th {
    text-align: left; color: var(--text-3); font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.proc-table td { color: var(--text); border-bottom: 1px solid rgba(255, 255, 255, 0.03); }

.extras-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.extra-chip {
    font-size: 0.72rem; padding: 4px 10px; border-radius: 999px;
    background: rgba(94, 158, 255, 0.08);
    border: 1px solid rgba(94, 158, 255, 0.1);
    color: var(--text-2);
}

/* ── 移动端适配 ───────────────────────────────────────── */
@media (max-width: 640px) {
    .hide-mobile { display: none !important; }
    
    .topbar { padding: 12px 16px; }
    .topbar-main { justify-content: space-between; width: 100%; }
    .topbar-stats { 
        width: 100%; 
        justify-content: space-between; 
        padding-top: 6px;
        border-top: 1px solid rgba(255,255,255,0.05);
    }
    
    .shell { padding: 16px 12px 30px; }
    
    .card-body { 
        grid-template-columns: 1fr; 
        justify-items: center; 
        gap: 20px; 
    }
    .stats-grid { 
        width: 100%; 
        grid-template-columns: repeat(2, 1fr); 
    }
    .chart-grid { grid-template-columns: 1fr; }
}
