:root {
  --bg: #f4f6fa;
  --paper: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6eaf0;
  --line-strong: #d0d7e2;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --err: #dc2626;
  --err-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --side: #0b1220;
  --side-text: #94a3b8;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
button, input, textarea, select { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  flex: 0 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
}
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn.secondary:hover { background: #f8fafc; }
.btn.ghost {
  background: transparent;
  color: var(--side-text);
  padding-inline: 8px;
}
.btn.ghost:hover { color: #fff; background: rgba(255,255,255,0.06); }
.btn.danger {
  background: #fff;
  color: var(--err);
  border: 1px solid #fecaca;
}
.btn.danger:hover { background: var(--err-soft); }
.btn.small { padding: 6px 10px; font-size: 12px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}
.row { display: flex; gap: 8px; }
input[type="text"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.65; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.code-input {
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  white-space: nowrap;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.muted { background: #f1f5f9; color: var(--muted); }
.badge.err { background: var(--err-soft); color: var(--err); }

.flash {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}
.flash.err { display: block; background: var(--err-soft); color: var(--err); }
.flash.ok { display: block; background: var(--ok-soft); color: var(--ok); }

.sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.sheet-block { padding: 22px 24px; }
.sheet-block + .sheet-block,
.sheet-grid + .sheet-foot,
.sheet-block + .sheet-grid,
.sheet-block + .sheet-foot {
  border-top: 1px solid var(--line);
}
.sheet-block h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}
.sheet-block .hint { margin: 0 0 16px; }
.sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
}
.sheet-grid > .sheet-block { min-width: 0; }
.sheet-grid > .sheet-block + .sheet-block { border-top: 0; border-left: 1px solid var(--line); }
.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
}
.form-grid { display: grid; gap: 16px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 132px;
  border: 1px dashed #c5cedb;
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  color: var(--muted);
}
.dropzone-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.dropzone-title { color: var(--ink); font-weight: 650; font-size: 14px; }
.dropzone-sub { font-size: 12px; }
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.file-list { display: grid; gap: 8px; margin-top: 12px; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.file-item > div { min-width: 0; overflow: hidden; }
.file-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size { color: var(--muted); font-size: 12px; margin-top: 2px; }
.file-item .tag {
  font-size: 11px;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
}

.count-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.stepper button {
  width: 36px;
  border: 0;
  background: #f8fafc;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.stepper button:hover { background: #eef2f7; }
.stepper input {
  width: 64px;
  border: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 0;
  outline: none;
  background: #fff;
  color: var(--ink);
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.codes-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  font-size: 13px;
  margin-top: 12px;
}
.codes-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi span { color: var(--muted); font-size: 12px; }
.kpi b { display: block; font-size: 22px; margin-top: 4px; letter-spacing: -0.03em; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.eyebrow {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  background: #fafbfc;
  font-size: 12px;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: #f8fafc; }
.code { font-family: var(--mono); letter-spacing: 0.02em; }
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.filters input, .filters select { width: auto; min-width: 160px; }
.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.empty {
  color: var(--muted);
  padding: 36px 16px;
  text-align: center;
  font-size: 13px;
}
.warn-banner {
  background: var(--warn-soft);
  color: #92400e;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid #fde68a;
}
.hidden { display: none !important; }
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  display: none;
  z-index: 20;
  font-size: 13px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.side {
  background: var(--side);
  color: #e2e8f0;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}
.side .brand { color: #fff; margin: 4px 8px 28px; }
.nav { display: grid; gap: 4px; }
.nav a {
  color: var(--side-text);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 550;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.side-foot {
  margin-top: auto;
  padding: 12px 8px 4px;
  color: var(--side-text);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.main { padding: 28px 32px 40px; min-width: 0; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 0%, rgba(37, 99, 235, 0.12), transparent 34%),
    var(--bg);
}
.login-card { width: min(400px, 100%); padding: 28px; }
.login-card h1 { margin: 12px 0 6px; font-size: 22px; letter-spacing: -0.03em; }
.login-card .hint { margin-bottom: 18px; }

.wrap {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
}
.is-redeem { background: #f7f8fb; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 8px;
}
.hero { margin: 36px auto 20px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 36px);
  letter-spacing: -0.04em;
}
.hero p { margin: 0; color: var(--muted); line-height: 1.7; }
.redeem-box { padding: 20px; margin-bottom: 20px; }
.result { display: none; padding: 22px; margin-bottom: 40px; }
.result.show { display: block; }
.result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.result h2 { margin: 0 0 6px; font-size: 20px; }
.desc { color: var(--muted); line-height: 1.7; margin: 0 0 16px; }
.content-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  min-height: 72px;
}
.content-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.footer {
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  padding: 8px 0 28px;
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
  .side .brand { margin: 0; }
  .nav { display: flex; flex-wrap: wrap; }
  .side-foot { margin-top: 0; }
  .sheet-grid { grid-template-columns: 1fr; }
  .sheet-grid > .sheet-block + .sheet-block { border-left: 0; border-top: 1px solid var(--line); }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .main { padding: 18px 16px 32px; }
  .row { flex-direction: column; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .sheet-foot { flex-direction: column; align-items: stretch; }
}
