:root {
  --bg: #f6efe3;
  --ink: #17130f;
  --panel: rgba(255, 251, 245, 0.9);
  --line: rgba(23, 19, 15, 0.14);
  --accent: #c44d2d;
  --accent-2: #0f766e;
  --shadow: 0 24px 60px rgba(35, 24, 17, 0.15);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(196, 77, 45, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(135deg, #f5ead8 0%, #f9f6f1 55%, #efe8dd 100%);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

body.is-modal-open {
  overflow: hidden;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.54)),
    linear-gradient(120deg, rgba(196, 77, 45, 0.1), rgba(15, 118, 110, 0.08));
  box-shadow: var(--shadow);
}

.hero-top {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}

.hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -40% auto;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(196, 77, 45, 0.2), transparent 70%);
  transform: rotate(18deg);
}

.eyebrow,
.panel-kicker {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: rgba(23, 19, 15, 0.7);
}

h1,
h2,
h3,
h4 {
  font-family: Baskerville, Georgia, serif;
  font-weight: 600;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(2.6rem, 6vw, 5rem);
  line-height: 0.95;
}

h2 {
  margin: 8px 0 0;
  font-size: 1.75rem;
}

h3,
h4 {
  margin: 0;
}

.lede {
  max-width: 760px;
  font-size: 1.05rem;
  line-height: 1.7;
}

.compact-lede {
  max-width: none;
  margin: 0;
}

.stat-grid,
.grid {
  display: grid;
  gap: 18px;
}

