:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #18212b;
  --muted: #677382;
  --line: #dce2e8;
  --accent: #1677ff;
  --accent-dark: #095ec8;
  --green: #18794e;
  --green-bg: #e8f6ef;
  --red: #b42318;
  --red-bg: #fff0ee;
  --amber: #8a5a00;
  --amber-bg: #fff7df;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1080px; background: var(--bg); }
button, input { font: inherit; letter-spacing: 0; }
button, .button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.topbar {
  height: 58px;
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #111820;
  color: #fff;
}
.brand { font-weight: 700; font-size: 17px; }
.topbar nav { display: flex; gap: 24px; align-items: center; font-size: 14px; }
.topbar nav a { color: #cbd3db; }
.topbar nav a:hover { color: #fff; }
.topbar nav form { margin: 0; }
.nav-button { border: 0; color: #cbd3db; background: transparent; padding: 0; }
.nav-button:hover { color: #fff; }

.redeem-page, .login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f5;
}
.redeem-panel { width: 720px; transform: translateY(-20px); }
.login-panel { width: 400px; transform: translateY(-20px); }
.mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #18212b;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 22px;
}
.mark.small { width: 44px; height: 44px; }
.redeem-panel h1, .login-panel h1 { margin: 0 0 8px; font-size: 32px; font-weight: 700; }
.redeem-panel > p { margin: 0 0 30px; color: var(--muted); }
label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 650; color: #414d59; }
input {
  height: 46px;
  padding: 0 14px;
  border: 1px solid #cbd3db;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,119,255,.12); }
.redeem-row { display: grid; grid-template-columns: 1fr 140px; gap: 10px; }
.redeem-row input { font-family: Consolas, monospace; font-size: 16px; text-transform: uppercase; }
.primary, .secondary, .button {
  min-height: 40px;
  padding: 0 17px;
  border-radius: 6px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  font-size: 14px;
}
.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.primary:disabled { opacity: .58; cursor: wait; }
.secondary { color: #27313c; background: #fff; border-color: #cbd3db; }
.secondary:hover { background: #f6f8fa; }
.full { width: 100%; height: 46px; }
.form-message { height: 24px; padding-top: 9px; font-size: 13px; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }
.notice {
  margin-top: 42px;
  padding-top: 18px;
  border-top: 1px solid #d8dee5;
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}
.notice strong { color: #37414d; }

.stack-form { margin-top: 26px; }
.stack-form input { width: 100%; margin-bottom: 18px; }
.stack-form .primary { margin-top: 4px; }

.admin-shell { width: min(1480px, calc(100% - 72px)); margin: 34px auto 80px; }
.admin-shell.narrow { max-width: 1040px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; }
.page-heading h1 { margin: 0 0 7px; font-size: 26px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.heading-actions { display: flex; gap: 8px; }

.upload-band { border: 1px solid var(--line); background: var(--surface); padding: 18px; }
.drop-zone {
  height: 122px;
  border: 1px dashed #aeb8c3;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
  background: #fafbfc;
}
.drop-zone.dragging { border-color: var(--accent); background: #f2f7ff; }
.drop-title { font-weight: 700; margin-bottom: 7px; }
.drop-meta { color: var(--muted); font-size: 13px; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-controls { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; }
.upload-controls > span { color: var(--muted); font-size: 13px; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--surface); margin: 18px 0; }
.stat { min-height: 80px; padding: 16px 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 7px; }
.stat:last-child { border-right: 0; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 22px; }
.stat.active { box-shadow: inset 0 -3px var(--accent); }

.table-section { background: var(--surface); border: 1px solid var(--line); }
.table-tools { height: 64px; padding: 0 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.search-form { display: flex; gap: 8px; }
.search-form input { width: 330px; height: 38px; }
.search-form button { height: 38px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid #e7ebef; font-size: 13px; vertical-align: middle; }
th { height: 44px; color: #65717e; background: #f8f9fa; font-weight: 650; }
th:nth-child(1) { width: 245px; }
th:nth-child(2) { width: 260px; }
th:nth-child(3) { width: 92px; }
th:nth-child(4) { width: 152px; }
th:nth-child(5) { width: 180px; }
.actions-col { width: 190px; }
tbody tr:hover { background: #fbfcfd; }
.code-copy { border: 0; padding: 0; background: transparent; font-family: Consolas, monospace; color: #095ec8; }
.code-copy:hover { text-decoration: underline; }
.filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 650; }
.status.unused { color: var(--green); background: var(--green-bg); }
.status.used { color: #45515e; background: #edf0f2; }
.status.disabled { color: var(--red); background: var(--red-bg); }
td small { display: block; color: var(--muted); margin-top: 3px; }
.row-actions { display: flex; gap: 12px; align-items: center; }
.row-actions form { margin: 0; }
.row-actions button { border: 0; background: transparent; padding: 2px 0; color: #3c4a57; font-size: 13px; }
.row-actions button:hover { color: var(--accent); }
.row-actions .danger-text { color: var(--red); }
.empty { height: 120px; text-align: center; color: var(--muted); }
.pagination { padding: 15px; display: flex; justify-content: center; gap: 20px; color: var(--muted); font-size: 13px; }
.pagination a { color: var(--accent); }

.result-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.error-list { margin-top: 18px; padding: 20px; border: 1px solid #f2c4bf; background: var(--red-bg); }
.error-list h2 { margin: 0 0 12px; font-size: 16px; }
.error-list p { margin: 6px 0; color: var(--red); font-size: 13px; }
.flash-stack { position: fixed; top: 70px; right: 22px; z-index: 20; }
.flash { min-width: 260px; padding: 12px 15px; border: 1px solid var(--line); background: #fff; box-shadow: 0 8px 24px rgba(15,23,42,.12); font-size: 13px; }
.flash.success { border-color: #a9d7c0; color: var(--green); }
.flash.error { border-color: #efb8b1; color: var(--red); }

