:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  --background: #101310;
  --panel: #1a1f19;
  --field: #111610;
  --line: #343c31;
  --text: #edf0e9;
  --muted: #a5afa0;
  --gold: #e9c886;
  --gold-hover: #f5d99d;
  --focus: #e9c886;
  --good: #afe0bd;
  --danger: #ffb9ae;
  background: var(--background);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(ellipse at 30% 0, #262a1b, transparent 42rem);
}

h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; }
a { color: inherit; }
button, input, textarea { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.layout {
  width: min(100% - 4rem, 68rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: #10131080;
}

.header-inner {
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 650;
  letter-spacing: .04em;
}

.brand-mark {
  display: grid;
  place-items: center;
  position: relative;
  width: 2.25rem;
  aspect-ratio: 1;
  border: 1px solid #73613e;
  border-radius: .65rem;
  background: linear-gradient(145deg, #5a4b2e, #292b21);
  color: var(--gold);
}

.brand-mark::before {
  content: "";
  width: .96rem;
  aspect-ratio: 1;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: .76rem;
  left: 1.03rem;
  width: .27rem;
  height: .35rem;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.logout {
  padding: .35rem 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: .875rem;
  text-underline-offset: .25em;
  text-decoration: underline transparent;
  transition: color .15s, text-decoration-color .15s;
}

.logout:disabled { opacity: .6; cursor: wait; }

.logout:hover:not(:disabled) {
  color: var(--text);
  text-decoration-color: currentColor;
}

main { padding-block: 3.25rem 4rem; }

h1 {
  font-size: clamp(2rem, 4vw, 2.65rem);
  font-weight: 680;
  line-height: 1.25;
  letter-spacing: -.03em;
}

h2 { font-size: 1.2rem; font-weight: 650; }

.subtitle {
  margin-top: .65rem;
  color: var(--muted);
}

.issue-panel {
  margin-top: 2.25rem;
  padding: 1.5rem;
  border: 1px solid #514a33;
  border-radius: 1rem;
  background: linear-gradient(105deg, #28281d, var(--panel) 73%);
}

.issue-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
}

.issue-main p, #revoke-form > p:not(.feedback) {
  margin-top: .4rem;
  color: var(--muted);
  font-size: .9375rem;
}

.issue-form { flex: 0 0 auto; }

.issue-form label {
  display: block;
  margin-bottom: .375rem;
  color: var(--muted);
  font-size: .875rem;
}

.issue-controls, .button-group {
  display: flex;
  align-items: center;
  gap: .625rem;
}

input[type="number"] {
  width: 5.1rem;
  min-height: 2.6rem;
  padding: .45rem .65rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--field);
}

.button, .text-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.button {
  min-height: 2.6rem;
  padding: .48rem .85rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
}

.button:disabled, .text-button:disabled {
  opacity: .6;
  cursor: wait;
}

.primary {
  min-width: 7rem;
  background: var(--gold);
  border-color: var(--gold);
  color: #242013;
}

.primary:hover:not(:disabled) { background: var(--gold-hover); }

.secondary { background: var(--field); }
.secondary:hover:not(:disabled) { background: #252d23; border-color: #596452; }

.results {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.results-header, .records-header, .records-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.results-header label { font-size: .9375rem; font-weight: 600; }

textarea {
  display: block;
  width: 100%;
  margin-top: .75rem;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--field);
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .875rem;
  resize: vertical;
  overflow-wrap: anywhere;
}

.feedback {
  color: var(--muted);
  font-size: .875rem;
}

.results .feedback { min-height: 1.4em; margin-top: .5rem; }
.error { color: var(--danger); }
.issue-panel > .error { margin-top: .75rem; }

.records { margin-top: 2.25rem; }
.records-header { margin-bottom: .75rem; }

.records-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--panel);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-inline-size: 0;
  margin: 0;
  padding: .8rem;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.filter {
  position: relative;
  font-size: .875rem;
  cursor: pointer;
}

.filter input, .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.filter span {
  display: grid;
  place-items: center;
  min-height: 2.35rem;
  min-width: 3.5rem;
  padding-inline: .8rem;
  border: 1px solid transparent;
  border-radius: .45rem;
  color: var(--muted);
}

.filter:hover span { background: #232b20; color: var(--text); }

.filter input:checked + span {
  border-color: #685a3b;
  background: #332d20;
  color: var(--gold);
}

.filter input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  text-align: left;
}

th, td {
  padding: .725rem 1rem;
  border-bottom: 1px solid var(--line);
}

thead { background: #151a14; color: var(--muted); }
thead th { font-weight: 600; }
.code-cell { font-weight: 500; }
.code-cell code { color: var(--gold); }
.date-cell { color: var(--muted); font-variant-numeric: tabular-nums; }
.mobile-label { display: none; }

.status {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .8125rem;
  font-weight: 550;
  white-space: nowrap;
  color: var(--muted);
  background: #2b322a;
}

.status[data-status="available"] { color: #f2d59e; background: #3c3221; }
.status[data-status="redeemed"] { color: var(--good); background: #233b2a; }

.text-button {
  min-height: 2rem;
  padding: .2rem .55rem;
  margin-inline: -.55rem;
  border: 0;
  border-radius: .4rem;
  background: transparent;
  color: var(--muted);
}

.text-button:hover { background: #372820; color: var(--danger); }

#empty-message {
  height: 9rem;
  color: var(--muted);
  text-align: center;
}

.records-footer {
  min-height: 3.1rem;
  padding: .55rem 1rem;
}

dialog {
  width: min(27rem, 100% - 2rem);
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: .875rem;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop { background: #080a08bb; }
dialog code { color: var(--gold); }

.dialog-actions {
  justify-content: flex-end;
  margin-top: 1rem;
}

#revoke-form > .error { margin-top: .6rem; }
.danger { background: #943f33; border-color: #bc6659; color: #fff1ee; }
.danger:hover:not(:disabled) { background: #ab4e40; }

@media (max-width: 42rem) {
  .layout { width: calc(100% - 2rem); }
  main { padding-top: 2rem; }
  .issue-panel { margin-top: 1.75rem; padding: 1rem; }
  .issue-main { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .results-header { align-items: flex-start; flex-direction: column; gap: .65rem; }
  .records-footer { gap: .5rem; }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
  }

  .code-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: .625rem;
    row-gap: .25rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--line);
  }

  .code-row > * { border: 0; padding: 0; }
  .status-cell { text-align: right; }
  .date-cell { grid-column: 1; }
  .date-cell .mobile-label { display: inline; margin-right: .35rem; }
  .update-cell:has(time[hidden]) { display: none; }
  .action-cell { grid-column: 2; grid-row: 2 / span 2; text-align: right; }
}

.login { width: min(27rem, 100% - 2rem); padding-top: clamp(3rem, 10vw, 7rem); }

.login-panel {
  padding: clamp(1.25rem, 5vw, 2rem);
  border: 1px solid #514a33;
  border-radius: 1rem;
  background: linear-gradient(130deg, #28281d, var(--panel) 72%);
}

.login h1 { font-size: 1.75rem; }
.login form { margin-top: 1.25rem; }

.login label {
  display: block;
  margin-block: .75rem .35rem;
  color: var(--muted);
  font-size: .875rem;
}

.login input {
  display: block;
  width: 100%;
  min-height: 2.7rem;
  padding: .45rem .65rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--field);
}

.login .feedback { min-height: 1.4em; margin-block: .65rem; }
.login .primary { width: 100%; }
#session-error { margin-top: .65rem; }