.stat-grid {
  margin-top: 30px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

body[data-page="home"] .stat-grid {
  justify-content: center;
}

body[data-page="home"] .stat-grid .stat-card {
  width: min(320px, 100%);
  margin: 0 auto;
  text-align: center;
}

.grid {
  margin-top: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-auth-grid.is-login-only {
  grid-template-columns: 1fr;
}

.lower-grid {
  align-items: start;
}

.stat-card,
.panel,
.download-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stat-card {
  padding: 20px 22px;
}

.stat-card span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(23, 19, 15, 0.68);
}

.stat-card strong {
  font-size: 2rem;
}

.panel {
  padding: 26px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head-row,
.panel-actions,
.modal-head,
.generated-result-head {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.panel-head-row {
  margin-bottom: 18px;
}

.panel-head-row .panel-head,
.panel-head-row .panel-kicker,
.panel-head-row h2 {
  margin-bottom: 0;
}

.panel-actions .action-button {
  width: auto;
}

.stack {
  display: grid;
  gap: 14px;
}

.token-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: end;
}

.grow {
  flex: 1;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(23, 19, 15, 0.16);
  font: inherit;
}

input,
select,
textarea {
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
}

textarea,
pre,
.console {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

button,
.button-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--accent), #df7f4d);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

.locale-toggle {
  width: auto;
  min-width: 108px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border-color: rgba(23, 19, 15, 0.12);
  box-shadow: 0 8px 22px rgba(35, 24, 17, 0.08);
}

.nav-pill {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: auto;
  min-width: 108px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(23, 19, 15, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(35, 24, 17, 0.08);
}

.secondary {
  background: linear-gradient(135deg, var(--accent-2), #2f9389);
}

.guide-actions {
  margin-top: 18px;
}

.inline-note {
  margin: 14px 0 0;
  color: rgba(23, 19, 15, 0.72);
  line-height: 1.6;
}

.status,
.help-box,
.console,
.download-card {
  margin-top: 16px;
}

.status {
  min-height: 26px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.download-card {
  padding: 18px;
}

.metric-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(23, 19, 15, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.metric-card span {
  display: block;
  margin-bottom: 8px;
  color: rgba(23, 19, 15, 0.68);
  font-size: 0.88rem;
}

.metric-card strong {
  font-size: 1.7rem;
}

.compact-head {
  margin-bottom: 12px;
}

.record-history {
  margin-top: 18px;
}

.record-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.record-item {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(23, 19, 15, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.record-title {
  font-size: 1.08rem;
}

.record-details {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.record-detail {
  display: grid;
  gap: 4px;
}

.record-label {
  color: rgba(23, 19, 15, 0.62);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.record-value {
  font-size: 0.96rem;
  word-break: break-word;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
  border-radius: 18px;
  border: 1px solid rgba(23, 19, 15, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.full-span {
  width: 100%;
}

.card-table-toolbar,
.card-pagination,
.toolbar-actions,
.pagination-actions {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
}

.card-table-toolbar {
  margin-bottom: 4px;
  justify-content: space-between;
}

.toolbar-field {
  min-width: 170px;
  flex: 0 1 200px;
}

.search-field {
  flex: 1 1 280px;
}

.toolbar-actions {
  margin-left: auto;
  justify-content: flex-end;
}

.toolbar-actions .inline-note,
.card-pagination .inline-note {
  margin: 0;
}

.card-pagination {
  margin-top: 14px;
  justify-content: space-between;
}

.page-indicator {
  min-width: 110px;
  text-align: center;
  font-weight: 700;
}

.card-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.card-table th,
.card-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(23, 19, 15, 0.08);
  text-align: left;
  vertical-align: middle;
}

.card-table th {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(23, 19, 15, 0.65);
  background: rgba(255, 255, 255, 0.82);
}

.card-table tbody tr:last-child td {
  border-bottom: 0;
}

.checkbox-cell {
  width: 56px;
  text-align: center !important;
}

.checkbox-cell input {
  width: 18px;
  height: 18px;
  margin: 0 auto;
  padding: 0;
  border-radius: 6px;
  accent-color: var(--accent-2);
}

.card-code {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.95rem;
}

.table-email {
  word-break: break-all;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-chip.is-unused {
  color: #166534;
  background: rgba(22, 101, 52, 0.12);
  border-color: rgba(22, 101, 52, 0.14);
}

.status-chip.is-used {
  color: #92400e;
  background: rgba(146, 64, 14, 0.12);
  border-color: rgba(146, 64, 14, 0.14);
}

.status-chip.is-voided {
  color: #991b1b;
  background: rgba(153, 27, 27, 0.12);
  border-color: rgba(153, 27, 27, 0.14);
}

.action-button {
  width: auto;
  min-width: 88px;
  padding: 10px 14px;
  border-radius: 12px;
}

.action-button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.admin-toolbar {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.admin-toolbar button {
  width: auto;
}

.admin-workspace {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 19, 15, 0.44);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.94), rgba(255, 251, 245, 0.92)),
    linear-gradient(120deg, rgba(196, 77, 45, 0.08), rgba(15, 118, 110, 0.07));
  box-shadow: 0 32px 80px rgba(35, 24, 17, 0.28);
}

.modal-form {
  margin-top: 18px;
}

.generated-result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(23, 19, 15, 0.1);
}

.generated-result-head {
  margin-bottom: 8px;
}

.hidden {
  display: none;
}

.help-box {
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px dashed rgba(23, 19, 15, 0.22);
  background: rgba(255, 255, 255, 0.48);
}

.console,
pre {
  padding: 16px;
  border-radius: 18px;
  background: #151312;
  color: #f0e8da;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

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

  .token-row {
    flex-direction: column;
    align-items: stretch;
  }

  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .hero-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
  }

  .hero,
  .panel {
    padding: 22px;
  }

  .modal-dialog {
    max-height: calc(100vh - 20px);
    padding: 20px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .card-table-toolbar,
  .card-pagination,
  .toolbar-actions,
  .pagination-actions {
    align-items: stretch;
  }

  .toolbar-field,
  .search-field,
  .toolbar-actions {
    flex: 1 1 100%;
    min-width: 0;
  }

  .toolbar-actions .action-button,
  .pagination-actions .action-button {
    width: 100%;
  }

  .page-indicator {
    min-width: 0;
    width: 100%;
  }

  .panel-actions,
  .modal-head,
  .generated-result-head {
    align-items: stretch;
  }

  .panel-actions .action-button,
  .modal-head .action-button,
  .generated-result-head .action-button {
    width: 100%;
  }
}
