@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap");

:root {
  --bg: #07111f;
  --bg-soft: #0a1729;
  --panel: rgba(13, 27, 46, 0.82);
  --panel-solid: #0d1b2e;
  --panel-hover: #11243d;
  --border: rgba(151, 188, 226, 0.12);
  --border-strong: rgba(151, 188, 226, 0.23);
  --text: #edf7ff;
  --muted: #8199b3;
  --muted-light: #aac0d5;
  --blue: #58a9ff;
  --blue-strong: #2588f5;
  --violet: #9a83ff;
  --green: #4fd39b;
  --red: #ff7185;
  --amber: #ffbf62;
  --warm: #ff9d39;
  --shadow: 0 26px 70px rgba(0, 6, 16, 0.34);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% -10%, rgba(43, 122, 195, 0.19), transparent 31rem),
    radial-gradient(circle at 46% 110%, rgba(55, 80, 166, 0.14), transparent 38rem),
    var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: .2;
  background-image: radial-gradient(circle, rgba(255,255,255,.55) 0 1px, transparent 1.5px);
  background-size: 43px 43px;
  mask-image: linear-gradient(to bottom, #000, transparent 68%);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  background: rgba(6, 15, 27, .88);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand img { width: 48px; height: 48px; border-radius: 14px; box-shadow: 0 8px 22px rgba(52, 141, 255, .2); }
.brand span { display: grid; gap: 1px; }
.brand strong { font: 800 19px/1 "Manrope", sans-serif; letter-spacing: .08em; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .03em; }
.main-nav { display: grid; gap: 8px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 47px; padding: 0 14px; color: var(--muted-light); border: 1px solid transparent; border-radius: 13px; font-weight: 600; transition: .2s ease; }
.nav-link:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-link.active { color: #fff; background: linear-gradient(120deg, rgba(39, 133, 239, .19), rgba(58, 106, 186, .08)); border-color: rgba(71, 160, 255, .18); box-shadow: inset 3px 0 var(--blue); }
.nav-icon { display: grid; place-items: center; width: 23px; height: 23px; color: var(--blue); font-size: 18px; }
.sidebar-footer { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid var(--border); }
.system-status { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.system-status span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }

.content { width: min(1280px, 100%); margin: 0 auto; padding: 56px clamp(28px, 4vw, 68px) 72px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font: 800 clamp(30px, 4vw, 43px)/1.08 "Manrope", sans-serif; letter-spacing: -.035em; }
h2 { margin-bottom: 6px; font: 700 18px/1.3 "Manrope", sans-serif; letter-spacing: -.02em; }
h3 { margin-bottom: 7px; font: 700 16px/1.3 "Manrope", sans-serif; }
.page-description, .panel-toolbar p { margin-bottom: 0; color: var(--muted); font-size: 14px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 12px; font-weight: 700; cursor: pointer; transition: transform .18s ease, filter .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button:active { transform: translateY(0); }
.button:disabled { cursor: wait; opacity: .56; transform: none; }
.button-primary { background: linear-gradient(135deg, #3097ff, #1579e7); color: #fff; box-shadow: 0 11px 26px rgba(30, 127, 229, .25); }
.button-secondary { background: rgba(59, 149, 247, .11); border-color: rgba(76, 162, 255, .24); color: #bdddff; }
.button-ghost { color: var(--muted-light); background: transparent; border-color: var(--border); }
.button-warm { color: #20140a; background: linear-gradient(135deg, #ffc564, #ff9735); box-shadow: 0 12px 25px rgba(255, 152, 52, .2); }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.stat-card { display: flex; align-items: center; gap: 14px; min-height: 98px; padding: 19px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgba(16, 34, 56, .92), rgba(10, 24, 41, .9)); box-shadow: 0 16px 40px rgba(0, 4, 12, .12); }
.stat-icon { display: grid; place-items: center; width: 45px; height: 45px; flex: 0 0 auto; border-radius: 13px; font-size: 19px; }
.stat-icon.blue { color: #7dbdff; background: rgba(45, 139, 240, .12); }
.stat-icon.violet { color: #ac9bff; background: rgba(138, 111, 255, .12); }
.stat-icon.amber { color: #ffd18b; background: rgba(255, 178, 67, .12); }
.stat-icon.green { color: #72e2b2; background: rgba(56, 199, 142, .12); }
.stat-icon.red { color: #ff91a1; background: rgba(255, 94, 119, .12); }
.stat-card div:last-child { display: grid; gap: 4px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { font: 700 24px/1.1 "Manrope", sans-serif; }
.stat-card strong small { margin-left: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }

.panel { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.panel-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 89px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.panel-toolbar h2 { margin-bottom: 3px; }
.search-field { width: min(290px, 100%); display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 11px; background: rgba(5, 14, 25, .45); color: var(--muted); }
.search-field:focus-within { border-color: rgba(76, 161, 255, .5); box-shadow: 0 0 0 3px rgba(48, 151, 255, .08); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
input::placeholder { color: #607a95; }
.table-wrap { position: relative; min-height: 270px; }
table { width: 100%; border-collapse: collapse; }
th { height: 44px; padding: 0 22px; text-align: left; color: #6f89a5; background: rgba(4, 13, 23, .22); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
td { height: 67px; padding: 10px 22px; border-top: 1px solid rgba(151, 188, 226, .075); color: var(--muted-light); font-size: 13px; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: rgba(67, 135, 204, .045); }
.player-id { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.player-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #81bcfa; background: linear-gradient(145deg, rgba(52, 142, 233, .18), rgba(72, 86, 175, .12)); font-size: 14px; }
.state-badge { display: inline-flex; align-items: center; min-height: 27px; padding: 0 10px; color: #bdadff; border: 1px solid rgba(154, 131, 255, .17); border-radius: 999px; background: rgba(138, 111, 255, .09); font-weight: 700; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.icon-button:hover { color: #fff; border-color: var(--border); background: rgba(255,255,255,.04); }
.icon-button.danger:hover { color: var(--red); border-color: rgba(255,113,133,.18); background: rgba(255,113,133,.06); }
.loading-state, .empty-state { display: flex; min-height: 270px; align-items: center; justify-content: center; }
.loading-state { gap: 10px; color: var(--muted); font-size: 13px; }
.empty-state { flex-direction: column; padding: 36px; text-align: center; }
.empty-state p { max-width: 330px; color: var(--muted); font-size: 13px; }
.empty-icon { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 15px; color: var(--blue); background: rgba(52, 142, 233, .08); font-size: 20px; }

.redeem-card { position: relative; overflow: hidden; display: grid; grid-template-columns: 1fr minmax(320px, .9fr); align-items: center; gap: 34px; min-height: 185px; margin-bottom: 18px; padding: 30px 32px; border: 1px solid rgba(92, 161, 233, .21); border-radius: 21px; background: linear-gradient(115deg, rgba(19, 53, 86, .95), rgba(18, 34, 66, .92) 55%, rgba(41, 37, 79, .9)); box-shadow: var(--shadow); }
.redeem-glow { position: absolute; inset: -80% auto auto -8%; width: 420px; height: 420px; border-radius: 50%; background: rgba(48, 151, 255, .1); filter: blur(35px); pointer-events: none; }
.redeem-copy { position: relative; z-index: 1; }
.redeem-copy h2 { margin: 0; font-size: 23px; }
.code-form { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 7px; border: 1px solid rgba(156, 190, 229, .16); border-radius: 15px; background: rgba(5, 15, 29, .42); }
.code-form input { width: 100%; height: 45px; padding: 0 12px; border: 0; outline: 0; background: transparent; color: var(--text); font: 700 15px "Manrope", sans-serif; letter-spacing: .06em; }
.code-form .button { min-height: 45px; white-space: nowrap; }
.codes-stats { margin-bottom: 18px; }
.code-toolbar { align-items: flex-start; }
.filter-group { display: flex; gap: 5px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: rgba(5, 14, 25, .35); }
.filter { min-height: 31px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; }
.filter:hover { color: #fff; }
.filter.active { color: #cce6ff; background: rgba(51, 142, 238, .14); }
.code-list { min-height: 0; }
.code-row { display: grid; grid-template-columns: minmax(145px, 1fr) 112px minmax(145px, .75fr) 135px minmax(135px, auto); align-items: center; gap: 16px; min-height: 76px; padding: 12px 22px; border-top: 1px solid rgba(151, 188, 226, .075); cursor: pointer; transition: background .16s ease; }
.code-row:first-child { border-top: 0; }
.code-row:hover { background: rgba(67, 135, 204, .045); }
.code-name { display: grid; gap: 4px; }
.code-name strong { font: 700 14px "Manrope", sans-serif; letter-spacing: .05em; }
.code-name span, .code-date { color: var(--muted); font-size: 11px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; width: fit-content; min-height: 27px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-completed { color: #72e2b2; background: rgba(56,199,142,.09); }
.status-partial { color: #ffd18b; background: rgba(255,178,67,.09); }
.status-failed { color: #ff91a1; background: rgba(255,94,119,.09); }
.status-expired { color: #ffb47d; background: rgba(255,130,62,.1); }
.status-processing, .status-pending { color: #82bdff; background: rgba(52,142,233,.09); }
.progress-wrap { display: grid; gap: 7px; }
.progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.06); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--violet)); }
.result-counts { display: flex; gap: 12px; font-size: 11px; }
.result-counts .ok { color: var(--green); }
.result-counts .bad { color: var(--red); }
.code-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.rerun-button { min-height: 31px; padding: 0 10px; border: 1px solid rgba(105, 174, 245, .22); border-radius: 8px; background: rgba(52, 142, 233, .1); color: #9ed0ff; cursor: pointer; font-size: 10px; font-weight: 700; white-space: nowrap; }
.rerun-button:hover:not(:disabled) { border-color: rgba(105, 174, 245, .45); background: rgba(52, 142, 233, .18); color: #d9edff; }
.rerun-button:disabled { border-color: var(--border); background: rgba(255,255,255,.025); color: #59718a; cursor: default; }
.code-chevron { color: #597490; font-size: 18px; }

.modal { width: min(480px, calc(100% - 30px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 20px; background: #0c1a2d; color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.modal::backdrop { background: rgba(2, 8, 17, .73); backdrop-filter: blur(7px); }
.modal form, .modal > div:not(.modal-header) { padding-left: 24px; padding-right: 24px; }
.modal form { padding-bottom: 24px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 23px 24px 18px; border-bottom: 1px solid var(--border); }
.modal form .modal-header { margin: 0 -24px 22px; }
.modal-header h2 { margin-bottom: 0; font-size: 20px; }
.modal-header .eyebrow { margin-bottom: 4px; }
.modal-copy { color: var(--muted); font-size: 13px; line-height: 1.55; }
.modal-small { width: min(420px, calc(100% - 30px)); }
.modal-wide { width: min(780px, calc(100% - 30px)); padding-bottom: 24px; }
.form-field { display: grid; gap: 7px; margin-bottom: 17px; color: var(--muted-light); font-size: 12px; font-weight: 600; }
.form-field > input, .prefixed-input { width: 100%; min-height: 46px; border: 1px solid var(--border-strong); border-radius: 11px; background: rgba(4, 13, 24, .55); color: var(--text); outline: 0; }
.form-field > input { padding: 0 13px; }
.form-field > input:focus, .prefixed-input:focus-within { border-color: rgba(76, 161, 255, .6); box-shadow: 0 0 0 3px rgba(48, 151, 255, .08); }
.form-field small { color: #5d7691; font-weight: 400; }
.prefixed-input { display: flex; align-items: center; }
.prefixed-input span { padding-left: 13px; color: var(--violet); font-weight: 700; }
.prefixed-input input { width: 100%; height: 44px; padding: 0 13px 0 5px; border: 0; outline: 0; background: transparent; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.results-summary { display: flex; gap: 10px; padding-top: 20px; padding-bottom: 15px; }
.summary-chip { padding: 8px 11px; border: 1px solid var(--border); border-radius: 10px; color: var(--muted-light); font-size: 11px; }
.results-list { max-height: 430px; overflow: auto; }
.result-row { display: grid; grid-template-columns: 1fr 90px 1.5fr; align-items: center; gap: 14px; min-height: 62px; border-top: 1px solid var(--border); font-size: 11px; }
.result-player { display: grid; gap: 3px; }
.result-player strong { color: var(--text); }
.result-player span, .result-message { color: var(--muted); }
.result-message { line-height: 1.4; }

.toast-region { position: fixed; z-index: 20; right: 22px; bottom: 22px; display: grid; gap: 9px; width: min(360px, calc(100% - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border: 1px solid var(--border-strong); border-radius: 12px; background: rgba(12, 27, 46, .97); box-shadow: 0 20px 50px rgba(0,0,0,.35); color: var(--muted-light); font-size: 12px; animation: toast-in .22s ease both; }
.toast.success { border-color: rgba(79, 211, 155, .25); }
.toast.error { border-color: rgba(255, 113, 133, .25); }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.14); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.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; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 72px; }
  .sidebar { position: fixed; z-index: 10; top: auto; right: 0; bottom: 0; left: 0; height: 68px; flex-direction: row; align-items: center; padding: 8px 14px; border-top: 1px solid var(--border); border-right: 0; }
  .brand { display: none; }
  .main-nav { width: 100%; grid-template-columns: 1fr 1fr; gap: 8px; }
  .nav-link { justify-content: center; min-height: 50px; }
  .nav-link.active { box-shadow: inset 0 -3px var(--blue); }
  .sidebar-footer { display: none; }
  .content { padding: 38px 22px 42px; }
  .redeem-card { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 650px) {
  .content { padding: 28px 15px 34px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-header .button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; gap: 9px; }
  .stat-card { min-height: 82px; }
  .panel-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tbody { padding: 8px 13px; }
  tbody tr { position: relative; padding: 12px; border-bottom: 1px solid var(--border); }
  tbody tr:last-child { border-bottom: 0; }
  td { height: auto; padding: 4px 0; border: 0; }
  td:nth-child(3) { color: var(--muted); font-size: 11px; }
  td:last-child { position: absolute; top: 12px; right: 6px; }
  .redeem-card { padding: 24px 20px; }
  .code-form { grid-template-columns: 1fr; }
  .code-form .button { width: 100%; }
  .code-toolbar { align-items: stretch; }
  .filter-group { overflow-x: auto; }
  .code-row { grid-template-columns: 1fr auto; gap: 8px 16px; padding: 16px 18px; }
  .code-row .progress-wrap { grid-column: 1 / -1; }
  .code-row .result-counts { grid-column: 1; }
  .code-row .code-date { display: none; }
  .code-status { grid-column: 2; grid-row: 1; }
  .code-info { grid-column: 1; grid-row: 3; }
  .code-actions { grid-column: 2; grid-row: 3; }
  .result-row { grid-template-columns: 1fr auto; padding: 10px 0; }
  .result-message { grid-column: 1 / -1; }
  .modal-actions .button { flex: 1; }
}

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