:root {
  --bg: #030915;
  --panel: rgba(9, 20, 40, 0.78);
  --panel-strong: rgba(14, 29, 56, 0.94);
  --panel-border: rgba(106, 151, 255, 0.28);
  --text: #eff6ff;
  --muted: #9db2d8;
  --accent: #4ec9ff;
  --accent-2: #b98cff;
  --danger: #ff6985;
  --success: #20d68f;
  --warning: #f7bf63;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(120, 164, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 164, 255, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 50% 18%, black, transparent 80%);
  pointer-events: none;
  z-index: -3;
}

.bg-orb {
  position: fixed;
  width: 52vw;
  height: 52vw;
  filter: blur(76px);
  opacity: 0.24;
  border-radius: 999px;
  pointer-events: none;
  z-index: -2;
}

.orb-a {
  top: -18vw;
  left: -12vw;
  background: radial-gradient(circle, #2f8dff 0%, #000 72%);
}

.orb-b {
  bottom: -24vw;
  right: -12vw;
  background: radial-gradient(circle, #9b6bff 0%, #000 74%);
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(122, 161, 255, 0.18);
  background: linear-gradient(to bottom, rgba(2, 9, 21, 0.96), rgba(2, 9, 21, 0.72));
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  object-fit: cover;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-badge {
  color: #cfe1ff;
  border: 1px solid rgba(128, 169, 255, 0.3);
  background: rgba(33, 57, 98, 0.35);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
}

.admin-shell {
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.auth-card,
.hero-panel,
.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 760px;
  margin: 8vh auto;
  padding: clamp(1.4rem, 4vw, 2.4rem);
}

.auth-card h1,
.hero-panel h1,
.panel h2 {
  font-family: "Sora", sans-serif;
  letter-spacing: -0.03em;
}

.auth-card h1,
.hero-panel h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
}

.auth-card p,
.hero-panel p {
  color: #d7e3ff;
  max-width: 72ch;
}

.auth-card.danger {
  border-color: rgba(255, 105, 133, 0.45);
}

.kicker {
  margin: 0 0 0.65rem;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  min-height: 42px;
  padding: 0.62rem 1rem;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.btn-primary {
  color: #031427;
  background: linear-gradient(120deg, #79e4ff 0%, #8ec4ff 52%, #c08aff 100%);
  box-shadow: 0 8px 26px rgba(95, 163, 255, 0.34);
}

.btn-ghost {
  border: 1px solid rgba(138, 178, 255, 0.36);
  background: rgba(31, 55, 95, 0.32);
}

.full {
  width: 100%;
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background:
    radial-gradient(circle at 16% -12%, rgba(78, 201, 255, 0.26), transparent 42%),
    linear-gradient(155deg, rgba(10, 25, 52, 0.82), rgba(8, 11, 30, 0.92));
}

.hero-panel p {
  margin: 0;
}

.hero-stat {
  display: grid;
  place-items: center;
  min-width: 150px;
  min-height: 150px;
  border: 1px solid rgba(126, 171, 255, 0.34);
  border-radius: 999px;
  background: rgba(6, 16, 34, 0.46);
}

.hero-stat span {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}

.hero-stat small {
  color: var(--muted);
}

.panel {
  padding: 1.15rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.35rem;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 1rem;
  margin-top: 1rem;
}

.stack {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.stat-card {
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid rgba(137, 176, 255, 0.25);
  background: rgba(18, 35, 68, 0.55);
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.stat-card span {
  color: #c5d7fb;
}

.stat-card.available strong { color: var(--success); }
.stat-card.assigned strong { color: var(--accent); }
.stat-card.redeemed strong { color: var(--accent-2); }
.stat-card.void strong { color: var(--danger); }

.form-grid,
.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.filters {
  grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(220px, 1.4fr);
  margin-bottom: 1rem;
}

.one-col {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 0.35rem;
  color: #c5d8ff;
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  border: 1px solid rgba(129, 169, 255, 0.32);
  border-radius: 13px;
  background: rgba(4, 13, 29, 0.76);
  padding: 0.68rem 0.75rem;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(78, 201, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(78, 201, 255, 0.12);
}

.file-drop {
  margin: 1rem 0;
  min-height: 116px;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(128, 172, 255, 0.48);
  border-radius: var(--radius-md);
  background: rgba(20, 39, 75, 0.42);
  cursor: pointer;
}

.file-drop input {
  display: none;
}

.file-drop span {
  font-size: 1.15rem;
  color: var(--text);
}

.file-drop small {
  color: var(--muted);
  font-weight: 500;
}

.format-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border: 1px solid rgba(126, 171, 255, 0.3);
  border-radius: 999px;
  color: #bad4ff;
  background: rgba(25, 48, 89, 0.45);
  padding: 0.22rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-available { color: #052719; background: color-mix(in srgb, var(--success) 72%, white 28%); }
.status-assigned { color: #03203b; background: color-mix(in srgb, var(--accent) 72%, white 28%); }
.status-redeemed { color: #1d0f31; background: color-mix(in srgb, var(--accent-2) 72%, white 28%); }
.status-void { color: #3b0712; background: color-mix(in srgb, var(--danger) 76%, white 24%); }

.preview-summary,
.message,
.empty-state,
.soft-box {
  color: #c9d9f5;
  border: 1px solid rgba(126, 171, 255, 0.24);
  border-radius: var(--radius-md);
  background: rgba(7, 18, 38, 0.62);
  padding: 0.85rem;
}

.message:empty {
  display: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

.button-row.vertical {
  display: grid;
}

.table-wrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid rgba(126, 171, 255, 0.22);
  border-radius: var(--radius-md);
}

.table-wrap.compact {
  max-height: 260px;
  margin-top: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  padding: 0.72rem 0.75rem;
  border-bottom: 1px solid rgba(126, 171, 255, 0.16);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #bad4ff;
  background: var(--panel-strong);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

td {
  color: #e2ecff;
}

tr:hover td {
  background: rgba(41, 73, 130, 0.18);
}

.code-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  word-break: break-all;
}

.row-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.mini-btn {
  border: 1px solid rgba(126, 171, 255, 0.32);
  border-radius: 999px;
  color: #dceaff;
  background: rgba(31, 55, 95, 0.34);
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  font-weight: 800;
}

.selected-code {
  margin: 0.8rem 0;
  border: 1px solid rgba(78, 201, 255, 0.38);
  border-radius: var(--radius-md);
  background: rgba(78, 201, 255, 0.08);
  padding: 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  word-break: break-all;
}

.apps-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
  max-height: 260px;
  overflow: auto;
}

.app-item {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  border: 1px solid rgba(126, 171, 255, 0.2);
  border-radius: 13px;
  background: rgba(7, 18, 38, 0.52);
  padding: 0.6rem;
}

.app-item small {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  max-width: min(420px, calc(100vw - 2rem));
  border: 1px solid rgba(126, 171, 255, 0.34);
  border-radius: 16px;
  background: rgba(7, 18, 38, 0.94);
  color: var(--text);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

@media (max-width: 1120px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .admin-header,
  .hero-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .form-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .hero-stat {
    min-width: 100%;
    min-height: 110px;
    border-radius: var(--radius-lg);
  }
}
