/* ==========================================================
   惠印天下 · 打印券后台
   ========================================================== */

:root {
  --red: #F0321A;
  --red-deep: #D1230C;
  --bg: #F6F7F9;
  --card: #fff;
  --ink: #1B1D21;
  --ink-2: #5C6270;
  --ink-3: #8E94A0;
  --line: #E8EAEE;
  --green: #12A05C;
  --amber: #C97A05;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 31, .04), 0 6px 20px rgba(20, 24, 31, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #F1F2F5;
  padding: 1px 5px;
  border-radius: 4px;
}

[hidden] { display: none !important; }

/* ---------------------------- 登录 ---------------------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(90% 50% at 50% 0%, #FFE9DC 0%, rgba(246, 247, 249, 0) 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 348px;
  padding: 28px 24px 22px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 16px 44px rgba(20, 24, 31, .10);
  text-align: center;
}

.login-logo { height: 34px; width: auto; }
.login-card h1 { margin: 14px 0 0; font-size: 18px; font-weight: 800; }
.login-sub { margin: 5px 0 20px; font-size: 12.5px; color: var(--ink-3); }
.login-err { margin: 10px 0 0; font-size: 12.5px; color: var(--red); min-height: 0; }
.login-err:empty { display: none; }

/* ---------------------------- 顶栏 ---------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 58px;
  padding: 0 22px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 26px; width: auto; }
.brand .divider { width: 1px; height: 16px; background: var(--line); }
.brand strong { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; }

/* ---------------------------- 布局 ---------------------------- */

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px 22px 48px;
}

.cols {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.sticky-card { position: sticky; top: 74px; }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .topbar { padding: 0 14px; }
  .container { padding: 14px 14px 40px; }
}

.card {
  padding: 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card, .card:not(:first-child) { margin-top: 0; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 14.5px;
  font-weight: 700;
}

.muted { font-size: 12px; font-weight: 400; color: var(--ink-3); }

/* ---------------------------- 概览 ---------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat {
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat i {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--ink-3);
}

.stat b {
  display: block;
  margin-top: 2px;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}

.stat.accent b { color: var(--red); }
.stat.green b { color: var(--green); }

.warn {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: #FFF8E8;
  border: 1px solid #F7E2B5;
  color: #8A5A00;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------------------------- 表单 ---------------------------- */

.form { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--ink-2); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.input, .textarea {
  width: 100%;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #FBFBFC;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}

.input:focus, .textarea:focus {
  background: #fff;
  border-color: #F3B9A8;
  box-shadow: 0 0 0 3px rgba(240, 50, 26, .10);
}

.textarea { resize: vertical; min-height: 84px; font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.7; }

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.check input { accent-color: var(--red); width: 15px; height: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s, transform .1s;
}

.btn:hover { background: #FAFAFB; border-color: #DDE0E6; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #F75B32, #E8270D);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(240, 50, 26, .24);
}
.btn-primary:hover { background: linear-gradient(135deg, #FA6A42, #E8270D); border-color: transparent; }

.btn-ghost { color: var(--ink-2); }
.btn-danger { color: #C4280D; border-color: #F4D5CC; background: #FFF7F5; }
.btn-danger:hover { background: #FFEFEA; border-color: #EEC0B2; }

.form-msg { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.form-msg.ok { color: var(--green); }
.form-msg.bad { color: var(--red); }

.row-inline { display: flex; align-items: center; gap: 12px; margin-top: 10px; }

.hint { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-3); line-height: 1.65; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: #8A5A00;
  background: #FFF3D6;
}

/* ---------------------------- 批次 ---------------------------- */

.batch-list { display: flex; flex-direction: column; gap: 12px; }

.empty {
  padding: 34px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
}

.batch {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  transition: border-color .16s, box-shadow .16s;
}

.batch:hover { border-color: #DDE0E6; }
.batch.open { box-shadow: 0 2px 12px rgba(20, 24, 31, .06); }

.batch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.batch-title { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-width: 0; }
.batch-title b { font-size: 14px; font-weight: 700; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  background: #F2F3F6;
  white-space: nowrap;
}

.tag.amber { color: #8A5A00; background: #FFF3D6; }
.tag.red { color: #B7230C; background: #FFEDE8; }

.batch-meta { margin-top: 6px; font-size: 12px; color: var(--ink-3); }

.progress {
  position: relative;
  height: 6px;
  margin-top: 11px;
  border-radius: 99px;
  background: #F0F1F4;
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #FF8A5C, #F0321A);
  transition: width .3s;
}

.batch-nums {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.batch-nums em { font-style: normal; font-weight: 700; color: var(--ink); }

.batch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* 券码表格 */

.detail { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }

.table-wrap {
  max-height: 440px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--ink-2);
  background: #FAFAFB;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #F3F4F7;
  color: var(--ink-2);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FCFCFD; }

td.mono, .mono {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--ink);
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
}

.state::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.state.unused { color: #B7230C; }
.state.claimed { color: var(--green); }
.state.void, .state.expired { color: var(--ink-3); }

td .link-btn {
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: #2563EB;
  background: none;
  border: 0;
  cursor: pointer;
}
td .link-btn:hover { text-decoration: underline; }

/* ---------------------------- Toast ---------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(10px);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(27, 29, 33, .92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 99;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.foot-note {
  margin: 16px 2px 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-3);
}
