:root {
  --bg: #090b0f;
  --panel: rgba(18, 22, 30, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f6efe0;
  --muted: #98a3b7;
  --gold: #f3c766;
  --green: #55f0a0;
  --red: #ff6b7a;
  --blue: #79a9ff;
  --cyan: #72f7ff;
  --purple: #b58cff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 24px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background:
    radial-gradient(circle at 15% -10%, rgba(231, 185, 87, 0.22), transparent 34rem),
    radial-gradient(circle at 95% 10%, rgba(122, 167, 255, 0.16), transparent 30rem),
    linear-gradient(135deg, #090b0f 0%, #11141b 50%, #08090d 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

body, button, input { -webkit-font-smoothing: antialiased; }

a { color: var(--gold); text-decoration: none; }
a:hover { color: #ffd98a; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.85rem + env(safe-area-inset-top)) clamp(1rem, 4vw, 4rem) 0.85rem;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-shadow: 0 0 20px rgba(243, 199, 102, 0.18);
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.62rem;
  background: url("/favicon.svg") center / contain no-repeat;
  box-shadow:
    0 0 0 1px rgba(243, 199, 102, 0.22),
    0 10px 28px rgba(243, 199, 102, 0.18);
}

.brand-name {
  color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(243, 199, 102, 0.28));
}

nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: wrap;
}

nav a {
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: #b9c9ff;
  font-size: 0.88rem;
  padding: 0.45rem 0.7rem;
}

nav a:hover {
  color: #0a0d12;
  background: linear-gradient(135deg, var(--gold), #ffe39a);
  box-shadow: 0 8px 24px rgba(243, 199, 102, 0.18);
}

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

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding: 1.4rem clamp(1rem, 4vw, 4rem) calc(1.4rem + env(safe-area-inset-bottom));
  font-size: 0.82rem;
}

.hero-grid,
.dashboard-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.hero-grid > div:first-child { grid-column: span 8; }
.hero-grid > .balance-card { grid-column: span 4; }

h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 12ch;
  font-size: clamp(2.2rem, 5vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  margin-bottom: 1rem;
  color: transparent;
  background: linear-gradient(135deg, #fff4cf 0%, var(--gold) 38%, var(--green) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 0 34px rgba(243, 199, 102, 0.18);
}
h2 {
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
  color: var(--gold);
}
h3 { color: var(--blue); }

.eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 900;
  margin-bottom: 0.7rem;
}

.muted { color: var(--muted); line-height: 1.6; }
.small { font-size: 0.84rem; }

.panel,
.auth-card,
.balance-card,
.metric-card {
  border: 1px solid rgba(243, 199, 102, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(28, 34, 47, 0.96), rgba(13, 17, 25, 0.94)),
    radial-gradient(circle at 20% 0%, rgba(243, 199, 102, 0.13), transparent 16rem);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 0 0 1px rgba(85, 240, 160, 0.035);
}

.panel:nth-of-type(2n),
.dashboard-grid .panel:nth-child(2n) {
  border-color: rgba(121, 169, 255, 0.18);
  background:
    linear-gradient(145deg, rgba(23, 29, 43, 0.96), rgba(11, 15, 24, 0.94)),
    radial-gradient(circle at 85% 0%, rgba(121, 169, 255, 0.12), transparent 15rem);
}

.panel { padding: 1.2rem; margin-bottom: 1rem; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }

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

.balance-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem;
  min-height: 150px;
}
.balance-card span, .balance-card small { color: var(--muted); }
.balance-card strong {
  font-size: clamp(2rem, 8vw, 2.6rem);
  color: var(--green);
  margin: 0.4rem 0;
  overflow-wrap: anywhere;
}

.metric-card {
  grid-column: span 3;
  min-height: 132px;
  padding: 1.1rem;
  position: relative;
  overflow: hidden;
}
.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -45% 30%;
  height: 86px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.12;
  filter: blur(22px);
}
.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  position: relative;
  z-index: 1;
}
.metric-card span {
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.68rem;
  font-weight: 900;
}
.metric-card strong {
  display: block;
  position: relative;
  z-index: 1;
  margin: 0.5rem 0 0.2rem;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  letter-spacing: -0.06em;
  overflow-wrap: anywhere;
}
.metric-card.gold { color: var(--gold); }
.metric-card.green { color: var(--green); }
.metric-card.blue { color: var(--blue); }
.metric-card.red { color: var(--red); }
.metric-card.gold strong { color: var(--gold); }
.metric-card.green strong { color: var(--green); }
.metric-card.blue strong { color: var(--blue); }
.metric-card.red strong { color: var(--red); }

