:root {
  color-scheme: dark;
  --bg: #030a07;
  --panel: rgba(11, 35, 27, 0.64);
  --panel-solid: #0b231b;
  --line: rgba(212, 175, 55, 0.16);
  --line-strong: rgba(212, 175, 55, 0.38);
  --gold: #d4af37;
  --gold-light: #f9f0d0;
  --gold-dark: #b8941f;
  --text: #f5f5f7;
  --muted: #7a9b8e;
  --green: #6abf9e;
  --red: #e87c7c;
  --amber: #e0b45c;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(26, 107, 82, 0.16), transparent 50%),
    radial-gradient(ellipse at 88% 100%, rgba(15, 74, 56, 0.22), transparent 52%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.app-shell { padding-bottom: 60px; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 10, 7, 0.72);
  backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 30;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, #1a6b52, #0f4a38);
  box-shadow: 0 3px 16px rgba(26, 107, 82, 0.4), 0 0 0 1px rgba(212, 175, 55, 0.2);
}
.topbar-logo svg { width: 24px; height: 24px; }
.topbar-brand strong {
  display: block;
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  font-size: 18px; letter-spacing: 2px; color: var(--gold-light);
}
.topbar-brand span { display: block; color: var(--muted); font-size: 10px; letter-spacing: 2px; margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.topbar-right .role { padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 10px; }

/* platform + tabs */
.platform-bar {
  display: flex; justify-content: center; gap: 4px;
  width: fit-content; margin: 20px auto 0;
  padding: 4px; border: 1px solid rgba(249, 240, 208, 0.1);
  border-radius: 999px; background: rgba(255, 255, 255, 0.04);
}
.platform-btn {
  border: 0; background: transparent; color: rgba(249, 240, 208, 0.55);
  padding: 8px 26px; border-radius: 999px; font-size: 13px; transition: all .2s ease;
}
.platform-btn:hover { color: rgba(249, 240, 208, 0.85); }
.platform-btn.active {
  background: linear-gradient(135deg, rgba(249, 240, 208, 0.16), rgba(249, 240, 208, 0.05));
  color: var(--gold);
}
.main-tabs { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 16px auto 0; padding: 0 20px; }
.tab-btn {
  border: 1px solid var(--line); background: rgba(15, 74, 56, 0.18);
  color: var(--muted); border-radius: 10px; padding: 9px 16px; font-size: 13px;
  transition: all .2s ease;
}
.tab-btn:hover { color: var(--gold-light); border-color: var(--line-strong); }
.tab-btn.active { color: var(--gold-light); border-color: var(--line-strong); background: linear-gradient(135deg, rgba(212,175,55,.14), rgba(212,175,55,.04)); }
.view-root { width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px 28px 0; }

/* section head */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 16px; }
.section-head h2 { margin: 0; font-size: 19px; letter-spacing: 1px; color: var(--gold-light); }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(15, 74, 56, 0.35);
  color: var(--gold-light);
  border-radius: 9px; padding: 9px 15px; font-size: 13px; font-weight: 600;
  text-decoration: none; transition: all .18s ease; white-space: nowrap;
}
.btn:hover { background: rgba(212, 175, 55, 0.12); border-color: var(--line-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: #1a1a1a; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { color: var(--gold-light); }
.btn.danger { color: var(--red); border-color: rgba(232, 124, 124, 0.25); background: rgba(232, 124, 124, 0.05); }
.btn.danger:hover { background: rgba(232, 124, 124, 0.12); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.icon { width: 30px; height: 30px; padding: 0; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  padding: 18px 18px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(15, 74, 56, 0.3), rgba(15, 74, 56, 0.08));
}
.stat .value { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 30px; line-height: 1.1; color: var(--gold-light); }
.stat .label { margin-top: 6px; color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.stat.green .value { color: var(--green); }
.stat.gold .value { color: var(--gold); }
.stat.red .value { color: var(--red); }

/* panels */
.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(15, 74, 56, 0.18), rgba(15, 74, 56, 0.05));
  overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid rgba(212, 175, 55, 0.08); }
.panel-head h3 { margin: 0; font-size: 14px; color: var(--gold-light); letter-spacing: .5px; }
.panel-body { padding: 16px 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

/* toolbar + forms */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(11, 35, 27, 0.55);
}
.toolbar .spacer { flex: 1; }
.input, .select, .textarea {
  width: 100%;
  background: rgba(3, 10, 7, 0.55);
  border: 1px solid rgba(212, 175, 55, 0.16);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input:focus, .select:focus, .textarea:focus { border-color: rgba(212, 175, 55, 0.5); box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.06); }
.toolbar .input { width: 240px; }
.toolbar .select { width: 140px; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; font-family: "SF Mono", Menlo, monospace; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: var(--gold-light); font-size: 12px; font-weight: 600; }
.field .hint { color: var(--muted); font-size: 11px; line-height: 1.6; }
.form-error { color: var(--red); font-size: 12px; min-height: 16px; margin: 6px 0 0; }

/* tables */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; padding: 11px 12px; white-space: nowrap;
  color: var(--gold-light); font-size: 11px; letter-spacing: .5px;
  background: rgba(212, 175, 55, 0.07); border-bottom: 1px solid var(--line);
}
table.data td { padding: 10px 12px; border-bottom: 1px solid rgba(212, 175, 55, 0.06); color: #d7e2dc; vertical-align: middle; }
table.data tbody tr:hover { background: rgba(212, 175, 55, 0.04); }
table.data tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: "SF Mono", Menlo, monospace; letter-spacing: .4px; }
.code-cell { color: var(--gold-light); font-weight: 600; cursor: pointer; }
.code-cell:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.checkbox { width: 15px; height: 15px; accent-color: var(--gold); }
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: rgba(212, 175, 55, 0.07);
  color: var(--gold-light); font-size: 12px;
}
.bulk-bar .spacer { flex: 1; }

