:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #15171c;
  --ink-2: #5b6070;
  --ink-3: #9aa0ae;
  --line: #e6e8ee;
  --accent: #2f6bff;
  --accent-soft: #eaf0ff;
  --side: #121419;
  --side-2: #1d2027;
  --green: #1e9e63;
  --green-soft: #e6f5ec;
  --red: #d9382e;
  --red-soft: #fbeae9;
  --amber: #c9780a;
  --amber-soft: #fdf1de;
  --gray-soft: #eef0f3;
  --radius: 12px;
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.muted { color: var(--ink-3); }
.sub { color: var(--ink-2); }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--side);
}
.login-card {
  width: 380px;
  padding: 44px 40px 34px;
  background: var(--panel);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  text-align: center;
}
.login-card h1 { font-size: 20px; font-weight: 500; margin: 0 0 8px; }
.login-card .lead { margin: 0 0 26px; color: var(--ink-2); font-size: 13px; }
.login-card .btn { margin-top: 22px; width: 100%; justify-content: center; }
.login-input { height: 44px; text-align: center; }
.login-input + .login-input { margin-top: 12px; }
.login-hint { margin: 18px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.icp { margin: 14px 0 0; font-size: 11px; color: var(--ink-3); text-align: center; }
.icp a { color: var(--ink-3); }
.icp a:hover { color: var(--ink-2); }
.sidebar .icp-sm { padding: 10px 8px 0; font-size: 11px; color: #6b7180; }
.sidebar .icp-sm a { color: inherit; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 34px; height: 32px; object-fit: contain; flex: none; display: block; }
.login-logo { width: 104px; height: auto; display: block; margin: 0 auto 20px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-weight: 500; font-size: 13px; letter-spacing: 0.04em;
}
.brand .name { font-size: 15px; font-weight: 500; line-height: 1.3; }
.brand .tag { font-size: 12px; color: var(--ink-3); }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side);
  color: #d9dce4;
  padding: 24px 16px 20px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 8px 24px; }
.sidebar .brand .name { color: #fff; }
.sidebar .brand .tag { color: #7f8595; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: #b8bdca; font-size: 14px;
}
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--side-2); color: #fff; }
.nav a.active .dot { background: var(--accent); }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: #4a4f5c; }
.sidebar .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #242830; font-size: 12px; color: #7f8595; display: flex; align-items: center; justify-content: space-between; }
.sidebar .foot button { background: none; border: 0; color: #b8bdca; cursor: pointer; font-size: 12px; padding: 4px; }
.sidebar .foot button:hover { color: #fff; }

.main { padding: 32px 40px 64px; max-width: 1480px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; font-weight: 500; margin: 0; letter-spacing: 0.01em; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 卡片与统计 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.card.pad { padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; font-weight: 500; margin: 0; }
.card-head .sub { font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { padding: 20px 22px; }
.stat .label { color: var(--ink-2); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 500; line-height: 1.2; margin-top: 6px; letter-spacing: -0.01em; }
.stat .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.stat.alert .value { color: var(--red); }
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; color: var(--ink-2);
  font-size: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: #fafbfc; white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfc; }
.table tr.dirty td { background: var(--amber-soft); }
.table tr.dirty .input { border-color: #e9c48b; background: #fffdf7; }
.table .num { font-variant-numeric: tabular-nums; }
.table .code { font-family: var(--mono); font-size: 13px; }
.table .act { display: flex; gap: 6px; justify-content: flex-end; }
.table td.empty-cell { text-align: center; color: var(--ink-3); padding: 48px 16px; }

/* ---------- 标签与按钮 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; line-height: 1.6; white-space: nowrap; }
.s-green { background: var(--green-soft); color: var(--green); }
.s-blue { background: var(--accent-soft); color: var(--accent); }
.s-red { background: var(--red-soft); color: var(--red); }
.s-amber { background: var(--amber-soft); color: var(--amber); }
.s-gray { background: var(--gray-soft); color: var(--ink-2); }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 14px; font-family: var(--font);
  cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: #cfd4de; background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2559d9; border-color: #2559d9; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #f0c4c0; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 筛选与表单 ---------- */
.filters { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.input, select.input {
  height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font-size: 14px; font-family: var(--font); outline: none; min-width: 150px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.w { min-width: 240px; }
.input.sm { height: 32px; font-size: 13px; min-width: 130px; padding: 0 10px; }
textarea.input { height: auto; padding: 10px 12px; line-height: 1.7; resize: vertical; font-family: var(--mono); font-size: 13px; }
input[type="file"].input { padding: 6px 10px; height: 38px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 10px; border-radius: 6px; background: var(--gray-soft); font-size: 12px; color: var(--ink-2); }

/* ---------- 弹层 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 20, 25, 0.45);
  display: grid; place-items: center; z-index: 50; padding: 24px;
}
.modal { width: 640px; max-width: 100%; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--panel); border-radius: 14px; }
.modal.wide { width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 500; }
.modal-head .x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 4px; }
.modal-head .x:hover { color: var(--ink); }
.modal-body { padding: 22px 24px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 16px; margin-bottom: 18px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; }
.list .item.warn { border-color: #f3c7c3; background: var(--red-soft); }
.list .item.extra { border-color: #f6dcae; background: var(--amber-soft); }
.section-title { font-size: 13px; color: var(--ink-2); margin: 18px 0 10px; font-weight: 500; }

#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: var(--side); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); animation: rise 0.2s ease-out; }
.toast-msg.err { background: var(--red); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .stat-grid, .two-col, .form-grid { grid-template-columns: 1fr 1fr; }
  .main { padding: 20px; }
}