.ledger-panel { margin-top: 1rem; }

.auth-shell {
  min-height: 68vh;
  display: grid;
  place-items: center;
}
.auth-card {
  width: min(460px, 100%);
  padding: 2rem;
}

.stacked-form {
  display: grid;
  gap: 1rem;
  margin: 1.4rem 0;
}
.stacked-form.compact { margin-bottom: 0; }

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.84rem;
}

input {
  width: 100%;
  min-height: var(--tap);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  outline: none;
  font: inherit;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(231, 185, 87, 0.12); }

.button {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.button.primary {
  background: linear-gradient(135deg, var(--gold), #ffe091);
  color: #15100a;
  border-color: transparent;
  box-shadow: 0 12px 34px rgba(243, 199, 102, 0.22);
}
.button.subtle { color: #b9c9ff; }
.button.danger {
  color: #260909;
  background: linear-gradient(135deg, var(--red), #ff9aa4);
  border-color: transparent;
  box-shadow: 0 12px 34px rgba(255, 107, 122, 0.18);
}
.button.mini { min-height: 2.3rem; padding: 0.45rem 0.7rem; font-size: 0.78rem; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: scale(0.96); }

.alert {
  border-radius: 18px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}
.alert.success { color: var(--green); background: rgba(96, 211, 148, 0.08); }
.alert.danger { color: var(--red); background: rgba(255, 107, 107, 0.08); }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  border-radius: 999px;
  padding: 0.25rem 0.62rem;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
}
.status-badge.active { color: #09140e; background: linear-gradient(135deg, var(--green), #b9ffd8); border-color: transparent; }
.status-badge.used { color: #d7e2ff; background: rgba(121, 169, 255, 0.12); border-color: rgba(121, 169, 255, 0.24); }
.status-badge.expired { color: var(--red); background: rgba(255, 107, 122, 0.1); border-color: rgba(255, 107, 122, 0.22); }

.provider-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  border-radius: 999px;
  padding: 0.28rem 0.68rem;
  color: #15100a;
  background: linear-gradient(135deg, var(--gold), #ffe39a);
  box-shadow: 0 0 24px rgba(243, 199, 102, 0.12);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
}
.provider-badge.steam { color: #dbe7ff; background: linear-gradient(135deg, #1b2838, #66c0f4); }

.key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.9rem;
  border-radius: 18px;
  background: #05070a;
  border: 1px solid var(--line);
  overflow: hidden;
}
.key-box code {
  min-width: 0;
  color: var(--green);
  word-break: break-all;
  overflow-wrap: anywhere;
}
.key-box.wallet code { color: var(--gold); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 0.85rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--gold);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
td { color: #d9e3f8; overflow-wrap: anywhere; }
td[data-label="ID"] { color: var(--gold); }
td[data-label="Amount"],
td[data-label="Requested"] { color: var(--green); font-weight: 900; }
td[data-label="TX"],
td[data-label="TX / note"],
td[data-label="Email"],
td[data-label="Provider"],
td[data-label="User"] { color: #b9c9ff; }
td[data-label="Received UTC"],
td[data-label="Created UTC"],
td[data-label="Reviewed UTC"] { color: var(--muted); }
.otp-code {
  color: var(--green);
  font-size: clamp(1.25rem, 7vw, 1.7rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  white-space: nowrap;
}
.otp-account {
  color: #b9c9ff;
  font-weight: 800;
  word-break: break-all;
}
.fresh-row { animation: flashRow 2.2s ease-out; }
.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 1.25rem;
  background: linear-gradient(135deg, rgba(243, 199, 102, 0.06), rgba(121, 169, 255, 0.045));
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  border: 1px solid currentColor;
  background: var(--panel-soft);
  font-weight: 900;
}
.status.approved {
  color: var(--green);
  background: rgba(85, 240, 160, 0.1);
  box-shadow: 0 0 24px rgba(85, 240, 160, 0.08);
}
.status.rejected {
  color: var(--red);
  background: rgba(255, 107, 122, 0.1);
}
.status.pending {
  color: var(--gold);
  background: rgba(243, 199, 102, 0.1);
}
.status.pending i {
  width: 0.65rem;
  height: 0.65rem;
  border: 2px solid rgba(231, 185, 87, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.actions-cell { min-width: 280px; }
.inline-form { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0.2rem 0; }
.inline-form input { width: 110px; padding: 0.45rem 0.6rem; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding-top: 1rem;
}
.pager-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}
.button.disabled {
  opacity: 0.45;
  pointer-events: none;
  transform: none;
}

.docs { line-height: 1.65; }
pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #05070a;
  max-width: 100%;
}
pre code { color: #dce6ff; }
.doc-list { color: var(--muted); padding-left: 1.2rem; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flashRow {
  0% { background: rgba(96, 211, 148, 0.24); }
  100% { background: transparent; }
}

@media (max-width: 920px) {
  .hero-grid > div:first-child,
  .hero-grid > .balance-card,
  .span-5,
  .span-7 { grid-column: 1 / -1; }

  .metric-card { grid-column: span 6; }

  .shell { padding-top: 2rem; }
  h1 { max-width: 14ch; }
}

@media (max-width: 640px) {
  :root {
    --radius: 18px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
  }

  body {
    background:
      radial-gradient(circle at 20% -10%, rgba(231, 185, 87, 0.16), transparent 24rem),
      linear-gradient(160deg, #090b0f 0%, #10131a 55%, #07080c 100%);
  }

  body::before { opacity: 0.16; background-size: 34px 34px; }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.7rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .brand { font-size: 0.95rem; }

  nav {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a {
    flex: 0 0 auto;
    min-height: 2.5rem;
    font-size: 0.82rem;
    color: #d7e2ff;
    background: linear-gradient(135deg, rgba(121, 169, 255, 0.14), rgba(243, 199, 102, 0.07));
    border: 1px solid rgba(121, 169, 255, 0.16);
  }

  .shell {
    width: min(100% - 1rem, 1180px);
    padding: 1.1rem 0 2.75rem;
  }

  .footer {
    display: grid;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .hero-grid,
  .dashboard-grid {
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }

  h1 {
    font-size: clamp(2rem, 13vw, 3rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
    margin-bottom: 0.75rem;
  }

  h2 { font-size: 1rem; }
  .eyebrow { font-size: 0.66rem; margin-bottom: 0.5rem; }
  .muted { line-height: 1.5; }

  .panel,
  .auth-card,
  .balance-card,
  .metric-card {
    border-radius: var(--radius);
  }

  .metric-card { grid-column: 1 / -1; }

  .panel,
  .auth-card {
    padding: 1rem;
  }

  .balance-card {
    min-height: auto;
    padding: 1rem;
  }

  .balance-card strong {
    font-size: clamp(2rem, 12vw, 2.6rem);
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
    gap: 0.75rem;
  }

  .panel-title .button,
  .panel-title form,
  .panel-title form .button,
  .pager .button {
    width: 100%;
  }

  .pager {
    align-items: stretch;
    justify-content: stretch;
  }

  .pager-status {
    order: -1;
    width: 100%;
    text-align: center;
  }

  .auth-shell {
    min-height: auto;
    place-items: stretch;
  }

  .key-box {
    align-items: stretch;
    flex-direction: column;
    gap: 0.8rem;
  }
  .key-box .button { width: 100%; }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 0.75rem;
  }

  tr {
    border: 1px solid rgba(243, 199, 102, 0.16);
    border-radius: 18px;
    background:
      linear-gradient(135deg, rgba(243, 199, 102, 0.08), transparent 42%),
      rgba(5, 7, 10, 0.74);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.26);
    overflow: hidden;
  }

  tr:nth-child(2n) {
    border-color: rgba(121, 169, 255, 0.16);
    background:
      linear-gradient(135deg, rgba(121, 169, 255, 0.08), transparent 42%),
      rgba(5, 7, 10, 0.74);
  }

  td {
    display: grid;
    grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.72rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  td:last-child { border-bottom: 0; }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
  }

  .empty-row td {
    display: block;
    text-align: center;
  }
  .empty-row td::before { content: none; }

  td[data-label="Code"] {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 1rem;
  }
  td[data-label="Code"]::before { content: none; }

  .otp-code {
    font-size: clamp(1.8rem, 15vw, 3.25rem);
    letter-spacing: 0.22em;
  }

  .status {
    width: fit-content;
    max-width: 100%;
    border-radius: 14px;
  }

  .actions-cell { min-width: 0; }
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    margin: 0.35rem 0;
  }
  .inline-form input,
  .inline-form .button {
    width: 100%;
  }

  pre {
    padding: 0.85rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 380px) {
  .shell { width: min(100% - 0.75rem, 1180px); }
  .panel, .auth-card, .balance-card { padding: 0.85rem; }
  td {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
}

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