:root {
  --primary: #1e40af;
  --primary-2: #2563eb;
  --primary-soft: #eff6ff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;
  --green: #16a34a; --red: #dc2626; --orange: #ea580c;
  --purple: #7c3aed; --cyan: #0891b2; --blue: #2563eb; --gray: #64748b;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.05);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--primary-2); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 15%, #dbeafe 0, transparent 45%),
              radial-gradient(circle at 85% 85%, #e0e7ff 0, transparent 45%), var(--bg); }
.login-card { width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 40px 36px; text-align: center; }
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 21px; margin: 0 0 2px; letter-spacing: .5px; }
.login-card .subtle { margin: 0 0 28px; font-size: 13px; }
.login-card .field-label { display: block; text-align: left; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.login-card .input { width: 100%; }
.login-card .btn { margin-top: 18px; height: 42px; }
.err-text { min-height: 20px; color: var(--red); font-size: 12px; text-align: left; margin-top: 6px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: 0 0 236px; background: #0f1e3d; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-icon { font-size: 28px; }
.brand-name { color: #fff; font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.brand-sub { font-size: 11px; color: #7c93b8; }
.nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-group { font-size: 11px; color: #6b83aa; letter-spacing: 1px; padding: 16px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  cursor: pointer; color: #b8c7de; font-size: 13.5px; margin-bottom: 2px; transition: .15s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary-2); color: #fff; font-weight: 600; }
.nav-item .ni { font-size: 16px; width: 20px; text-align: center; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; color: #8ba2c4;
  display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); display: inline-block; }
.dot.ok { background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.18); }
.dot.bad { background: #f87171; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 68px; flex: 0 0 68px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px; }
.page-title { font-size: 17px; font-weight: 700; }
.page-desc { font-size: 12px; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.stamp { font-size: 12px; color: var(--subtle); margin-right: 6px; }
.content { padding: 22px 26px 40px; flex: 1; }

/* ---------- 通用组件 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); } .subtle { color: var(--subtle); }
.small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--primary-2); color: var(--primary-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: var(--red); color: var(--red); }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; display: block; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

.input, .select, textarea.input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  background: #fff; color: var(--text); outline: none; transition: .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.input { resize: vertical; min-height: 76px; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field-hint { font-size: 11px; color: var(--subtle); margin-top: 4px; }
.req { color: var(--red); margin-left: 2px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: #f1f5f9; color: var(--muted); white-space: nowrap; }
.tag-green { background: #dcfce7; color: #15803d; } .tag-red { background: #fee2e2; color: #b91c1c; }
.tag-orange { background: #ffedd5; color: #c2410c; } .tag-blue { background: #dbeafe; color: #1d4ed8; }
.tag-purple { background: #ede9fe; color: #6d28d9; } .tag-cyan { background: #cffafe; color: #0e7490; }
.tag-gray { background: #f1f5f9; color: #64748b; }

/* ---------- 工具栏与表格 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .search { min-width: 230px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; text-align: left; padding: 11px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12px; }
td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.cell-actions { white-space: nowrap; }
.td-strong { font-weight: 600; color: var(--text); }
.td-clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 60px 20px; color: var(--subtle); }
.empty-icon { font-size: 36px; display: block; margin-bottom: 10px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px 0; font-size: 12.5px; color: var(--muted); }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary-2); }
.stat.s-red::before { background: var(--red); } .stat.s-green::before { background: var(--green); }
.stat.s-orange::before { background: var(--orange); } .stat.s-purple::before { background: var(--purple); }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 27px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat-hint { font-size: 11.5px; color: var(--subtle); margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 12.5px; }
.bar-label { width: 130px; flex: 0 0 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 9px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary-2), #60a5fa); border-radius: 999px; }
.bar-value { width: 40px; text-align: right; color: var(--muted); flex: 0 0 40px; }

.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.timeline-item:last-child { border-bottom: 0; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary-2); margin-top: 7px; flex: 0 0 8px; }

/* ---------- 弹层 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal-box { position: relative; width: min(680px, 94vw); max-height: 88vh; background: var(--surface);
  border-radius: 14px; box-shadow: 0 20px 60px rgba(15,23,42,.25); display: flex; flex-direction: column; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.detail-grid { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; font-size: 13px; }
.detail-grid dt { color: var(--muted); } .detail-grid dd { margin: 0; word-break: break-all; }
.qr-box { text-align: center; padding: 10px; }
.qr-box svg { border: 1px solid var(--border); border-radius: 8px; }
.code-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; margin-top: 12px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(15,23,42,.25); }
.toast.err { background: var(--red); }

.notice { background: var(--primary-soft); border: 1px solid #bfdbfe; border-radius: 10px; padding: 12px 16px;
  font-size: 12.5px; color: #1e3a8a; }
.kv-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 10px; }
.kv { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; }
.kv b { display: block; font-size: 18px; margin-top: 2px; }
