:root {
  --bg: #f4f5fb;
  --panel: #ffffff;
  --ink: #1f2433;
  --muted: #8a90a6;
  --line: #e7e9f3;
  --pri: #6d5efc;
  --pri2: #9b6dff;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef5350;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(80, 70, 160, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
input, select, textarea, button { font-family: inherit; font-size: 14px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); }
textarea { resize: vertical; min-height: 64px; }
.btn {
  border: none; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600;
  background: #eef0f8; color: var(--ink); transition: transform .05s, filter .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--pri), var(--pri2)); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.msg { margin-top: 8px; font-size: 13px; }
.msg.inline { margin: 0 0 0 10px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }
code { background: #f0f1f8; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 70% -10%, #e9e3ff 0%, transparent 60%), var(--bg); }
.login-card { width: 340px; background: var(--panel); border-radius: var(--radius); padding: 34px 28px;
  box-shadow: var(--shadow); text-align: center; }
.login-logo { font-size: 30px; font-weight: 800; letter-spacing: 1px; }
.login-sub { color: var(--muted); margin: 6px 0 22px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

/* 布局 */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: #1c1e2e; color: #cfd2e6; padding: 20px 14px; display: flex; flex-direction: column; }
.brand { font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 26px; }
.brand span { display: block; font-size: 12px; color: #8b8fb0; font-weight: 500; margin-top: 2px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { padding: 11px 14px; border-radius: 10px; color: #b9bcd6; cursor: pointer; font-weight: 600; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--pri), var(--pri2)); color: #fff; }
.side-foot { color: #6a6e8c; font-size: 12px; margin-top: 16px; }
.main { padding: 22px 26px; overflow: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.title { font-size: 20px; font-weight: 800; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); }

/* 卡片 */
.card { background: var(--panel); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h3 { margin: 0 0 14px; font-size: 15.5px; }
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-row > * { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); padding-left: 2px; }
.tips { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.9; }
.tips code { color: var(--pri); }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 800; background: linear-gradient(135deg, var(--pri), var(--pri2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .l { color: var(--muted); margin-top: 4px; font-size: 13px; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl tr:hover td { background: #fafaff; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag.unused { background: #eef2ff; color: #4f46e5; }
.tag.used { background: #e7f8f1; color: #047857; }
.tag.disabled { background: #fdeaea; color: #b91c1c; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 发卡结果 */
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.result-head h3 { margin: 0; }
.codes { background: #1c1e2e; color: #d6dbff; padding: 16px; border-radius: 10px; max-height: 340px; overflow: auto;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.8; white-space: pre-wrap; word-break: break-all; }

/* toast */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c1e2e; color: #fff; padding: 12px 20px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 99; font-size: 13.5px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }

/* 修改密码弹窗 */
.modal { position: fixed; inset: 0; background: rgba(20, 22, 40, .5); display: flex;
  align-items: center; justify-content: center; z-index: 200; }
.modal[hidden] { display: none; }
/* 全局：保证 hidden 属性对任何带 display 的容器都生效（避免被 .app/.login-wrap/.view 的 display 覆盖） */
[hidden] { display: none !important; }
.modal-card { width: 360px; background: var(--panel); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.modal-card h3 { margin: 0 0 4px; font-size: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
