:root {
  --navy: #17233d;
  --navy-2: #1f2f4f;
  --navy-3: #2a3d61;
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e5e9f2;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #0f9960;
  --amber: #b45309;
  --red: #d92d20;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: var(--navy);
  color: #c9d4e6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand h1 { font-size: 16px; margin: 0; color: #fff; letter-spacing: 0.5px; }
.brand p { margin: 4px 0 0; font-size: 12px; color: #7f8db0; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c9d4e6;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: var(--navy-2); color: #fff; }
.nav-item.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 #6d9bff; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: #6d9bff; opacity: 0; }
.nav-item.active .dot { opacity: 1; }

.sidebar-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #8c9aba;
}
.sidebar-foot .who { color: #fff; font-size: 13px; margin-bottom: 2px; }
.sidebar-foot button {
  margin-top: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #c9d4e6;
  cursor: pointer;
}
.sidebar-foot button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.main { flex: 1; min-width: 0; padding: 18px 22px 40px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .sub { color: var(--muted); font-size: 12px; }

/* ---------- 表单 ---------- */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  border: 1px solid #d5dbe7;
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
textarea { min-height: 72px; resize: vertical; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.filters .actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #d5dbe7;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #b9c3d6; background: #fafbff; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #f3c1bd; }
.btn.danger:hover { background: #fff5f4; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 指标卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 650; letter-spacing: 0.5px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.accent .v { color: var(--primary); }
.stat.good .v { color: var(--green); }
.stat.warn .v { color: var(--amber); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f7f9fc; color: #475467; font-weight: 600; font-size: 12px; position: sticky; top: 0; }
tbody tr:hover { background: #fafbfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.compact { min-width: 520px; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
  background: #eef2f8;
  color: #475467;
  border: 1px solid #e1e7f0;
}
.tag.blue { background: #eaf1ff; color: #1d4ed8; border-color: #d3e0ff; }
.tag.green { background: #e9f8f0; color: var(--green); border-color: #ccebdc; }
.tag.amber { background: #fff6e6; color: var(--amber); border-color: #ffe3b3; }
.tag.red { background: #fdeceb; color: var(--red); border-color: #f8d3d0; }
.tag.gray { background: #f2f4f8; color: #667085; }
.tag.demo { background: #fff; color: #7c3aed; border: 1px dashed #c4b5fd; }

.banner {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff8ec;
  border: 1px solid #ffe0b0;
  color: #92400e;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}
.banner b { color: #7c2d12; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 40;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  padding: 18px 20px 20px;
}
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal .hint { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: #14213d;
  color: #fff;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.3);
  max-width: 320px;
}
.toast.err { background: #b42318; }
.toast.ok { background: #05795a; }

.mono { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-list { display: flex; gap: 6px; flex-wrap: wrap; }
.hidden { display: none !important; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 0; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.checks input { width: auto; }

.pw-box {
  background: #f7f9fc;
  border: 1px dashed #c7d2e4;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 13px;
}
.pw-box .line { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.pw-box .val { font-family: "JetBrains Mono", Consolas, monospace; font-weight: 600; }

/* ---------- 登录页 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #17233d 0%, #22345a 55%, #2f4670 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 30px 28px 26px;
  box-shadow: 0 24px 60px rgba(8, 15, 35, 0.35);
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn.primary { width: 100%; padding: 10px; font-size: 14px; }
.auth-foot { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.auth-foot code { background: #f2f4f8; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.auth-err { background: #fdecec; color: #b42318; border: 1px solid #f7d2cf; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 12px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex: none; }
  .nav { display: flex; gap: 6px; overflow-x: auto; padding: 10px; }
  .nav-item { width: auto; white-space: nowrap; margin: 0; }
  .nav-item .dot { display: none; }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; }
  .sidebar-foot button { width: auto; margin: 0; }
  .main { padding: 14px 14px 32px; }
  .form-grid { grid-template-columns: 1fr; }
  table { min-width: 860px; }
}
