:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: rgba(20, 23, 31, 0.92);
  --panel-2: #11141b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f7fb;
  --muted: #8b919d;
  --muted-2: #626875;
  --accent: #9cff38;
  --accent-2: #53f5a4;
  --accent-dark: #101b0c;
  --danger: #ff6b7d;
  --warning: #f6c659;
  --radius: 20px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.public-page {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(117, 255, 44, 0.13), transparent 34%),
    radial-gradient(circle at 5% 90%, rgba(47, 223, 171, 0.07), transparent 24%),
    #080a0f;
}

.public-page::before {
  content: "";
  position: fixed;
  inset: 0;
  opacity: .35;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.redeem-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; position: relative; }
.redeem-card {
  width: min(100%, 470px);
  padding: 46px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(26, 30, 39, .92), rgba(13, 16, 22, .96));
  box-shadow: 0 36px 100px rgba(0, 0, 0, .55), inset 0 1px rgba(255, 255, 255, .04);
  text-align: center;
  backdrop-filter: blur(18px);
}

.brand-mark { width: 54px; height: 54px; margin: 0 auto 22px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(145deg, #b8ff5b, #65eb41); box-shadow: 0 0 38px rgba(133, 255, 63, .22); transform: rotate(45deg); }
.brand-mark span { width: 22px; height: 22px; border: 3px solid #0c1307; border-left-width: 8px; border-radius: 5px; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 11px; }
.brand-mark.small span { width: 16px; height: 16px; border-width: 2px; border-left-width: 6px; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .22em; }
.redeem-card h1, .admin-login-card h1 { margin: 0; font-size: clamp(30px, 7vw, 42px); letter-spacing: -.04em; }
.intro, .admin-login-card > p { margin: 12px 0 30px; color: var(--muted); font-size: 14px; }
.redeem-form { display: grid; gap: 13px; }
.input-shell { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 17px; border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(7, 9, 13, .72); transition: border-color .2s, box-shadow .2s; }
.input-shell:focus-within { border-color: rgba(156, 255, 56, .55); box-shadow: 0 0 0 4px rgba(156, 255, 56, .07); }
.input-icon { color: var(--accent); font-size: 17px; }
.input-shell input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); letter-spacing: .05em; }
.input-shell input::placeholder { color: #5e6470; letter-spacing: 0; }
.primary-button, .invite-button {
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #0a1006;
  background: linear-gradient(120deg, var(--accent), #72ef57);
  box-shadow: 0 14px 34px rgba(125, 244, 66, .14);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s, filter .18s;
}
.primary-button:hover, .invite-button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.primary-button.compact { min-height: 45px; padding: 0 24px; width: fit-content; }
.button-loader { display: none; width: 17px; height: 17px; border: 2px solid rgba(0, 0, 0, .25); border-top-color: #071004; border-radius: 50%; animation: spin .65s linear infinite; }
.primary-button.loading .button-loader { display: block; }
.form-error { min-height: 20px; margin: 0; color: #ff8b98; font-size: 13px; }
.support-button { margin-top: 28px; border: 0; background: transparent; color: #a7acb7; cursor: pointer; font-size: 13px; transition: color .18s; }
.support-button:hover { color: var(--accent); }
.result-panel { display: grid; justify-items: center; gap: 12px; padding-top: 3px; }
.success-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(156, 255, 56, .12); border: 1px solid rgba(156, 255, 56, .28); color: var(--accent); font-size: 25px; }
.result-panel h2 { margin: 3px 0 6px; font-size: 22px; }
.result-panel p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.invite-button { width: 100%; margin-top: 8px; }
.status-line { display: flex; align-items: center; gap: 8px; margin-top: 3px; color: #aeb4bf; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 10px rgba(246, 198, 89, .7); }
.status-dot.status-succeeded { background: var(--accent-2); box-shadow: 0 0 10px rgba(83, 245, 164, .7); }
.status-dot.status-failed, .status-dot.status-ambiguous, .status-dot.status-timed_out { background: var(--danger); box-shadow: 0 0 10px rgba(255, 107, 125, .7); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translate(-50%, 24px); opacity: 0; padding: 11px 18px; border: 1px solid rgba(156, 255, 56, .22); border-radius: 999px; background: #172013; color: #dfffc0; box-shadow: 0 16px 40px rgba(0, 0, 0, .35); font-size: 13px; pointer-events: none; transition: .24s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.toast-error { color: #ffdce1; border-color: rgba(255, 107, 125, .25); background: #241317; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.admin-page { min-height: 100vh; background: #0a0c11; }
.admin-login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 20%, rgba(156, 255, 56, .1), transparent 32%); }
.admin-login-card { width: min(100%, 420px); padding: 42px; text-align: center; border: 1px solid var(--line); border-radius: 24px; background: #12151c; box-shadow: 0 28px 80px rgba(0, 0, 0, .45); }
.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; border-right: 1px solid var(--line); background: #0d0f14; display: flex; flex-direction: column; }
.admin-brand { display: flex; align-items: center; gap: 14px; padding: 4px 10px 30px; }
.admin-brand strong, .admin-brand small { display: block; }
.admin-brand strong { font-size: 17px; letter-spacing: -.02em; }
.admin-brand small { margin-top: 3px; color: var(--muted-2); font-size: 10px; letter-spacing: .12em; }
.admin-nav { display: grid; gap: 5px; }
.nav-item { width: 100%; height: 45px; padding: 0 13px; display: flex; align-items: center; gap: 13px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: #8f95a1; cursor: pointer; text-align: left; transition: .18s; }
.nav-item span { width: 20px; color: #6f7581; font-size: 18px; text-align: center; }
.nav-item:hover { background: rgba(255, 255, 255, .035); color: #dfe3eb; }
.nav-item.active { border-color: rgba(156, 255, 56, .09); color: #e9ffd9; background: linear-gradient(90deg, rgba(156, 255, 56, .13), rgba(156, 255, 56, .035)); }
.nav-item.active span { color: var(--accent); }
.sidebar-footer { margin-top: auto; display: grid; gap: 7px; }
.ghost-button, .logout-button { min-height: 40px; border-radius: 10px; cursor: pointer; }
.ghost-button { border: 1px solid var(--line); background: #14171e; color: #b5bac4; }
.logout-button { border: 0; background: transparent; color: #696f7a; }
.admin-main { min-width: 0; padding: 34px clamp(22px, 4vw, 60px) 60px; }
.admin-header { min-height: 70px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.admin-header h1 { margin: 0; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.04em; }
.service-indicator { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: #8f95a1; font-size: 11px; }
.service-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 9px rgba(83, 245, 164, .55); }
.admin-view { display: none; }
.admin-view.active-view { display: block; animation: reveal .22s ease; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.stat-card { min-height: 150px; display: flex; align-items: flex-start; gap: 16px; padding: 24px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, #151820, #11141a); }
.stat-icon { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: rgba(156, 255, 56, .08); color: var(--accent); }
.stat-card span, .stat-card strong, .stat-card small { display: block; }
.stat-label { margin-bottom: 8px; color: #8e949f; font-size: 12px; }
.stat-card strong { font-size: 30px; line-height: 1.1; letter-spacing: -.04em; }
.stat-card small { margin-top: 9px; color: #5f6570; font-size: 10px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: #12151b; box-shadow: inset 0 1px rgba(255, 255, 255, .018); }
.dashboard-note { min-height: 180px; margin-top: 16px; padding: 34px; display: flex; align-items: center; justify-content: space-between; gap: 30px; background: linear-gradient(115deg, rgba(156, 255, 56, .07), transparent 45%), #12151b; }
.dashboard-note h2, .panel-heading h2 { margin: 5px 0 8px; font-size: 21px; }
.dashboard-note p { max-width: 650px; margin: 0; color: #858b96; line-height: 1.7; font-size: 13px; }
.panel-kicker { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .2em; }
.secondary-button { min-height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 10px; background: #191c23; color: #d7dbe3; cursor: pointer; white-space: nowrap; }
.form-panel, .table-panel, .created-result { padding: 28px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.panel-heading p { margin: 10px 0 0; color: #656b75; font-size: 11px; }
.admin-form { max-width: 820px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-grid label { display: grid; gap: 8px; color: #aeb3bd; font-size: 12px; }
.form-grid label em { color: #5f6570; font-style: normal; font-size: 10px; }
.form-grid input, .table-tools input, .table-tools select { height: 44px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #0d0f14; color: var(--text); }
.form-grid input { padding: 0 13px; }
.form-grid input:focus, .table-tools input:focus, .table-tools select:focus { border-color: rgba(156, 255, 56, .38); }
.wide-field { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 20px; margin-top: 24px; }
.created-result { margin-top: 16px; }
.created-result pre { max-height: 320px; overflow: auto; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: #0a0c10; color: #cfff9b; line-height: 1.9; }
.table-tools { display: flex; align-items: center; gap: 8px; }
.table-tools input { width: 190px; padding: 0 12px; }
.table-tools select { min-width: 110px; padding: 0 30px 0 11px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #181b22; color: #aeb3bd; cursor: pointer; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { padding: 12px 13px; border-bottom: 1px solid var(--line); color: #626874; font-size: 10px; font-weight: 600; letter-spacing: .05em; text-align: left; }
td { padding: 16px 13px; border-bottom: 1px solid rgba(255, 255, 255, .045); color: #ced2da; font-size: 12px; vertical-align: middle; }
tbody tr { transition: background .16s; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
.code-cell { display: flex; align-items: center; gap: 8px; }
.code-cell code { color: #e8ffce; font-size: 11px; }
.tiny-button, .text-link, .danger-link { border: 0; background: transparent; cursor: pointer; font-size: 10px; }
.tiny-button, .text-link { color: var(--accent); }
.danger-link { color: #ff8795; }
.muted-cell, .code-preview { color: #7f8590; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line); color: #9ba1ac; background: rgba(255, 255, 255, .03); font-size: 10px; white-space: nowrap; }
.badge-active, .badge-succeeded { border-color: rgba(83, 245, 164, .18); background: rgba(83, 245, 164, .08); color: #78f5b5; }
.badge-redeemed { border-color: rgba(137, 158, 255, .18); background: rgba(137, 158, 255, .08); color: #a9b7ff; }
.badge-revoked, .badge-failed, .badge-ambiguous, .badge-timed_out { border-color: rgba(255, 107, 125, .18); background: rgba(255, 107, 125, .07); color: #ff95a2; }
.badge-waiting, .badge-processing { border-color: rgba(246, 198, 89, .18); background: rgba(246, 198, 89, .07); color: #f4cd73; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #242933; color: #cdd3de; font-size: 11px; }
.user-cell strong, .user-cell small { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-cell strong { font-size: 11px; font-weight: 600; }
.user-cell small { margin-top: 3px; color: #676d78; font-size: 9px; }
.log-detail { max-width: 320px; }
.error-detail { display: inline-block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #777d88; vertical-align: middle; }
.empty-state { padding: 60px 20px; color: #5e6470; text-align: center; font-size: 13px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 18px; color: #6f7580; font-size: 10px; }
.pagination button { min-height: 34px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; background: #171a21; color: #b9bec7; cursor: pointer; }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }

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

@media (max-width: 760px) {
  .redeem-card { padding: 36px 22px; }
  .admin-layout { display: block; }
  .admin-sidebar { position: sticky; z-index: 20; width: 100%; height: auto; padding: 12px; border: 0; border-bottom: 1px solid var(--line); }
  .admin-brand { display: none; }
  .admin-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .nav-item { height: 42px; justify-content: center; padding: 0 5px; font-size: 10px; }
  .nav-item span { display: none; }
  .sidebar-footer { display: none; }
  .admin-main { padding: 22px 14px 45px; }
  .admin-header { min-height: 56px; margin-bottom: 18px; }
  .service-indicator { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { min-height: 125px; padding: 16px; gap: 10px; }
  .stat-icon { width: 34px; height: 34px; }
  .stat-card strong { font-size: 24px; }
  .dashboard-note, .panel-heading { align-items: flex-start; flex-direction: column; }
  .form-panel, .table-panel, .created-result { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .table-tools { width: 100%; flex-wrap: wrap; }
  .table-tools input { flex: 1; min-width: 130px; }
}