/* badges */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge.available { color: var(--green); background: rgba(106, 191, 158, 0.1); border-color: rgba(106, 191, 158, 0.25); }
.badge.issued { color: var(--gold); background: rgba(212, 175, 55, 0.1); border-color: rgba(212, 175, 55, 0.3); }
.badge.claimed { color: #8fc7e8; background: rgba(143, 199, 232, 0.1); border-color: rgba(143, 199, 232, 0.25); }
.badge.redeemed { color: #9fd8b8; background: rgba(159, 216, 184, 0.1); border-color: rgba(159, 216, 184, 0.3); }
.badge.voided, .badge.expired { color: var(--red); background: rgba(232, 124, 124, 0.1); border-color: rgba(232, 124, 124, 0.25); }
.badge.recycled { color: var(--amber); background: rgba(224, 180, 92, 0.1); border-color: rgba(224, 180, 92, 0.25); }
.badge.active { color: var(--green); background: rgba(106, 191, 158, 0.1); border-color: rgba(106, 191, 158, 0.25); }
.badge.partially_voided { color: var(--amber); background: rgba(224, 180, 92, 0.1); border-color: rgba(224, 180, 92, 0.25); }
.badge.closed { color: var(--muted); background: rgba(122, 155, 142, 0.1); border-color: rgba(122, 155, 142, 0.2); }

/* pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 18px 0 8px; color: var(--muted); font-size: 12px; }
.pager button { border: 1px solid var(--line); background: rgba(15, 74, 56, 0.25); color: var(--gold-light); border-radius: 8px; padding: 6px 14px; font-size: 12px; }
.pager button:disabled { opacity: .35; cursor: not-allowed; }
.empty { padding: 46px 20px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; }
.empty strong { display: block; color: var(--gold-light); font-size: 15px; margin-bottom: 4px; }

/* login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; padding: 30px 28px;
  border: 1px solid var(--line); border-radius: 20px;
  background: linear-gradient(135deg, rgba(15, 74, 56, 0.35), rgba(6, 23, 18, 0.85));
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand strong { display: block; color: var(--gold-light); font-family: "Songti SC", serif; font-size: 20px; letter-spacing: 2px; }
.login-brand span { display: block; color: var(--muted); font-size: 10px; letter-spacing: 2px; margin-top: 2px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 6px; padding: 11px; }
.login-foot { text-align: center; color: var(--muted); font-size: 11px; margin-top: 18px; line-height: 1.7; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}
.modal {
  width: 100%; max-width: 620px; max-height: min(88vh, 860px);
  display: flex; flex-direction: column;
  border: 1px solid var(--line-strong); border-radius: 18px;
  background: linear-gradient(135deg, #0d3a2c, #061712);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; color: var(--gold-light); font-size: 16px; letter-spacing: 1px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; }
.modal-close:hover { color: var(--gold-light); }

/* preview */
.preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.preview-fit { width: 100%; max-width: 440px; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* misc */
.hint-box { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.hint-box strong { color: var(--gold-light); }
.link-list { display: flex; flex-direction: column; gap: 8px; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row input { flex: 1; background: rgba(3, 10, 7, 0.55); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--gold-light); font-size: 11px; font-family: "SF Mono", Menlo, monospace; }
.tabs-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.copy-mini { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 7px; padding: 5px 9px; font-size: 11px; }
.copy-mini:hover { color: var(--gold-light); border-color: var(--line-strong); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  max-width: min(86vw, 520px); padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(6, 23, 18, 0.96);
  color: var(--gold-light); font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease; z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .topbar { padding: 12px 14px; }
  .topbar-right .who { display: none; }
  .view-root { padding: 16px 14px 0; }
  .platform-btn { padding: 8px 18px; }
  .toolbar .input { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  table.data { min-width: 760px; }
  .section-head { align-items: flex-start; }
}
