:root {
    --bg: #f3f5f9; --panel: #fff; --ink: #101828; --muted: #667085; --line: #e4e7ec;
    --brand: #4f46e5; --brand-soft: #eef2ff; --ok: #067647; --ok-soft: #ecfdf3;
    --danger: #b42318; --danger-soft: #fef3f2; --warning: #b54708; --warning-soft: #fffaeb;
    --shadow: 0 12px 32px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 "Microsoft YaHei", "PingFang SC", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; padding: 24px 18px; background: #101828; color: #fff; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(135deg, #818cf8, #4f46e5); font-size: 20px; font-weight: 800; }
.brand strong { display: block; font-size: 16px; }
.brand small { color: #98a2b3; font-size: 12px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; color: #d0d5dd; }
.nav-icon { width: 20px; text-align: center; font-size: 17px; line-height: 1; }
.sidebar nav a:hover, .sidebar nav a.active { background: #1d2939; color: #fff; }
.sidebar nav a.active { box-shadow: inset 3px 0 #818cf8; }
.sidebar-foot { margin-top: auto; color: #98a2b3; font-size: 13px; }
.sidebar-foot a { color: #d0d5dd; }
.main { margin-left: 232px; width: calc(100% - 232px); padding: 28px 34px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 25px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 18px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.metric { padding: 20px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 8px; font-size: 29px; font-weight: 800; letter-spacing: -.5px; }
.metric-note { margin-top: 5px; color: var(--muted); font-size: 12px; }
.panel { padding: 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.chart-wrap { height: 280px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 12px; font-weight: 600; background: #fcfcfd; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; background: #f2f4f7; color: #475467; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.pending { background: var(--warning-soft); color: var(--warning); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #4338ca; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 9px; font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; }
.flash.success { background: var(--ok-soft); border-color: #abefc6; color: var(--ok); }
.flash.error { background: var(--danger-soft); border-color: #fecdca; color: var(--danger); }
.flash.info { background: var(--brand-soft); border-color: #c7d2fe; color: #3730a3; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); }
input, select, textarea { width: 100%; border: 1px solid #d0d5dd; border-radius: 10px; padding: 10px 12px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #818cf8; box-shadow: 0 0 0 3px #e0e7ff; }
textarea { min-height: 96px; resize: vertical; font-family: Consolas, monospace; font-size: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #e0e7ff, transparent 38%), var(--bg); }
.login-card { width: min(420px, 100%); padding: 30px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card > p { margin: 0 0 22px; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: 18px; }
.source-card { padding: 18px; margin-bottom: 12px; }
.source-head { display: flex; justify-content: space-between; gap: 12px; }
.source-title { font-weight: 700; }
.source-meta { color: var(--muted); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.kv { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
@media (max-width: 1000px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .sidebar { position: static; width: 100%; padding: 16px; } .app-shell { display: block; } .main { margin: 0; width: 100%; padding: 20px 16px 40px; } .metrics { grid-template-columns: 1fr; } .panel-head { align-items: flex-start; flex-direction: column; } }

.advanced-settings > summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.advanced-settings[open] > summary { margin-bottom: 18px; }

.sidebar { transition: width .22s ease, transform .22s ease; overflow: hidden; }
.main { transition: margin-left .22s ease, width .22s ease; }
.sidebar-toggle { position: absolute; z-index: 5; top: 19px; right: 12px; width: 30px; height: 30px; border: 0; border-radius: 8px; background: #1d2939; color: #fff; cursor: pointer; display: block; line-height: 1; }
.brand { padding-right: 34px; }
body.sidebar-collapsed .sidebar { width: 64px; padding-left: 10px; padding-right: 10px; }
body.sidebar-collapsed .brand > div,
body.sidebar-collapsed .sidebar nav { display: grid; margin-top: 46px; }
body.sidebar-collapsed .sidebar-foot { display: none; }
body.sidebar-collapsed .nav-text { display: none; }
body.sidebar-collapsed .sidebar nav a { justify-content: center; padding: 11px 0; }
body.sidebar-collapsed .brand { display: none; }
body.sidebar-collapsed .main { margin-left: 64px; width: calc(100% - 64px); }
body.sidebar-collapsed .sidebar-toggle { left: 17px; right: auto; transform: rotate(180deg); }
@media (max-width: 700px) { .sidebar { position: relative; width: 100%; } body.sidebar-collapsed .sidebar { width: 64px; } body.sidebar-collapsed .main { margin-left: 0; width: 100%; } }

select[multiple] { min-height: 180px; padding: 8px; }
.compare-table th, .compare-table td { min-width: 170px; vertical-align: top; }
.compare-table thead th:first-child, .compare-table tbody th { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 130px; }
.compare-table thead th:first-child { z-index: 3; background: #fcfcfd; }
.compare-table small { color: var(--muted); font-weight: 400; }

.toast-container { position: fixed; right: 22px; bottom: 22px; z-index: 1000; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { border: 1px solid #abefc6; background: #ecfdf3; color: #067647; border-radius: 14px; padding: 14px 16px; box-shadow: 0 16px 34px rgba(16,24,40,.16); font-weight: 600; animation: toastIn .22s ease; cursor: pointer; }
.toast small { display:block; color:#475467; font-weight:400; margin-top:3px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }


body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 20px; background: rgba(16, 24, 40, .48); }
.modal-backdrop[hidden] { display: none; }
.modal-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 20px; box-shadow: 0 24px 60px rgba(16, 24, 40, .24); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; line-height: 1; }
.modal-product { margin: 0 0 14px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
