:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --blue: #2563eb;
  --blue-700: #1d4ed8;
  --blue-50: #eff6ff;
  --green: #16a34a;
  --green-50: #f0fdf4;
  --amber: #d97706;
  --amber-50: #fffbeb;
  --rose: #e11d48;
  --rose-50: #fff1f2;
  --violet: #7c3aed;
  --violet-50: #f5f3ff;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

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

button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--blue); text-decoration: none; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ── 顶栏 / 标签页 ───────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 900;
}
.brand small { display: block; font-size: 10px; font-weight: 600; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; }
.topbar-spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); background: #fbfdff; white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.dot.off { background: var(--faint); }

.tabs {
  display: flex; gap: 4px; padding: 0 24px; background: var(--card);
  border-bottom: 1px solid var(--line); overflow-x: auto;
  justify-content: center;
}
.tab {
  padding: 12px 14px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; white-space: nowrap;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

main { flex: 1; padding: 24px 28px 48px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ── 卡片 / 网格 ───────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 18px 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 13px; font-weight: 800; color: var(--ink-2); }
.card-sub { font-size: 12px; color: var(--faint); }

.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── 工具栏 / 按钮 ───────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input {
  height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); outline: none;
}
.toolbar select:focus, .toolbar input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #dbeafe; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
  background: var(--blue); color: #fff;
}
.btn:hover { background: var(--blue-700); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { background: var(--line-soft); color: var(--ink-2); }
.btn.soft { background: var(--blue-50); color: var(--blue); border-color: #bfdbfe; }
.btn.soft:hover { background: #dbeafe; }
.btn.danger { background: transparent; color: var(--rose); border-color: #fecdd3; }
.btn.danger:hover { background: var(--rose-50); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 表格 ───────────────────────────────────── */
.table-wrap { width: 100%; border: 1px solid var(--line); border-radius: 14px; overflow: auto; background: var(--card); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th {
  text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 700;
  color: var(--faint); text-transform: uppercase; letter-spacing: .06em;
  background: #fbfdff; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td .sub { display: block; font-size: 11px; color: var(--faint); margin-top: 2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid transparent; white-space: nowrap;
}
.badge.gray { background: #f8fafc; color: var(--muted); border-color: var(--line); }
.badge.blue { background: var(--blue-50); color: var(--blue); border-color: #bfdbfe; }
.badge.green { background: var(--green-50); color: var(--green); border-color: #bbf7d0; }
.badge.amber { background: var(--amber-50); color: var(--amber); border-color: #fde68a; }
.badge.rose { background: var(--rose-50); color: var(--rose); border-color: #fecdd3; }
.badge.violet { background: var(--violet-50); color: var(--violet); border-color: #ddd6fe; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 40px 16px; text-align: center; color: var(--faint); }
.empty strong { display: block; color: var(--muted); font-size: 14px; margin-bottom: 4px; }

.bar-row { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.bar-track { height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 999px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line-soft); border-radius: 12px; background: #fcfdff;
}
.list-item .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 抽屉 ───────────────────────────────────── */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .32);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 94vw);
  background: var(--card); box-shadow: -24px 0 60px rgba(15, 23, 42, .18);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  z-index: 41; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: 16px; font-weight: 800; }
.drawer-body { flex: 1; overflow: auto; padding: 20px 24px; }
.drawer-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--line); background: #fcfdff;
}
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line-soft); }

/* ── 表单 ───────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #fcfdff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #93c5fd; box-shadow: 0 0 0 3px #dbeafe; background: #fff;
}
.field textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.field .hint { font-size: 11px; color: var(--faint); margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.note { font-size: 12px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; line-height: 1.6; }
.inline-error { font-size: 13px; color: var(--rose); background: var(--rose-50); border: 1px solid #fecdd3; border-radius: 10px; padding: 9px 12px; margin-bottom: 14px; }

pre.json {
  margin: 0; padding: 14px; border-radius: 12px; background: #0f172a; color: #e2e8f0;
  font-size: 12px; line-height: 1.65; overflow: auto; max-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Toast ──────────────────────────────────── */
.toast-wrap {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .12); font-size: 13px; font-weight: 600;
  animation: drop .22s ease-out;
  background: var(--green-50); color: #166534; border: 1px solid #bbf7d0;
}
.toast.error { background: var(--rose-50); color: #9f1239; border-color: #fecdd3; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.loading { display: flex; align-items: center; justify-content: center; padding: 60px 0; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #dbeafe; border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--faint); font-weight: 600; }
.kv dd { margin: 0; color: var(--ink-2); word-break: break-all; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.metric { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fcfdff; }
.metric .k { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.metric .v { font-size: 15px; font-weight: 700; margin-top: 4px; word-break: break-all; }

/* ── 文件传输 ───────────────────────────────── */
.dropzone {
  border: 2px dashed var(--line); border-radius: 14px; background: #fcfdff;
  padding: 26px 18px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: #93c5fd; background: var(--blue-50); }
.dropzone strong { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.dropzone span { font-size: 12px; color: var(--faint); }
.dropzone .picked { margin-top: 10px; font-size: 12px; color: var(--blue); font-weight: 700; word-break: break-all; }

.progress { height: 6px; background: #f1f5f9; border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; width: 0; background: var(--blue); border-radius: 999px; transition: width .15s; }

.file-name { font-weight: 700; color: var(--ink-2); word-break: break-all; }
.file-note { font-size: 11px; color: var(--faint); margin-top: 3px; word-break: break-all; }
.file-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.upload-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.file-group { margin-bottom: 14px; }
.file-group .card-head { align-items: flex-start; }
.file-group .table-wrap { border: 0; box-shadow: none; }

@media (max-width: 720px) {
  .tabs { justify-content: flex-start; }
}

/* ── 登录页（与现有项目保持一致） ───────────── */
.login-body { min-height: 100vh; overflow: hidden; background: #0b1a3a; }
.login-bg {
  position: fixed; inset: 0; background-position: center; background-size: cover; background-repeat: no-repeat;
}
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, rgba(15, 47, 136, .28), rgba(31, 86, 214, .18) 45%, rgba(10, 31, 102, .32));
}
.login-glow { position: fixed; border-radius: 999px; filter: blur(60px); pointer-events: none; }
.login-glow-a { top: -120px; left: -120px; width: 380px; height: 380px; background: rgba(255,255,255,.14); }
.login-glow-b { bottom: -80px; left: 0; width: 480px; height: 280px; background: linear-gradient(90deg, rgba(255,255,255,.12), transparent); filter: blur(40px); }

.login-wrap {
  position: relative; z-index: 10; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px 64px;
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 16px;
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 16px 48px rgba(15, 23, 42, .16);
  padding: 28px 24px 24px;
}
.login-chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 auto 16px;
  padding: 4px 10px; border-radius: 999px; background: var(--blue-50);
  color: var(--blue); border: 1px solid #bfdbfe; font-size: 11px; font-weight: 700;
}
.login-head { text-align: center; margin-bottom: 24px; }
.login-head h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; color: #1e293b; letter-spacing: -0.02em; }
.login-head p { margin: 0; font-size: 14px; color: var(--muted); }
.login-form .field { margin-bottom: 18px; }
.login-form .field label { font-size: 14px; font-weight: 500; color: #334155; }
.login-form .field input {
  padding: 12px 16px; border-radius: 12px; background: #f8fafc; border-color: #e2e8f0;
}
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--faint); font-size: 12px; font-weight: 600; cursor: pointer;
}
.pw-toggle:hover { color: var(--ink-2); }
.login-btn { width: 100%; height: 46px; border-radius: 12px; font-size: 14px; font-weight: 600; gap: 8px; }
.login-footer {
  position: relative; z-index: 10; margin-top: 24px; text-align: center;
  color: #fff; font-size: 12px; opacity: .85;
}
.login-note { margin-top: 18px; text-align: center; font-size: 11px; color: var(--faint); line-height: 1.6; }

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  main { padding: 16px; }
  .tabs { padding: 0 10px; }
  .field-row { grid-template-columns: 1fr; }
  .login-card { padding: 24px 18px; }
}
