:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #e7ebf3;
  --border-strong: #d7deea;
  --text: #1f2430;
  --text-2: #4a5262;
  --muted: #838c9e;
  --primary: #3b6fe0;
  --primary-h: #2f5ec6;
  --primary-soft: #eef3ff;
  --green: #16a34a;
  --green-soft: #e9f8ef;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #d97706;
  --amber-soft: #fef5e7;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(31, 36, 48, .05);
  --shadow: 0 8px 30px rgba(31, 36, 48, .08);
  --shadow-lg: 0 20px 60px rgba(31, 36, 48, .16);
}

* { 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;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-h); }
.btn-ghost { background: #fff; color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; color: var(--red); border-color: #f3c9c9; }
.btn-danger:hover { background: var(--red-soft); }
.btn-dashed {
  width: 100%; background: #fbfcfe; border: 1px dashed var(--border-strong);
  color: var(--text-2); height: 38px;
}
.btn-dashed:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-block { width: 100%; height: 42px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: #f1f4fa; color: var(--text); }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #f7f9fd 0%, #eef3fb 60%, #e9effa 100%);
}
.login-card {
  width: 100%; max-width: 392px; background: #fff; border-radius: 18px; padding: 40px 34px 28px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); text-align: center;
}
.login-logo {
  width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 17px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.login-card h1 { font-size: 19px; margin: 0 0 8px; font-weight: 600; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
#loginForm input, .form-row input, .form-row select {
  width: 100%; height: 40px; padding: 0 13px; border: 1px solid var(--border-strong);
  border-radius: 9px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; outline: none; transition: border-color .16s, box-shadow .16s;
}
#loginForm input:focus, .form-row input:focus, .form-row select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 111, 224, .12);
}
#loginForm input { margin-bottom: 14px; }
.login-tip { font-size: 12px; color: var(--muted); margin: 18px 0 0; }
.form-error { color: var(--red); font-size: 12.5px; min-height: 18px; line-height: 18px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand-icon {
  width: 30px; height: 30px; border-radius: 9px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.topbar-actions { display: flex; gap: 8px; }

.banner {
  background: var(--amber-soft); color: #8a5300; font-size: 13px; padding: 9px 24px;
  border-bottom: 1px solid #f6e3c4;
}
.banner a { color: #8a5300; font-weight: 600; text-decoration: none; margin-left: 6px; }
.banner a:hover { text-decoration: underline; }

/* ---------------- 布局 ---------------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 24px 60px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.card-label { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.card-value { font-size: 26px; font-weight: 650; letter-spacing: -.5px; line-height: 1.1; }
.card-value.accent { color: var(--primary); }
.card-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-mini { height: 46px; display: flex; align-items: flex-end; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.panel-tools { display: flex; gap: 10px; align-items: center; }
.panel-tools input[type=search] {
  width: 250px; height: 36px; padding: 0 13px; border: 1px solid var(--border-strong);
  border-radius: 9px; font-size: 13.5px; font-family: inherit; outline: none; background: #fbfcfe;
}
.panel-tools input[type=search]:focus { border-color: var(--primary); background: #fff; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted);
  padding: 11px 20px; background: #fafbfd; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 14px 20px; border-bottom: 1px solid #f1f4f9; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafcff; }
.table-sm th, .table-sm td { padding: 8px 12px; font-size: 12.5px; }
.table-wrap.scroll { max-height: 260px; overflow-y: auto; }

.cell-name { font-weight: 550; margin-bottom: 4px; display: flex; align-items: center; gap: 7px; }
.tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px;
  background: #f1f4fa; color: var(--text-2); font-weight: 500;
}
.tag-blue { background: var(--primary-soft); color: var(--primary); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-gray { background: #f1f4fa; color: var(--muted); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.link-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--primary); cursor: pointer; word-break: break-all;
}
.link-mono:hover { text-decoration: underline; }
.cell-target { font-size: 12.5px; color: var(--text-2); word-break: break-all; line-height: 1.5; }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.num { font-variant-numeric: tabular-nums; font-weight: 500; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions button {
  border: none; background: transparent; cursor: pointer; font-size: 13px; padding: 5px 7px;
  border-radius: 7px; color: var(--muted); white-space: nowrap;
}
.row-actions button:hover { background: #f1f4fa; color: var(--primary); }
.row-actions button.del:hover { color: var(--red); background: var(--red-soft); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 36px; opacity: .5; margin-bottom: 12px; }
.empty p { margin: 0; font-size: 13.5px; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(24, 30, 42, .42); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 22px; z-index: 100;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .2s ease;
}
.modal-lg { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
  background: #fcfdfe; border-radius: 0 0 16px 16px;
}
.modal-foot > div { display: flex; gap: 9px; }

/* ---------------- 表单 ---------------- */
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-label {
  display: block; font-size: 13px; font-weight: 550; margin-bottom: 7px; color: var(--text-2);
}
.form-label .req { color: var(--red); }
.form-label .hint { font-weight: 400; color: var(--muted); font-size: 11.5px; margin-left: 5px; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; word-break: break-all; }
.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.sub-title { font-size: 13.5px; font-weight: 600; margin: 0 0 12px; }

.switch-line { display: flex; align-items: center; gap: 8px; height: 40px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.target-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 9px; }
.target-row { display: flex; gap: 8px; align-items: center; }
.target-row input[type=text] { flex: 1; }
.target-row input.w-70 { width: 74px; flex: 0 0 74px; text-align: center; }
.target-row .rm {
  width: 34px; height: 38px; flex: 0 0 34px; border: 1px solid var(--border-strong); background: #fff;
  border-radius: 9px; color: var(--muted); cursor: pointer; font-size: 14px;
}
.target-row .rm:hover { color: var(--red); border-color: #f3c9c9; background: var(--red-soft); }

/* ---------------- 二维码弹窗 ---------------- */
.qr-body { text-align: center; }
.qr-preview {
  background: #f7f9fc; border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px;
  min-width: 240px; min-height: 240px;
}
.qr-preview img { max-width: 234px; max-height: 262px; width: auto; height: auto; display: block; }
.qr-linkrow { display: flex; gap: 8px; margin-bottom: 18px; }
.qr-linkrow input {
  flex: 1; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--primary);
  background: #fbfcfe; outline: none;
}
.qr-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
.opt label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.opt-colors { grid-column: span 2; }
.seg { display: flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.seg button {
  flex: 1; height: 34px; border: none; background: #fff; cursor: pointer; font-size: 12.5px;
  font-family: inherit; color: var(--text-2); border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: #f7f9fd; }
.seg button.on { background: var(--primary); color: #fff; font-weight: 500; }
.colors { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.colors input[type=color] {
  width: 40px; height: 34px; padding: 2px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); margin: 0; cursor: pointer; }

/* ---------------- 统计弹窗 ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-box {
  background: #fafbfd; border: 1px solid var(--border); border-radius: 11px; padding: 14px; text-align: center;
}
.stat-box span { display: block; font-size: 22px; font-weight: 650; color: var(--text); }
.stat-box em { font-style: normal; font-size: 12px; color: var(--muted); }
.chart-box { background: #fafbfd; border: 1px solid var(--border); border-radius: 11px; padding: 14px; margin-bottom: 18px; }
.chart-box canvas { width: 100%; display: block; }
.dist-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; margin-bottom: 20px; }
.dist-item { display: flex; align-items: center; gap: 10px; height: 26px; font-size: 12.5px; }
.dist-name { width: 74px; color: var(--text-2); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-bar { flex: 1; height: 7px; background: #eef1f7; border-radius: 4px; overflow: hidden; }
.dist-bar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.dist-num { width: 46px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); z-index: 200; animation: pop .18s ease;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

/* ---------------- 多选工具条 ---------------- */
.selbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--primary-soft); border-bottom: 1px solid #dbe6fb;
  font-size: 13px; color: var(--primary); flex-wrap: wrap;
}
.selbar b { font-weight: 600; }
.selbar-actions { display: flex; gap: 8px; }
.selbar .btn { height: 32px; font-size: 13px; padding: 0 13px; }
.c-check { width: 40px; padding-right: 0 !important; }
.c-check input { margin: 0; vertical-align: middle; display: block; }
tr.row-sel { background: #f7faff !important; }
tr.row-sel:hover { background: #f1f6ff !important; }

.serial {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; font-weight: 600; color: var(--text);
  background: #f1f4fa; padding: 2px 8px; border-radius: 6px; display: inline-block;
  word-break: break-all;
}

/* ---------------- 分段选择（宽） ---------------- */
.seg-wide button { height: 38px; font-size: 13px; }

/* ---------------- 文本域 ---------------- */
textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: 9px;
  font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text); background: #fbfcfe; outline: none; resize: vertical; line-height: 1.7;
}
textarea:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(59, 111, 224, .12); }

/* ---------------- 批量生成预览 ---------------- */
.batch-preview {
  background: #f7f9fc; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.9;
}
.batch-preview .k { color: var(--muted); }
.batch-preview code {
  font-family: ui-monospace, Menlo, Consolas, monospace; background: #fff;
  padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); color: var(--primary);
}
.batch-preview .warn { color: var(--amber); }

/* ---------------- 下载进度 ---------------- */
.progress { margin-top: 6px; }
.progress-bar { height: 7px; background: #eef1f7; border-radius: 4px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 4px; transition: width .15s ease; }
.progress-text { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------------- 编号选项行 ---------------- */
.label-opts { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.label-opts select {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text); background: #fff; outline: none; cursor: pointer;
}
.label-opts select:focus { border-color: var(--primary); }
.flex1 { flex: 1; min-width: 140px; }
.colors .flex1 {
  height: 34px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 13px; font-family: inherit; outline: none;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .dist-grid { grid-template-columns: 1fr; }
  .qr-opts { grid-template-columns: 1fr; }
  .opt-colors { grid-column: span 1; }
}
@media (max-width: 640px) {
  .container { padding: 16px 14px 50px; }
  .topbar { padding: 0 14px; }
  .panel-tools { width: 100%; }
  .panel-tools input[type=search] { flex: 1; width: auto; }
  .stat-row { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px 14px; }
}
