:root {
  color-scheme: light;
  font-family:
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: #332c28;
  background: #f4ebe2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --bg: #f4ebe2;
  --bg-deep: #eadbd0;
  --surface: #fbf7f2;
  --surface-strong: #fffdfa;
  --ink: #332c28;
  --ink-soft: #625750;
  --ink-muted: #81736a;
  --border: #dfd0c5;
  --border-strong: #cbb9aa;
  --accent: #a95f50;
  --accent-dark: #7e4035;
  --accent-soft: #f0dcd2;
  --sage: #50675a;
  --sage-soft: #e0e7df;
  --danger: #9a403e;
  --danger-soft: #f4ddda;
  --success: #456855;
  --shadow: 0 24px 70px rgba(99, 71, 55, 0.12);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(204, 156, 132, 0.28), transparent 36%),
    linear-gradient(145deg, var(--bg), #f8f1e9 55%, var(--bg-deep));
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(125, 100, 89, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 100, 89, 0.045) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: "DM Mono", "SFMono-Regular", Consolas, monospace;
}

.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;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--accent-dark);
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4.2vw, 3.5rem);
  font-weight: 600;
  line-height: 1.13;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

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

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
textarea:focus-visible,
nav a:focus-visible,
nav button:focus-visible {
  outline: 3px solid rgba(169, 95, 80, 0.25);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  color: #fff9f4;
  background: var(--accent-dark);
  box-shadow: 0 11px 28px rgba(126, 64, 53, 0.22);
}

.button-primary:hover:not(:disabled) {
  background: #6f372d;
  box-shadow: 0 13px 32px rgba(126, 64, 53, 0.3);
}

.button-secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--border-strong);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface);
}

.button-full {
  width: 100%;
}

.button-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.79rem;
}

.icon-button {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease;
}

