:root {
    color-scheme: light;
    --bg: #f3f6fb;
    --bg-accent: radial-gradient(circle at top, rgba(59, 130, 246, 0.16), transparent 34%), linear-gradient(180deg, #f8fbff 0%, #eef3f9 100%);
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --border: rgba(148, 163, 184, 0.26);
    --text: #0f172a;
    --muted: #64748b;
    --shadow: 0 24px 50px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.06);
    --emerald: #10b981;
    --amber: #f59e0b;
    --red: #ef4444;
    --blue: #2563eb;
    --timeline-empty: #e2e8f0;
}

body.dark {
    color-scheme: dark;
    --bg: #020617;
    --bg-accent: radial-gradient(circle at top, rgba(14, 165, 233, 0.2), transparent 26%), linear-gradient(180deg, #020617 0%, #0f172a 100%);
    --surface: rgba(15, 23, 42, 0.82);
    --surface-strong: #111827;
    --border: rgba(148, 163, 184, 0.22);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --shadow: 0 24px 50px rgba(2, 6, 23, 0.42);
    --shadow-soft: 0 12px 30px rgba(2, 6, 23, 0.35);
    --timeline-empty: #334155;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-accent);
}

button {
    font: inherit;
}

.hidden {
    display: none !important;
}

.container {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(18px);
    background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
}

.brand {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand span {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
}

.subtitle,
.meta-text {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.theme-toggle,
.primary-button {
    border: 0;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
}

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.theme-toggle:hover,
.primary-button:hover {
    transform: translateY(-1px);
}

.theme-toggle span {
    position: absolute;
    transition: opacity 0.18s ease;
}

body.dark .theme-toggle-sun,
body:not(.dark) .theme-toggle-moon {
    opacity: 0;
}

.page-content {
    padding: 28px 0 44px;
}

.state-panel {
    min-height: 240px;
    display: grid;
    place-items: center;
    gap: 14px;
    text-align: center;
    color: var(--muted);
}

.spinner {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 4px solid rgba(148, 163, 184, 0.28);
    border-top-color: var(--blue);
    animation: spin 1s linear infinite;
}

.error-text {
    color: var(--red);
    font-weight: 600;
}

.primary-button {
    padding: 10px 18px;
    border-radius: 12px;
    background: var(--blue);
    color: #fff;
}

.content-grid {
    display: grid;
    gap: 18px;
}

.group-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.group-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.group-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tag-muted {
    background: rgba(148, 163, 184, 0.14);
    color: var(--muted);
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow-soft);
    padding: 18px;
    display: grid;
    gap: 14px;
}

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.card-name {
    margin: 0;
    font-size: 1rem;
}

.card-model {
    color: var(--muted);
    font-size: 0.78rem;
    word-break: break-all;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

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

.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.metric {
    background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
    border-radius: 16px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
}

.metric-label {
    color: var(--muted);
    font-size: 0.72rem;
}

.metric-value {
    margin-top: 4px;
    font-size: 0.95rem;
    font-weight: 700;
}

.availability {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--muted);
    font-size: 0.84rem;
}

.availability strong {
    color: var(--text);
}

.timeline {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 3px;
    min-height: 28px;
    overflow: hidden;
}

.timeline-bar {
    width: 4px;
    height: 28px;
    border-radius: 999px;
    background: var(--timeline-empty);
    flex: 0 0 auto;
}

.card-message {
    color: var(--muted);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pulse {
    animation: pulse 1.8s ease-in-out infinite;
}

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

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

@media (max-width: 720px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

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