* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6fb; --card: #fff; --ink: #1f2733; --muted: #7a8699; --line: #e6ebf3;
  --primary: #5b78e8; --primary-d: #4763cf; --ok: #16a34a; --warn: #f59e0b; --danger: #e5484d;
}
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 9px 16px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--danger); }
.btn.ghost { width: 100%; background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 12px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a2340, #2a3a6a); }
.login-card { width: 380px; background: #fff; border-radius: 16px; padding: 40px 36px; box-shadow: 0 24px 60px rgba(0,0,0,.3); text-align: center; }
.login-logo { width: 56px; height: 56px; margin: 0 auto 14px; background: var(--primary); color: #fff; border-radius: 16px; font-size: 30px; display: flex; align-items: center; justify-content: center; }
.login-card h1 { font-size: 21px; font-weight: 600; }
.login-sub { color: var(--muted); margin: 4px 0 24px; font-size: 13px; }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; outline: none; }
.login-card input:focus { border-color: var(--primary); }
.login-card .btn { width: 100%; margin-top: 14px; padding: 12px; }
.login-err { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 18px; }
.login-hint { color: var(--muted); font-size: 11px; margin-top: 18px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.side { width: 220px; flex-shrink: 0; background: #1e2740; color: #c9d2e3; display: flex; flex-direction: column; padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.blogo { width: 34px; height: 34px; background: var(--primary); color: #fff; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 19px; }
.brand b { color: #fff; display: block; font-size: 14px; }
.brand small { font-size: 10px; opacity: .6; }
.side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side nav button { border: 0; background: transparent; color: #aab6cd; text-align: left; padding: 11px 14px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.side nav button span { font-size: 16px; width: 20px; text-align: center; }
.side nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav button.active { background: var(--primary); color: #fff; }
.side-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.server-status { font-size: 11px; opacity: .7; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; display: inline-block; }
.content { flex: 1; padding: 32px 40px; overflow: auto; max-height: 100vh; }
.page-head h1 { font-size: 22px; font-weight: 600; }
.page-head p { color: var(--muted); margin-top: 6px; font-size: 13px; }
.card { background: var(--card); border-radius: 14px; padding: 22px 24px; margin-top: 20px; box-shadow: 0 1px 3px rgba(20,30,60,.06); }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; font-weight: 500; background: #eef2ff; color: var(--primary); padding: 2px 8px; border-radius: 99px; }

/* 统计卡 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: var(--bg); border-radius: 12px; padding: 18px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .num { font-size: 28px; font-weight: 600; margin-top: 6px; }
.stat .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.type-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.type-table th, .type-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.type-table th { color: var(--muted); font-weight: 500; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; color: #fff; }

/* 表单 */
.form-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.form-row:last-child { border-bottom: 0; }
.form-row label { width: 130px; flex-shrink: 0; color: #4b5563; }
.form-row label small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.form-row input, .form-row select, .form-row textarea { flex: 1; max-width: 360px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--primary); }
.type-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.type-opt { border: 2px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; transition: .15s; }
.type-opt:hover { border-color: var(--primary); }
.type-opt.sel { border-color: var(--primary); background: #f5f7ff; }
.type-opt .nm { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.type-opt .pr { color: var(--primary); font-size: 18px; font-weight: 600; margin: 6px 0; }
.type-opt .ds { color: var(--muted); font-size: 11px; }
.result-box { background: #0f172a; color: #a5f3d0; border-radius: 10px; padding: 16px; margin-top: 16px; font-family: Consolas, monospace; font-size: 12px; line-height: 1.9; max-height: 240px; overflow: auto; white-space: pre-wrap; display: none; }

/* 码库表格 */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar select, .toolbar input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; }
.table-wrap { overflow: auto; max-height: 60vh; }
table.codes { width: 100%; border-collapse: collapse; font-size: 12px; }
table.codes th { text-align: left; padding: 10px 8px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
table.codes td { padding: 9px 8px; border-bottom: 1px solid #f0f2f7; }
.code-txt { font-family: Consolas, monospace; font-weight: 600; }
.st { padding: 2px 8px; border-radius: 99px; font-size: 11px; }
.st.unused { background: #f1f5f9; color: #64748b; }
.st.active { background: #dcfce7; color: #15803d; }
.st.expired { background: #fef3c7; color: #b45309; }
.st.disabled { background: #fee2e2; color: #b91c1c; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.qr-box { width: 180px; height: 180px; border: 1px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--muted); background: #fff; overflow: hidden; }
.qr-box img { max-width: 100%; max-height: 100%; }

#toast { position: fixed; bottom: 28px; right: 28px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast-item { background: #1f2733; color: #fff; padding: 12px 18px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slidein .2s; }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }
