:root {
  color-scheme: dark;
  --bg: #06101d;
  --panel: #0b1a2b;
  --panel-2: #10243a;
  --line: #203b58;
  --text: #edf6ff;
  --muted: #9db1c7;
  --blue: #4ca6ff;
  --green: #39d98a;
  --red: #ff6b7a;
  --yellow: #ffc857;
  --shadow: 0 20px 60px #0007;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0, #123556 0, transparent 35%),
    linear-gradient(160deg, #05101c, #081625 60%, #07111f);
  color: var(--text);
}

button, input, select, textarea { font: inherit; }
button, select { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #4ca6ff55;
  outline-offset: 2px;
}

.hidden { display: none !important; }
.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;
}

.shell { width: min(1280px, 100%); margin: auto; padding: 18px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 48px; height: 48px; border-radius: 15px; box-shadow: 0 10px 35px #4ca6ff55; }
.brand h1 { margin: 0; font-size: 20px; }
.brand small { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: #78bcff; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.muted { color: var(--muted); }

.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px;
  background: #12263b;
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .62; cursor: wait; }
.btn.primary { border: 0; background: linear-gradient(135deg, #1688ef, #655cff); }
.btn.danger { border-color: #722c3b; background: #3a1720; color: #ffd8dd; }
.btn.ghost { background: transparent; }
.icon-button { min-width: 42px; padding: 7px 10px; font-size: 24px; line-height: 1; }

.auth { min-height: 80vh; display: grid; place-items: center; }
.card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, #0d1e31ef, #091725f5);
  box-shadow: var(--shadow);
}
.auth-card { width: min(470px, 100%); padding: 30px; }
.auth-card h2 { margin: 0 0 6px; font-size: clamp(25px, 5vw, 30px); }
.security-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; }

.field { display: grid; gap: 7px; margin: 15px 0; }
.field label { font-size: 13px; font-weight: 750; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  outline: none;
  background: #071522;
  color: var(--text);
}
.field input[readonly] { color: #cdeaff; background: #0a1c2c; cursor: not-allowed; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.auth-actions { display: grid; gap: 10px; margin-top: 18px; }

.notice { margin-top: 14px; border: 1px solid #1f4d70; border-radius: 12px; padding: 11px 13px; background: #0d2940; color: #cdeaff; }
.notice.error { border-color: #7f2d3c; background: #3c1720; color: #ffd7dd; }
.notice.warning { border-color: #725d21; background: #382d11; color: #ffe29a; }

.layout { display: grid; grid-template-columns: 225px minmax(0, 1fr); gap: 16px; }
.side { position: sticky; top: 14px; height: fit-content; padding: 14px; }
.nav { display: grid; gap: 7px; }
.nav button { text-align: left; }
.nav button.active { border-color: #3f83bb; background: #173652; }
.content { min-width: 0; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; padding: 20px; }
.hero h2 { margin: 0 0 5px; }
.hero p:last-child { margin: 0; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 15px; }
.stat { padding: 17px; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.stat strong { display: block; margin-top: 7px; font-size: 28px; }
.panel { padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { margin: 0; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 15px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 12px 13px; border-bottom: 1px solid #173049; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: #0c1d2e; color: #a9bdd1; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; }
td { font-size: 14px; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 35px; color: var(--muted); text-align: center; }
.activity-row { padding: 10px 0; border-bottom: 1px solid #173049; }
.activity-row:last-child { border-bottom: 0; }

.badge { display: inline-flex; border: 1px solid; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 850; }
.b-unused, .b-active, .b-pro_active, .b-paid, .b-complimentary { border-color: #26684a; background: #103525; color: #8ff0bd; }
.b-redeemed { border-color: #315f89; background: #12304d; color: #acd5ff; }
.b-revoked, .b-expired, .b-pro_expired { border-color: #7c3442; background: #401922; color: #ffb2bb; }
.b-pending { border-color: #705d21; background: #3d3010; color: #ffe29a; }

.modal { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; overflow: auto; padding: 16px; background: #000b; }
.modal-card { width: min(600px, 100%); max-height: 90vh; overflow: auto; padding: 22px; }
.modal-card h3 { margin-top: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code-box { margin-top: 15px; border: 1px dashed #3f86bd; border-radius: 14px; padding: 16px; background: #06131f; font: 700 17px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; user-select: all; }
.result-actions { margin-top: 15px; }

.toast { position: fixed; z-index: 20; right: 18px; bottom: 18px; max-width: min(380px, calc(100vw - 36px)); border: 1px solid #2d638e; border-radius: 14px; padding: 13px 16px; background: #102b42; box-shadow: var(--shadow); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid #ffffff44; border-top-color: #fff; border-radius: 50%; vertical-align: middle; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; overflow-x: auto; }
  .nav { display: flex; min-width: max-content; }
  .nav button { text-align: center; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .top { align-items: flex-start; }
  .brand h1 { font-size: 18px; }
  .auth { min-height: 75vh; }
  .auth-card { padding: 22px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero .row, .hero .btn { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px; }
  .stat strong { font-size: 23px; }
  .panel { padding: 14px; }
  .panel-head { align-items: flex-start; }
  .split { grid-template-columns: 1fr; }
  .result-actions .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