.icon-button:hover {
  color: var(--accent-dark);
  background: var(--surface-strong);
  border-color: var(--border-strong);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.icon-button-small {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  border-radius: 6px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  color: var(--ink-soft);
  font-size: 0.79rem;
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.field textarea {
  min-height: 76px;
  resize: vertical;
}

.field select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 21px,
    calc(100% - 13px) 21px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  cursor: pointer;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #ac9d94;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169, 95, 80, 0.1);
  outline: none;
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-hint {
  color: var(--ink-muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  color: #7f302f;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.success-box {
  margin: 0;
  padding: 10px 12px;
  color: var(--success);
  background: var(--sage-soft);
  border-left: 3px solid var(--sage);
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.public-shell {
  display: grid;
  width: min(1120px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  grid-template-rows: auto 1fr auto;
}

.site-header {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(177, 153, 137, 0.34);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  color: #fff8f2;
  background: var(--accent-dark);
  border-radius: 9px;
  transform: rotate(-3deg);
}

.brand-mark::before {
  content: none;
}

.header-note {
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.public-content {
  display: grid;
  min-width: 0;
  min-height: 0;
  align-items: center;
  padding: 66px 0;
}

.redeem-card {
  display: grid;
  width: 100%;
  max-width: 920px;
  min-height: 510px;
  margin: 0 auto;
  padding: 64px;
  background:
    linear-gradient(112deg, transparent 0 64%, rgba(236, 219, 207, 0.65) 64% 65%, transparent 65%),
    var(--surface);
  border: 1px solid rgba(196, 169, 151, 0.55);
  border-radius: 12px;
  box-shadow: var(--shadow);
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 72px;
}

.redeem-intro {
  align-self: center;
}

.redeem-intro h1 {
  max-width: 420px;
}

.intro-copy {
  max-width: 440px;
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.8;
}

.redeem-form {
  display: flex;
  align-self: center;
  flex-direction: column;
  gap: 17px;
}

.redeem-form input {
  min-height: 58px;
  padding: 15px 16px;
  font-family: "DM Mono", monospace;
  font-size: 1.02rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.airport-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink-soft);
  grid-column: 1 / -1;
}

.airport-note svg {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--sage);
}

.airport-note:not(:has(svg)) p::before {
  content: "✓";
  display: inline-block;
  width: 18px;
  color: var(--sage);
}

.airport-note:not(:has(svg)) {
  align-items: center;
}

.airport-note p {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.6;
}

.result-section {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 50px;
  background: var(--surface);
  border: 1px solid rgba(196, 169, 151, 0.55);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: enter 300ms ease both;
}

.restore-view {
  display: flex;
  width: min(520px, 100%);
  min-height: 330px;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  padding: 48px;
  flex-direction: column;
  text-align: center;
  background: var(--surface);
  border: 1px solid rgba(196, 169, 151, 0.55);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.restore-view h1 {
  max-width: 380px;
  font-size: clamp(1.65rem, 3.2vw, 2.25rem);
}

.restore-view .intro-copy {
  margin-top: 14px;
  font-size: 0.84rem;
}

.restore-view .form-error {
  width: 100%;
  margin-top: 20px;
  text-align: left;
}

.restore-view .button {
  margin-top: 20px;
}

.restore-spinner {
  width: 40px;
  height: 40px;
  margin-bottom: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.result-heading h1 {
  font-size: clamp(1.65rem, 3.2vw, 2.55rem);
}

.status-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  color: var(--success);
  background: var(--sage-soft);
  border: 1px solid #cbd7ce;
  border-radius: 5px;
  font-size: 0.76rem;
  font-weight: 600;
}

.key-panel {
  padding: 20px 22px;
  background: #342e2b;
  border-radius: 8px;
  color: #fff8ef;
}

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

.key-panel .field-label {
  color: #cabcaf;
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.key-actions {
  display: flex;
  gap: 7px;
}

.key-panel .icon-button {
  color: #e4d8cc;
  border-color: #5a504b;
}

.key-panel .icon-button:hover {
  color: #fff;
  background: #443d39;
  border-color: #75665d;
}

.key-value {
  display: block;
  margin-top: 17px;
  overflow-wrap: anywhere;
  color: #f7eee4;
  font-size: clamp(0.9rem, 2.1vw, 1.16rem);
  line-height: 1.7;
}

.key-value.is-masked {
  color: #d8cabd;
}

.key-persistence-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 14px 0 0;
  color: #cabcaf;
  font-size: 0.7rem;
  line-height: 1.5;
}

.key-persistence-note svg {
  flex: 0 0 auto;
  color: #bad0c0;
}

.detail-grid {
  display: grid;
  margin: 28px 0 0;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-item {
  min-width: 0;
  margin: 0;
  padding: 17px 18px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.detail-wide {
  grid-column: 1 / -1;
}

.detail-item dt {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.detail-item dd {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  font-weight: 500;
}

.detail-item dd code {
  font-size: 0.8rem;
}

.time-progress {
  width: 100%;
}

.time-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
  color: var(--ink);
  font-size: 0.82rem;
}

.time-progress-head strong {
  color: var(--ink-soft);
  font-family: "Cascadia Mono", monospace;
  font-size: 0.76rem;
  font-weight: 500;
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  background: #e9ded5;
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  min-width: 3px;
  background: linear-gradient(90deg, #8c4a3d, #bc8067);
  border-radius: inherit;
  transition: width 320ms ease;
}

.progress-fill.progress-low {
  background: linear-gradient(90deg, #9a403e, #c97666);
}

.progress-fill.progress-infinite {
  width: 100%;
  background: linear-gradient(90deg, #50675a, #91a696);
}

.detail-item .icon-button {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
}

.model-list {
  justify-content: flex-start !important;
  color: var(--ink-soft);
  font-family: "DM Mono", monospace;
  font-size: 0.78rem !important;
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 27px;
}

.result-footer p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.74rem;
}

.result-footer p svg {
  flex: 0 0 auto;
}

.site-footer {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink-soft);
  border-top: 1px solid rgba(177, 153, 137, 0.34);
  font-size: 0.72rem;
}

.centered-page {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.empty-state,
.login-card {
  width: 100%;
  max-width: 430px;
  padding: 42px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.empty-state h1,
.login-card h1 {
  margin-bottom: 21px;
  font-size: 2rem;
}

.login-mark {
  display: inline-flex;
  width: 52px;
  height: 52px;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  color: #fff9f3;
  background: var(--accent-dark);
  border-radius: 10px;
}

.login-mark::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: 9px -9px 0 -6px currentColor;
}

.login-card .intro-copy {
  margin: 13px auto 30px;
  font-size: 0.84rem;
  line-height: 1.7;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 17px;
  text-align: left;
}

.admin-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 232px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  padding: 30px 22px 22px;
  flex-direction: column;
  color: #f5ece3;
  background: #332d2a;
}

.admin-sidebar .brand-mark {
  color: #4a302a;
  background: #e2c3b2;
}

.admin-nav {
  display: flex;
  margin-top: 48px;
  flex-direction: column;
  gap: 6px;
}

.admin-nav a,
.admin-nav button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  color: #c8bbb1;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 0.83rem;
  text-align: left;
  cursor: pointer;
}

.admin-nav a:hover,
.admin-nav button:hover,
.admin-nav a.active {
  color: #fff9f3;
  background: #463d38;
}

.sidebar-footer {
  display: flex;
  margin-top: auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 20px;
  color: #a99a8f;
  border-top: 1px solid #514742;
  font-size: 0.76rem;
}

.sidebar-footer button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px;
  color: #d7c8bd;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.admin-main {
  width: 100%;
  max-width: 1260px;
  min-width: 0;
  padding: 44px clamp(24px, 4vw, 60px) 70px;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.admin-header h1 {
  font-size: clamp(1.8rem, 3.2vw, 2.65rem);
}

.connection-status {
  max-width: 310px;
  padding: 9px 12px;
  color: var(--success);
  background: rgba(224, 231, 223, 0.72);
  border: 1px solid #c9d8cc;
  border-radius: 5px;
  font-size: 0.73rem;
  line-height: 1.4;
}

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

.metric {
  display: flex;
  min-width: 0;
  padding: 18px;
  flex-direction: column;
  gap: 8px;
  background: rgba(251, 247, 242, 0.76);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border-strong);
  border-radius: 7px;
}

.metric span {
  color: var(--ink-muted);
  font-size: 0.73rem;
}

.metric strong {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.metric-green {
  border-top-color: var(--sage);
}

.metric-warm {
  border-top-color: #bf8567;
}

.metric-red {
  border-top-color: var(--danger);
}

.panel {
  margin-top: 22px;
  padding: 26px;
  background: rgba(251, 247, 242, 0.82);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.panel-heading > svg {
  color: var(--ink-muted);
}

.generate-form {
  display: grid;
  margin-top: 22px;
  align-items: end;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 17px 15px;
}

.generate-form .field:nth-last-of-type(1) {
  grid-column: 1 / 3;
}

.generated-codes {
  margin-top: 22px;
  padding: 18px;
  background: #f1e6dc;
  border: 1px solid #ddcbbd;
  border-radius: 7px;
}

.generated-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 13px;
  font-size: 0.83rem;
}

.generated-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-list {
  display: grid;
  max-height: 245px;
  overflow-y: auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.code-row {
  display: flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 6px 3px 11px;
  background: var(--surface-strong);
  border: 1px solid #ddcec2;
  border-radius: 5px;
}

.code-row code {
  min-width: 0;
  overflow: hidden;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-records {
  padding-bottom: 14px;
}

.table-wrap {
  width: 100%;
  margin-top: 9px;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 11px 9px;
  color: var(--ink-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  max-width: 270px;
  padding: 13px 9px;
  border-top: 1px solid #e7dbd1;
  font-size: 0.77rem;
  vertical-align: middle;
}

td small {
  display: block;
  max-width: 190px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted-code {
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.full-code {
  display: inline-block;
  padding: 3px 6px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 0.67rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-unused {
  color: #865936;
  background: #f2e3cf;
}

.status-issued {
  color: var(--success);
  background: var(--sage-soft);
}

.status-failed {
  color: #8b3b39;
  background: var(--danger-soft);
}

.status-revoked {
  color: #71655e;
  background: #e8e2dc;
}

.error-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--danger);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.row-actions {
  width: 42px;
  text-align: right;
}

.muted-dash {
  color: var(--ink-muted);
}

.table-empty {
  padding: 35px;
  color: var(--ink-muted);
  text-align: center;
}

.toast {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 20;
  display: flex;
  max-width: min(410px, calc(100vw - 44px));
  align-items: center;
  gap: 9px;
  padding: 12px 15px;
  color: #fffaf5;
  background: #3b3531;
  border-radius: 7px;
  box-shadow: 0 12px 40px rgba(37, 27, 22, 0.22);
  font-size: 0.8rem;
  animation: toast-in 220ms ease both;
}

.toast-success svg {
  color: #b8d8c0;
}

.toast-error svg {
  color: #ebb3ab;
}

.spin {
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-7px);
  }
}

@media (max-width: 980px) {
  .redeem-card {
    max-width: 650px;
    padding: 45px;
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .redeem-form {
    max-width: 460px;
  }

  .airport-note {
    grid-column: auto;
  }

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

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

  .generate-form .field:nth-last-of-type(1) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .public-shell {
    width: min(100% - 28px, 620px);
  }

  .site-header {
    min-height: 72px;
  }

  .public-content {
    padding: 30px 0 40px;
  }

  .redeem-card,
  .result-section,
  .restore-view {
    padding: 28px 22px;
  }

  .redeem-card {
    min-height: auto;
    background: var(--surface);
  }

  .redeem-intro h1 {
    font-size: clamp(2rem, 9vw, 2.8rem);
  }

  .result-heading {
    flex-direction: column;
    gap: 15px;
  }

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

  .detail-wide {
    grid-column: auto;
  }

  .result-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-footer .button {
    width: 100%;
  }

  .site-footer {
    min-height: 64px;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    padding: 15px 0;
  }

  .admin-shell {
    display: block;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    padding: 18px 18px 12px;
  }

  .admin-nav {
    margin-top: 19px;
    flex-direction: row;
    overflow-x: auto;
  }

  .admin-nav a,
  .admin-nav button {
    min-width: max-content;
  }

  .sidebar-footer {
    display: none;
  }

  .admin-main {
    padding: 28px 18px 50px;
  }

  .admin-header {
    flex-direction: column;
  }

  .connection-status {
    max-width: 100%;
  }

  .generate-form {
    grid-template-columns: 1fr;
  }

  .generate-form .field:nth-last-of-type(1) {
    grid-column: auto;
  }

  .code-list {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 20px 15px;
  }
}

@media (max-width: 480px) {
  .public-shell {
    width: calc(100% - 22px);
  }

  .header-note {
    display: none;
  }

  .redeem-card,
  .result-section,
  .restore-view {
    padding: 25px 17px;
    border-radius: 9px;
  }

  .login-card {
    padding: 32px 24px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 1.45rem;
  }

  .toast {
    top: 12px;
    right: 12px;
    max-width: calc(100vw - 24px);
  }
}

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

