/*
 * 配色：靛蓝主色 + 深色侧边栏。
 * 主题：<html data-theme="light|dark"> 是手动指定的，没有这个属性就跟随系统（app.js 的 applyTheme）。
 * 深色的变量写了两遍（跟随系统、手动深色），改的时候两处一起改。
 */
:root {
    color-scheme: light;
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #f2f3f9;
    --surface-3: #e7e9f3;
    --glass: rgba(15, 18, 34, .86);
    --border: #e5e7f0;
    --border-strong: #d2d6e4;
    --text: #151830;
    --muted: #646a85;
    --accent: #5458ee;
    --accent-2: #6c66f8;
    --accent-soft: #ededff;
    --accent-text: #ffffff;
    --ring: rgba(91, 91, 246, .26);
    --ok: #15803d;
    --ok-bg: #e3f6ea;
    --warn: #a15c07;
    --warn-bg: #fdf2dc;
    --bad: #d02f2f;
    --bad-bg: #fdeaea;
    --info: #2563eb;
    --info-bg: #e7efff;
    --code-bg: #f7f8fc;
    --shadow-sm: 0 1px 2px rgba(20, 24, 56, .05);
    --shadow: 0 1px 3px rgba(20, 24, 56, .06), 0 1px 2px rgba(20, 24, 56, .04);
    --shadow-md: 0 8px 20px -6px rgba(20, 24, 56, .12), 0 2px 4px rgba(20, 24, 56, .04);
    --shadow-lg: 0 20px 44px -12px rgba(20, 24, 56, .26);
    /* 侧边栏两种主题下都是深色 */
    --side-bg: #0f1222;
    --side-bg-2: #181c33;
    --side-border: #1d2238;
    --side-text: #e6e8f5;
    --side-muted: #8a90ad;
    --side-hover: rgba(255, 255, 255, .06);
    --side-active: rgba(124, 108, 255, .2);
    --brand-grad: linear-gradient(135deg, #6366f1 0%, #7c6cff 55%, #a855f7 100%);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --side: 248px;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --spring: cubic-bezier(.34, 1.4, .64, 1);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0a0c16;
        --surface: #11142a;
        --surface-2: #171b33;
        --surface-3: #20253f;
        --glass: rgba(10, 12, 22, .86);
        --border: #222743;
        --border-strong: #2f3555;
        --text: #e7e9f5;
        --muted: #8d93b0;
        --accent: #8e8fff;
        --accent-2: #a796ff;
        --accent-soft: rgba(142, 143, 255, .14);
        --accent-text: #0b0c1d;
        --ring: rgba(142, 143, 255, .32);
        --ok: #5fd49a;
        --ok-bg: rgba(95, 212, 154, .12);
        --warn: #f0b955;
        --warn-bg: rgba(240, 185, 85, .12);
        --bad: #f68a80;
        --bad-bg: rgba(246, 138, 128, .13);
        --info: #7fb0ff;
        --info-bg: rgba(127, 176, 255, .13);
        --code-bg: #0d1022;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow: 0 1px 3px rgba(0, 0, 0, .4);
        --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, .55);
        --shadow-lg: 0 20px 44px -12px rgba(0, 0, 0, .7);
        --side-bg: #0c0e1c;
        --side-bg-2: #151933;
        --side-border: #1c2140;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0c16;
    --surface: #11142a;
    --surface-2: #171b33;
    --surface-3: #20253f;
    --glass: rgba(10, 12, 22, .86);
    --border: #222743;
    --border-strong: #2f3555;
    --text: #e7e9f5;
    --muted: #8d93b0;
    --accent: #8e8fff;
    --accent-2: #a796ff;
    --accent-soft: rgba(142, 143, 255, .14);
    --accent-text: #0b0c1d;
    --ring: rgba(142, 143, 255, .32);
    --ok: #5fd49a;
    --ok-bg: rgba(95, 212, 154, .12);
    --warn: #f0b955;
    --warn-bg: rgba(240, 185, 85, .12);
    --bad: #f68a80;
    --bad-bg: rgba(246, 138, 128, .13);
    --info: #7fb0ff;
    --info-bg: rgba(127, 176, 255, .13);
    --code-bg: #0d1022;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, .55);
    --shadow-lg: 0 20px 44px -12px rgba(0, 0, 0, .7);
    --side-bg: #0c0e1c;
    --side-bg-2: #151933;
    --side-border: #1c2140;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

::selection { background: var(--ring); }

/* 细滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }

.container { max-width: 1320px; margin: 0 auto; padding: 24px 16px 56px; }

/* ---------- 图标：用 mask 画，颜色跟随文字 ---------- */
.nav a[data-route]::before, .nav-user #whoami::before, .logo::after {
    content: ""; flex: none; width: 18px; height: 18px; background: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.nav a[data-route$="/machines"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='7' rx='2'/%3E%3Crect x='3' y='13' width='18' height='7' rx='2'/%3E%3Cpath d='M7 7.5h.01M7 16.5h.01'/%3E%3C/svg%3E"); }
.nav a[data-route$="/tasks"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 1.5v4M12 18.5v4M1.5 12h4M18.5 12h4'/%3E%3C/svg%3E"); }
.nav a[data-route$="/logs"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h6'/%3E%3C/svg%3E"); }
.nav a[data-route="pool"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.6 18.5a9 9 0 1 1 14.8 0'/%3E%3Cpath d='M12 14l4-4.5'/%3E%3Ccircle cx='12' cy='14' r='1.3'/%3E%3C/svg%3E"); }
.nav a[data-route="scripts"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 8l-4 4 4 4M16 8l4 4-4 4M14 5l-4 14'/%3E%3C/svg%3E"); }
.nav a[data-route="logs"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h4l3-8 4 16 3-8h4'/%3E%3C/svg%3E"); }
.nav a[data-route="settings"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6h9M19 6h1M4 12h3M13 12h7M4 18h11M21 18h-1'/%3E%3Ccircle cx='16' cy='6' r='2.5'/%3E%3Ccircle cx='10' cy='12' r='2.5'/%3E%3Ccircle cx='18' cy='18' r='2.5'/%3E%3C/svg%3E"); }
.nav a[data-route="admin"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='8' r='3.5'/%3E%3Cpath d='M2.5 20a6.5 6.5 0 0 1 13 0M16 4.6a3.5 3.5 0 0 1 0 6.8M18.5 14.4a6.5 6.5 0 0 1 3 5.6'/%3E%3C/svg%3E"); }
.nav-user #whoami { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E"); }

/* 品牌标志：渐变底 + 显卡芯片 */
.logo {
    position: relative; display: inline-grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 10px; color: #fff;
    background: var(--brand-grad);
    box-shadow: 0 4px 14px -2px rgba(108, 102, 248, .55), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.logo::after {
    width: 60%; height: 60%;
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='6' width='12' height='12' rx='2'/%3E%3Crect x='9.5' y='9.5' width='5' height='5' rx='1'/%3E%3Cpath d='M9 2v4M15 2v4M9 18v4M15 18v4M2 9h4M2 15h4M18 9h4M18 15h4'/%3E%3C/svg%3E");
}

/* ---------- 侧边栏（桌面） ---------- */
.topbar {
    position: fixed; inset: 0 auto 0 0; z-index: 10; width: var(--side);
    display: flex; flex-direction: column; gap: 18px;
    padding: 18px 14px 14px;
    color: var(--side-text);
    background:
        radial-gradient(240px 200px at 0% 0%, rgba(108, 102, 248, .22), transparent 70%),
        var(--side-bg);
    border-right: 1px solid var(--side-border);
}
.topbar:not([hidden]) ~ .container {
    max-width: none;
    margin-left: var(--side);
    padding: 28px max(32px, calc((100% - var(--side) - 1320px) / 2)) 64px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-size: 16px; font-weight: 700; color: var(--side-text); white-space: nowrap; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-color: var(--side-border) transparent; }
.nav a {
    position: relative; display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-sm); color: var(--side-muted); white-space: nowrap; font-weight: 500;
    transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.nav a:hover { background: var(--side-hover); text-decoration: none; color: var(--side-text); }
.nav a:active { transform: scale(.98); }
.nav a.active { color: #fff; background: var(--side-active); font-weight: 600; }
.nav a.active::after {
    content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
    background: var(--brand-grad);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.platform-switch { position: relative; margin-bottom: 6px; }
.topbar .platform-btn {
    width: 100%; justify-content: flex-start; gap: 8px; padding: 8px 12px; min-height: 44px;
    background: var(--side-bg-2); border-color: var(--side-border); border-radius: var(--radius-sm);
    color: var(--side-text); box-shadow: none;
}
.topbar .platform-btn:hover { background: var(--side-hover); border-color: rgba(255, 255, 255, .12); }
.topbar .platform-btn .muted { color: var(--side-muted); }
.platform-btn b { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.platform-btn .caret { margin-left: auto; color: var(--side-muted); font-size: 11px; transition: transform .2s var(--ease); }
.platform-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.platform-menu {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
    display: grid; gap: 2px; max-height: 60vh; overflow-y: auto; padding: 6px;
    background: var(--side-bg-2); border: 1px solid var(--side-border); border-radius: var(--radius);
    box-shadow: 0 20px 44px -12px rgba(0, 0, 0, .6);
    transform-origin: top center; animation: pop .18s var(--ease);
}
.platform-menu input { margin-bottom: 4px; background: var(--side-bg); border-color: var(--side-border); color: var(--side-text); }
.nav .platform-menu a { justify-content: space-between; gap: 12px; color: var(--side-text); font-weight: 400; }
.nav .platform-menu a.current { background: var(--side-active); color: #fff; font-weight: 600; }
.nav .platform-menu a.current::after { display: none; }
.platform-menu a span { color: var(--accent-2); }
.platform-menu .empty-hint { padding: 6px 10px; color: var(--side-muted); }
.nav-sep { display: block; margin: 14px 10px 4px; color: var(--side-muted); opacity: .75; font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.nav-user {
    margin-top: auto; display: flex; gap: 6px; align-items: center;
    padding: 8px 8px 8px 12px; border-radius: var(--radius-sm); background: var(--side-bg-2); border: 1px solid var(--side-border);
    color: var(--side-muted); white-space: nowrap; font-size: 13px;
}
.nav-user #whoami { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--side-text); }
.nav-user #whoami::before { width: 16px; height: 16px; color: var(--side-muted); }
.nav-user .link { color: var(--side-muted); padding: 0 4px; }
.nav-user .link:hover { color: var(--bad); text-decoration: none; }
.nav-toggle { display: none; }

/* 主题切换：跟随系统 → 浅色 → 深色，图标表示当前模式 */
.theme-btn {
    flex: none; width: 30px; min-height: 30px; padding: 0; border: none; border-radius: 7px;
    background: none; box-shadow: none; color: var(--side-muted);
}
.theme-btn:hover { background: var(--side-hover); color: var(--side-text); }
.theme-btn::before {
    content: ""; width: 16px; height: 16px; background: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.theme-btn[data-mode="system"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='12' rx='2'/%3E%3Cpath d='M8 20h8M12 16v4'/%3E%3C/svg%3E"); }
.theme-btn[data-mode="light"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E"); }
.theme-btn[data-mode="dark"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z'/%3E%3C/svg%3E"); }

/* ---------- 顶栏（手机 / 窄屏） ---------- */
@media (max-width: 860px) {
    .topbar {
        position: sticky; inset: 0 0 auto; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0 12px;
        padding: 10px 16px; min-height: 56px; border-right: none; border-bottom: 1px solid var(--side-border);
        background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
    }
    .topbar:not([hidden]) ~ .container { margin-left: 0; padding: 20px 16px 56px; }
    .brand { padding: 0; }
    .logo { width: 30px; height: 30px; border-radius: 9px; }
    .nav-toggle {
        display: inline-flex; margin-left: auto; width: 38px; padding: 0; font-size: 16px;
        background: var(--side-bg-2); border-color: var(--side-border); color: var(--side-text); box-shadow: none;
    }
    .nav-toggle:hover { background: var(--side-hover); }
    .nav { display: none; flex-basis: 100%; flex: none; width: 100%; overflow: visible; padding: 12px 0 6px; margin: 0; }
    .nav.open { display: flex; animation: drop .24s var(--ease); }
    .nav a.active::after { display: none; }
    .nav-user { margin-top: 10px; }
    .platform-menu { position: static; margin-top: 6px; box-shadow: none; max-height: 50vh; }
    .nav-sep { margin: 12px 10px 4px; }
}

/* ---------- 页面内容 ---------- */
#app > * { animation: rise .38s var(--ease) both; }
#app > :nth-child(2) { animation-delay: .04s; }
#app > :nth-child(3) { animation-delay: .08s; }
#app > :nth-child(4) { animation-delay: .12s; }
#app > :nth-child(n+5) { animation-delay: .16s; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 20px; min-height: 36px; }
.page-head .spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* 卡片 */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.card-head .spacer { flex: 1; }
.card.empty { box-shadow: none; border-style: dashed; background: transparent; }
.card.empty:hover { box-shadow: none; }

.specs {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 18px;
    margin-bottom: 14px; padding: 12px 16px; border-radius: var(--radius);
    background: var(--surface-2); font-variant-numeric: tabular-nums;
}
.specs > div { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.specs > div > span { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }

/* 选项卡：胶囊样式 */
.tabs {
    display: flex; gap: 4px; width: fit-content; max-width: 100%; margin-bottom: 18px; padding: 4px; overflow-x: auto;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.tabs button {
    border: none; border-radius: var(--radius-sm); background: none; color: var(--muted);
    padding: 6px 14px; min-height: 32px; box-shadow: none;
}
.tabs button:hover { background: none; color: var(--text); }
.tabs button.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

.log-lines { font: 12px/1.65 var(--mono); background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 0; max-height: 70vh; overflow: auto; }
.log-lines div { display: flex; gap: 12px; padding: 0 14px; white-space: pre-wrap; word-break: break-all; transition: background .12s; }
.log-lines div:hover { background: var(--surface-2); }
.log-lines .t { color: var(--muted); flex: none; }
.log-lines .m { color: var(--info); flex: none; }
.log-lines .sev-error, .log-lines .sev-critical, .log-lines .sev-alert, .log-lines .sev-emergency { color: var(--bad); }
.log-lines .sev-warning { color: var(--warn); }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px 18px; box-shadow: var(--shadow);
    transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.stat::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .0; transition: opacity .22s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat:hover::before { opacity: 1; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 650; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
@media (max-width: 520px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { padding: 12px 14px; border-radius: var(--radius); }
    .stat .value { font-size: 20px; }
    .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .card { padding: 16px; }
}

/* 表格：外面包一层横向滚动，手机上不撑开页面 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap.card { border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: .02em; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 220px; max-width: 480px; word-break: break-word; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.detail td { background: var(--surface-2); white-space: normal; animation: fade .2s var(--ease); }

/* 标签 */
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12px; line-height: 20px; font-weight: 500;
    background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle;
}
.badge.ok, .badge.warn, .badge.bad, .badge.info { padding-left: 8px; }
.badge.ok::before, .badge.warn::before, .badge.bad::before, .badge.info::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none;
}
.badge.ok::before { animation: pulse 2.4s ease-out infinite; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }

.notice {
    padding: 11px 14px; border-radius: var(--radius); margin-bottom: 12px;
    background: var(--info-bg); color: var(--info); border-left: 3px solid currentColor;
    animation: fade .25s var(--ease);
}
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.text-bad { color: var(--bad); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }

/* 按钮和表单 */
button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 500; padding: 6px 14px; min-height: 34px; border-radius: var(--radius-sm); cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .12s var(--ease), color .16s;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:active:not(:disabled), .btn:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary, .btn.primary {
    background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: var(--accent-text);
    box-shadow: 0 1px 2px var(--ring), 0 4px 12px -4px var(--ring), inset 0 1px 0 rgba(255, 255, 255, .18);
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.06); background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: 0 2px 4px var(--ring), 0 8px 18px -6px var(--ring); }
button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-bg); border-color: transparent; }
button.small, .btn.small { padding: 2px 10px; min-height: 28px; font-size: 12px; border-radius: 7px; }
button.link { border: none; background: none; padding: 0; min-height: 0; color: var(--accent); box-shadow: none; }
button.link:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.form { display: grid; gap: 16px; max-width: 720px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 500; }
.field .hint { color: var(--muted); font-size: 12px; }
input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 11px; min-height: 38px; width: 100%; min-width: 0;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
textarea { resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; line-height: 1.55; min-height: 360px; tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto; background: var(--code-bg); }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
label.check input { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); box-shadow: none; }

/* 二选一的分段按钮 */
.seg {
    display: inline-flex; gap: 2px; padding: 3px; width: fit-content; max-width: 100%;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.seg label {
    display: inline-flex; align-items: center; padding: 5px 14px; cursor: pointer; color: var(--muted); white-space: nowrap;
    border-radius: var(--radius-sm); transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.seg label:hover { color: var(--text); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.seg label:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.seg label:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--ring); }
.script-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.script-tools .spacer { flex: 1; }
.script-tools select { width: auto; max-width: 100%; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; max-width: 100%; }

pre.body {
    margin: 4px 0 12px; padding: 12px; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; max-height: 420px; overflow: auto;
}

.prices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.prices .badge { font-variant-numeric: tabular-nums; }

/* Pearl 算力：地址搜索和查询历史 */
.pool-search { display: flex; gap: 8px; }
.pool-search input { flex: 1; font-family: var(--mono); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 14px; }
.chip {
    display: inline-flex; align-items: center; max-width: 100%;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
    font: 12px/1 var(--mono); transition: border-color .16s var(--ease), background .16s var(--ease);
    animation: fade .2s var(--ease);
}
.chip:hover { border-color: var(--border-strong); }
.chip.current { border-color: var(--accent); background: var(--accent-soft); }
.chip a { padding: 6px 4px 6px 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip a:hover { text-decoration: none; color: var(--accent); }
.chip .chip-x {
    min-height: 0; width: 22px; height: 22px; padding: 0; margin-right: 3px; border: none; border-radius: 50%;
    background: none; box-shadow: none; color: var(--muted); font-size: 14px;
}
.chip .chip-x:hover { background: var(--bad-bg); color: var(--bad); }
.filter-input { width: 200px; max-width: 100%; min-height: 32px; padding: 4px 10px; }
.card-head select { width: auto; max-width: 100%; min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
#gpuFilter { width: 250px; }
@media (max-width: 520px) {
    .filter-input, #gpuFilter { width: 100%; }
    .card-head select { flex: 1; }
}

/* Pearl 算力：行情和走势图 */
.up { color: var(--ok); }
.down { color: var(--bad); }
.tabs.compact { margin-bottom: 0; padding: 3px; }
.tabs.compact button { padding: 4px 12px; min-height: 28px; font-size: 13px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 28px; }
.charts > div { min-width: 0; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.chart { position: relative; min-height: 190px; }
.chart .empty { padding: 70px 0; }
.chart svg { display: block; overflow: visible; touch-action: pan-y; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart [hidden] { display: none; }
.chart-tip {
    position: absolute; pointer-events: none; padding: 6px 10px; white-space: nowrap;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
    font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums;
}

/* ---------- 登录页 ---------- */
body:has(.auth-box) {
    background:
        radial-gradient(600px 400px at 15% 0%, var(--accent-soft), transparent 70%),
        radial-gradient(500px 360px at 90% 100%, var(--info-bg), transparent 70%),
        var(--bg);
    min-height: 100vh;
}
.auth-box { max-width: 400px; margin: 10vh auto 0; }
.auth-brand { display: grid; justify-items: center; gap: 6px; text-align: center; }
.auth-brand .logo { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 10px; animation: float 5s ease-in-out infinite; }
.auth-brand h1 { font-size: 26px; letter-spacing: .04em; }
.auth-box .card { margin-top: 26px; padding: 26px; box-shadow: var(--shadow-lg); border-radius: 20px; }
.auth-box .card:hover { box-shadow: var(--shadow-lg); }
.auth-box button.primary { min-height: 40px; margin-top: 4px; }
.auth-switch { margin-top: 16px; text-align: center; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.empty.loading { display: flex; align-items: center; justify-content: center; gap: 10px; }
.empty.loading::before {
    content: ""; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }

.toast {
    position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translateX(-50%) translateY(24px) scale(.96);
    max-width: calc(100% - 32px); padding: 11px 18px; border-radius: var(--radius);
    background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none; transition: opacity .22s var(--ease), transform .32s var(--spring);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--bad); color: #fff; }

.progress { display: inline-block; width: 70px; height: 6px; border-radius: 999px; background: var(--surface-3); vertical-align: middle; overflow: hidden; margin: 0 6px; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s var(--ease); }

/* ---------- 动效 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 currentColor; }
    70%, 100% { box-shadow: 0 0 0 5px transparent; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
