:root {
    --ink: #101828;
    --muted: #667085;
    --faint: #98a2b3;
    --line: #eaecf0;
    --bg: #f6f8fb;
    --card: #ffffff;
    --brand: #4657e8;
    --brand-dark: #3546d4;
    --a: #2970e8;
    --a-soft: #eaf2ff;
    --b: #e0821a;
    --b-soft: #fff4e6;
    --ok: #12a173;
    --danger: #e5484d;
    --danger-soft: #fff0f0;
    --side: #111a33;
    --side-2: #1a2444;
    --shadow: 0 4px 20px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
svg { width: 20px; height: 20px; flex: none; }
.app { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: 244px; flex: none;
    background: linear-gradient(180deg, var(--side), var(--side-2));
    color: #c7d0e6;
    display: flex; flex-direction: column;
    padding: 24px 16px 20px;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 11px; flex: none;
    background: linear-gradient(140deg, #5b6cff, #8a5bff);
    color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(91, 108, 255, 0.4);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { color: #fff; font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: #8492b5; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-label { font-size: 11px; color: #63719a; letter-spacing: 1px; margin: 18px 12px 8px; font-weight: 600; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 11px 12px; border: none; border-radius: 10px;
    color: #b9c4de; background: transparent; font-size: 14px; cursor: pointer;
    text-decoration: none; text-align: left; transition: .15s;
}
.nav-item svg { width: 19px; height: 19px; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(99, 122, 255, 0.18); color: #fff; box-shadow: inset 3px 0 0 #6b7cff; }
.nav-count { margin-left: auto; font-style: normal; font-size: 11px; background: rgba(255,255,255,0.1); padding: 2px 8px; border-radius: 20px; color: #cfd8ee; }

.side-bottom { padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.status-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,0.04); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,0.14); }
.status-card strong { display: block; font-size: 12px; color: #e4eaf7; }
.status-card span { display: block; font-size: 11px; color: #7f8cb0; margin-top: 2px; }

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; }
.topbar {
    height: 68px; background: var(--card); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px; position: sticky; top: 0; z-index: 5;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--faint); }
.crumbs b { color: var(--line); font-weight: 400; }
.crumbs strong { color: var(--ink); font-weight: 600; }
.menu-btn { display: none; border: none; background: transparent; color: var(--ink); cursor: pointer; padding: 6px; }
.icon-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
    background: #fff; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg); color: var(--brand); }
.token-box { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 38px; color: var(--faint); }
.token-box svg { width: 17px; height: 17px; }
.token-box input { border: none; outline: none; font-size: 13px; width: 110px; color: var(--ink); background: transparent; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; flex: none;
    background: linear-gradient(140deg, #4657e8, #7d5bf0); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}

.content { padding: 30px 32px 48px; max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 38px; padding: 0 15px; border-radius: 9px; border: none;
    font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(70,87,232,0.22); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-soft-a { background: var(--a-soft); color: var(--a); }
.btn-soft-b { background: var(--b-soft); color: var(--b); }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 26px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.stat-total::before { background: #98a2b3; }
.stat-a::before { background: var(--a); }
.stat-b::before { background: var(--b); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ico { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-total .stat-ico { background: #f2f4f7; color: #667085; }
.stat-a .stat-ico { background: var(--a-soft); color: var(--a); }
.stat-b .stat-ico { background: var(--b-soft); color: var(--b); }
.stat-ico svg { width: 19px; height: 19px; }
.stat-trend { font-size: 12px; font-weight: 600; color: var(--faint); background: var(--bg); padding: 3px 9px; border-radius: 20px; }
.stat-num { font-size: 36px; font-weight: 750; line-height: 1.1; margin-top: 14px; letter-spacing: -1px; }
.stat-label { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-a { background: var(--a); }
.dot-b { background: var(--b); }

/* ---------- 分布条 ---------- */
.distribution { margin-top: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 22px; box-shadow: var(--shadow); }
.dist-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--muted); }
.dist-legend { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--muted); }
.dist-legend em { font-style: normal; font-weight: 700; color: var(--ink); }
.dist-bar { display: flex; height: 9px; border-radius: 20px; overflow: hidden; margin-top: 12px; background: #eef1f5; }
.dist-seg { height: 100%; transition: width .4s ease; }
.dist-seg-a { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.dist-seg-b { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* ---------- 列表面板 ---------- */
.panel { margin-top: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 84px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title h2 { margin: 0; font-size: 16px; font-weight: 700; }
.count-pill { font-size: 11px; font-weight: 600; color: var(--brand); background: #eef0ff; padding: 3px 10px; border-radius: 20px; }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-box { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--faint); }
.search-box svg { width: 17px; height: 17px; }
.search-box input { border: none; outline: none; font-size: 13px; width: 150px; color: var(--ink); background: transparent; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
thead th {
    text-align: left; padding: 12px 16px; background: #fafbfc;
    color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .3px;
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid #f2f4f7; vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }
.col-check { width: 46px; }
.col-id { width: 92px; }
.col-ver { width: 132px; }
.col-time { width: 132px; }
.col-op { width: 96px; text-align: right; }

.cbox { display: inline-flex; position: relative; cursor: pointer; }
.cbox input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.cbox span { width: 17px; height: 17px; border: 1.5px solid #cfd6e0; border-radius: 5px; background: #fff; display: block; transition: .15s; position: relative; }
.cbox input:checked + span { background: var(--brand); border-color: var(--brand); }
.cbox input:checked + span::after { content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.mono { font-family: "SF Mono", "Consolas", monospace; font-size: 11px; color: var(--faint); }
.id-main { display: block; color: var(--brand); font-weight: 600; }
.id-sub { display: block; margin-top: 3px; font-size: 10px; }

.app-cell { display: flex; align-items: center; gap: 11px; }
.app-ico { width: 34px; height: 34px; border-radius: 9px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; }
.app-name { font-weight: 600; color: var(--ink); }
.app-note { font-size: 11px; color: var(--faint); margin-top: 2px; }

/* 分段开关 */
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: #eef1f5; gap: 2px; }
.seg-btn {
    min-width: 42px; height: 27px; border: none; border-radius: 7px; background: transparent;
    font-size: 12px; font-weight: 700; color: var(--faint); cursor: pointer; transition: .15s;
}
.seg-btn.active-a { background: #fff; color: var(--a); box-shadow: 0 1px 4px rgba(16,24,40,.12); }
.seg-btn.active-b { background: #fff; color: var(--b); box-shadow: 0 1px 4px rgba(16,24,40,.12); }
.seg-btn:not(.active-a):not(.active-b):hover { color: var(--ink); }
.time-cell { color: var(--faint); font-size: 12px; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: .15s;
}
.mini-btn svg { width: 15px; height: 15px; }
.mini-btn:hover { background: var(--bg); color: var(--brand); }
.mini-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #ffd6d6; }

.empty { padding: 54px 20px; text-align: center; }
.empty[hidden] { display: none; }
.empty-ico { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; background: #f2f4f7; color: var(--faint); display: flex; align-items: center; justify-content: center; }
.empty-ico svg { width: 26px; height: 26px; }
.empty strong { display: block; font-size: 15px; }
.empty span { display: block; margin-top: 6px; font-size: 12px; color: var(--faint); }

.panel-foot { display: flex; align-items: center; justify-content: space-between; padding: 13px 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }
.live { display: flex; align-items: center; gap: 7px; color: var(--ok); font-weight: 600; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(18,161,115,.4); } 50% { box-shadow: 0 0 0 5px rgba(18,161,115,0); } }
.foot-tip { text-align: center; margin-top: 18px; font-size: 12px; color: var(--faint); }

/* ---------- 源码合并 ---------- */
.merge-body { padding: 20px; }
.merge-intro { margin: 0 0 20px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.merge-intro code { font-family: "SF Mono", Consolas, monospace; font-size: 12px; background: #f2f4f7; padding: 2px 6px; border-radius: 5px; color: var(--brand); }
.merge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.upload-a { border-left: 3px solid var(--a); }
.upload-b { border-left: 3px solid var(--b); }
.upload-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.upload-zone {
    display: flex; align-items: center; justify-content: center; min-height: 84px;
    border: 1.5px dashed #cfd6e0; border-radius: 10px; color: var(--faint);
    font-size: 13px; cursor: pointer; text-align: center; padding: 12px; transition: .15s;
}
.upload-zone:hover { border-color: var(--brand); color: var(--brand); background: #fafbff; }
.upload-zone input { display: none; }
.upload-zone.has-file { border-style: solid; border-color: var(--ok); color: var(--ok); background: #f2fbf7; }
.merge-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.merge-fields .field { margin-bottom: 0; }
.merge-actions { margin-top: 18px; display: flex; justify-content: flex-end; }
.builds { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.builds[hidden] { display: none; }
.builds h3 { margin: 0 0 14px; font-size: 14px; }
.build-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.build-info { flex: 1; min-width: 180px; }
.build-name { font-weight: 600; font-size: 13px; }
.build-meta { font-size: 11px; color: var(--faint); margin-top: 3px; }
.build-del { background: var(--danger-soft); color: var(--danger); }
.build-bound { margin-top: 6px; font-size: 12px; color: var(--brand); font-weight: 600; }
.build-bound span { color: var(--faint); font-weight: 400; }
@media (max-width: 640px) {
    .merge-grid, .merge-fields { grid-template-columns: 1fr; }
}

/* ---------- 登录 / 用户操作 ---------- */
.text-btn { border: none; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; padding: 8px 6px; }
.text-btn:hover { color: var(--brand); }
.login-mask {
    position: fixed; inset: 0; z-index: 60;
    background: linear-gradient(135deg, #111a33, #1a2444);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-mask[hidden] { display: none; }
.login-card {
    width: 100%; max-width: 400px; background: #fff; border-radius: 20px;
    padding: 36px; box-shadow: 0 30px 80px rgba(0,0,0,0.35);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand strong { display: block; font-size: 18px; }
.login-brand span { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }
.login-card h2 { margin: 0; font-size: 24px; }
.login-sub { margin: 6px 0 24px; color: var(--muted); font-size: 13px; }
.login-err { min-height: 20px; margin-top: -6px; color: var(--danger); font-size: 13px; }
.login-btn { width: 100%; height: 46px; margin-top: 8px; font-size: 15px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; right: 26px; bottom: 26px; z-index: 50;
    display: flex; align-items: center; gap: 11px;
    background: #101828; color: #fff; padding: 13px 18px; border-radius: 11px;
    font-size: 13px; font-weight: 500; box-shadow: 0 12px 32px rgba(16,24,40,.28);
    animation: toastIn .25s ease;
}
.toast[hidden] { display: none; }
.toast-ico { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.toast.ok .toast-ico { background: var(--ok); }
.toast.err .toast-ico { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(16,24,40,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 440px; background: #fff; border-radius: 16px; padding: 26px; box-shadow: 0 24px 64px rgba(16,24,40,.24); animation: toastIn .2s ease; }
.modal-head { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.modal-ico { width: 42px; height: 42px; border-radius: 11px; background: #eef0ff; color: var(--brand); display: flex; align-items: center; justify-content: center; flex: none; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head p { margin: 3px 0 0; font-size: 12px; color: var(--faint); }
.field { display: block; margin-bottom: 16px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
    display: block; width: 100%; margin-top: 7px; padding: 10px 13px;
    border: 1px solid var(--line); border-radius: 9px; font-size: 14px; color: var(--ink);
    outline: none; font-family: inherit; resize: vertical; transition: .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(70,87,232,.1); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
    .sidebar { position: fixed; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: flex; }
    .content { padding: 24px 20px 40px; }
    .topbar { padding: 0 20px; }
}
@media (max-width: 640px) {
    .stats { grid-template-columns: 1fr; gap: 12px; }
    .stat-num { font-size: 30px; }
    .token-box { display: none; }
    .crumbs span, .crumbs b { display: none; }
    .panel-head { align-items: stretch; }
    .search-box input { width: 100%; }
    .panel-tools .btn { flex: 1; }
    .col-time, .col-id { display: none; }
}
