* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6fb; color: #1f2430; -webkit-font-smoothing: antialiased; }

button { font-family: inherit; }
input, select { font-family: inherit; }

/* ============ 登录层 ============ */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ff8a65 0%, #ff5e7e 100%); z-index: 999; }
.login-card { width: 340px; background: #fff; border-radius: 18px; padding: 38px 30px;
  box-shadow: 0 20px 60px rgba(255,94,126,.28); text-align: center; }
.login-logo { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #ff8a65, #ff5e7e); color: #fff; font-weight: 800; font-size: 24px;
  display: flex; align-items: center; justify-content: center; letter-spacing: 1px; }
.login-card h1 { font-size: 19px; margin: 0 0 6px; color: #222; }
.login-sub { font-size: 13px; color: #999; margin: 0 0 22px; }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid #e6e8ef; border-radius: 10px;
  font-size: 14px; margin-bottom: 14px; outline: none; }
.login-card input:focus { border-color: #ff6b5e; }
.login-card button { width: 100%; padding: 12px; border: none; border-radius: 10px; font-size: 15px;
  font-weight: 600; color: #fff; background: linear-gradient(135deg, #ff8a65, #ff5e7e); cursor: pointer; }
.login-card button:hover { opacity: .92; }
.login-err { color: #ff5e7e; font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.login-foot { display: block; margin-top: 18px; font-size: 12px; color: #ff6b5e; text-decoration: none; }

/* ============ 后台布局 ============ */
.admin { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: linear-gradient(180deg, #ff7a6c 0%, #ff5e7e 100%);
  color: #fff; padding: 22px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 24px; padding: 0 6px; }
.brand-mark { background: rgba(255,255,255,.22); border-radius: 8px; padding: 4px 8px; font-size: 14px; letter-spacing: 1px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav .tab { border: none; background: transparent; color: rgba(255,255,255,.85); text-align: left;
  padding: 12px 14px; border-radius: 10px; font-size: 14px; cursor: pointer; transition: .15s; }
.nav .tab:hover { background: rgba(255,255,255,.14); color: #fff; }
.nav .tab.active { background: #fff; color: #ff5e7e; font-weight: 600; }
.side-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.2); }
.side-link { color: rgba(255,255,255,.85); font-size: 13px; text-decoration: none; }
.logout { border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff; padding: 8px;
  border-radius: 8px; font-size: 13px; cursor: pointer; }
.logout:hover { background: rgba(255,255,255,.14); }

.content { flex: 1; min-width: 0; }
.topbar { height: 60px; background: #fff; box-shadow: 0 1px 0 #eceef4; display: flex;
  align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 10; }
.page-title { font-size: 17px; font-weight: 600; }
.top-user { font-size: 13px; color: #888; display: flex; align-items: center; gap: 6px; }
.top-user .dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; }

main { padding: 22px 24px; }
.panel { display: none; }
.panel.active { display: block; }

.card { background: #fff; border-radius: 14px; padding: 20px; box-shadow: 0 2px 12px rgba(31,36,48,.05); }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.card h2.sub { margin-top: 22px; padding-top: 16px; border-top: 1px dashed #f0d6cf; }
.card h3 { font-size: 14px; color: #555; margin: 18px 0 10px; }

/* 指标卡 */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { border-radius: 14px; padding: 18px; color: #fff; position: relative; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.stat .num { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat .label { font-size: 13px; opacity: .92; margin-top: 6px; }
.stat .ic { position: absolute; right: 14px; top: 14px; font-size: 22px; opacity: .85; }
.stat.c1 { background: linear-gradient(135deg, #ff8a65, #ff5e7e); }
.stat.c2 { background: linear-gradient(135deg, #36d1dc, #1c9ec4); }
.stat.c3 { background: linear-gradient(135deg, #5b86ff, #3f5fe0); }
.stat.c4 { background: linear-gradient(135deg, #a974ff, #7c4dff); }

.doc { font-size: 13px; color: #666; line-height: 1.9; padding-left: 18px; margin: 0; }
.doc b { color: #333; }

/* 表单与通用 */
.hint { font-size: 13px; color: #888; margin: 8px 0 14px; line-height: 1.6; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.row.col { flex-direction: column; align-items: stretch; }
input, select { padding: 10px 12px; border: 1px solid #e6e8ef; border-radius: 9px; font-size: 14px;
  flex: 1; min-width: 130px; outline: none; background: #fff; }
input:focus, select:focus { border-color: #ff6b5e; }
button { padding: 10px 18px; border: none; background: linear-gradient(135deg, #ff8a65, #ff5e7e);
  color: #fff; border-radius: 9px; font-size: 14px; cursor: pointer; }
button:hover { opacity: .92; }
button.ghost { background: #fff; color: #ff5e7e; border: 1px solid #ffd0d8; }
button.ghost:hover { background: #fff3f5; }

.list { margin-top: 12px; }
.item { background: #fafbff; border: 1px solid #eef0f6; border-radius: 10px; padding: 11px 14px;
  margin-bottom: 8px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.item button { padding: 6px 14px; font-size: 12px; }
.empty { color: #aaa; font-size: 14px; text-align: center; padding: 22px; }

.cat-tabs { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.cat-tabs .cat { background: #f3f4fa; color: #555; border: 1px solid #e6e8f0; border-radius: 999px;
  padding: 7px 16px; font-size: 13px; cursor: pointer; }
.cat-tabs .cat span { font-weight: 700; margin-left: 2px; }
.cat-tabs .cat.active { background: #ff5e7e; color: #fff; border-color: #ff5e7e; }
.qr-item { background: #fafbff; border: 1px solid #eef0f6; border-radius: 10px; padding: 11px 14px;
  margin-bottom: 8px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.qr-item .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .5px; }
.qr-item .meta { color: #888; font-size: 12px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.unbound { background: #fff0e6; color: #ff7a18; }
.badge.bound { background: #e6f7ed; color: #18a058; }
.qr-item .right { display: flex; align-items: center; gap: 8px; }
.result { background: #1e1e2e; color: #9cdcfe; padding: 14px; border-radius: 10px; font-size: 12px;
  max-height: 340px; overflow: auto; white-space: pre-wrap; margin-top: 12px; }
.tag { background: #ff9800; color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 6px; }

.qr-box { margin-top: 14px; }
.qr img { width: 240px; height: 240px; border: 1px solid #eee; border-radius: 10px; }
.kv { font-size: 13px; color: #666; margin: 6px 0; }
.kv a { color: #ff5e7e; }

/* 批量预生成网格 */
.qr-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; }
.qr-card { width: 210px; border: 1px solid #eef0f6; border-radius: 12px; padding: 14px; text-align: center; background: #fff; }
.qr-card img { width: 176px; height: 176px; }
.qr-code { font-family: monospace; font-size: 18px; font-weight: 700; letter-spacing: 1px; margin-top: 8px; }
.qr-label { font-size: 13px; color: #888; margin-top: 4px; }

/* 打印：仅输出二维码卡片 */
@media print {
  .sidebar, .topbar, .row, .hint, .stat-cards, .result, .card h2, .card h3, .doc, #preSummary, #btnPrint, .login-wrap, .cat-tabs, #qrList { display: none !important; }
  body { background: #fff; }
  .admin { display: block; }
  .content { margin: 0; }
  main { padding: 0; }
  .panel.active { background: #fff; }
  .card { border: none; box-shadow: none; padding: 0; }
  .qr-grid { display: flex; flex-wrap: wrap; gap: 12px; }
  .qr-card { border: 1px dashed #ccc; break-inside: avoid; }
}

/* 响应式 */
@media (max-width: 880px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 180px; }
}
