:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #15171a;
  --muted: #667085;
  --line: #dfe3e8;
  --accent: #111827;
  --accent-2: #2563eb;
  --ok: #16803c;
  --warn: #b26b00;
  --danger: #c62828;
  --shadow: 0 12px 36px rgba(20, 24, 28, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}
.nav { display: flex; gap: 8px; align-items: center; }
.nav a, .nav button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  text-decoration: none;
  cursor: pointer;
}
.page {
  width: min(1180px, calc(100vw - 40px));
  margin: 28px auto 56px;
}
.redeem-shell {
  min-height: calc(100vh - 64px);
  display: grid;
  align-items: center;
  padding: 36px 0;
}
.redeem-card {
  width: min(720px, calc(100vw - 32px));
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.redeem-head { padding: 30px; border-bottom: 1px solid var(--line); }
.eyebrow {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}
h1, h2, h3 { margin: 0; }
h1 { margin-top: 8px; font-size: 34px; line-height: 1.16; }
.sub { color: var(--muted); line-height: 1.65; margin: 12px 0 0; }
.redeem-body { padding: 28px 30px 30px; display: grid; gap: 18px; }
.input-row { display: flex; gap: 10px; align-items: stretch; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}
textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  border-color: #93b4ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}
.btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 11px 15px;
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
}
.btn.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn.danger { background: #b91c1c; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.message {
  display: none;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.5;
}
.message.show { display: block; }
.message.error { background: #fff1f0; color: var(--danger); border: 1px solid #ffd0cc; }
.message.ok { background: #edf8f0; color: var(--ok); border: 1px solid #c9edd2; }
.result {
  display: none;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 24px 30px 30px;
}
.result.show { display: block; }
.credential {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}
.credential-item {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.credential-title {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.field-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.field-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.field-value { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 750; word-break: break-all; }
.guide {
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  line-height: 1.65;
  color: #344054;
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.muted { color: var(--muted); }
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.stat strong { display: block; font-size: 28px; margin-top: 4px; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.refresh-status { font-size: 13px; }
.detect-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.detect-box > div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.detect-box strong {
  display: block;
  font-size: 24px;
  margin-top: 4px;
}
.mode-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mode-box.disabled {
  opacity: .55;
}
.radio-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
}
.radio-card input { width: auto; margin-top: 3px; }
.radio-card strong { display: block; font-size: 14px; }
.radio-card small { display: block; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; }
.section { display: none; }
.section.active { display: grid; gap: 16px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-size: 12px; font-weight: 800; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 750;
  background: #eef2ff;
  color: #3730a3;
}
.pill.available { background: #e9f8ef; color: #16703a; }
.pill.bound { background: #fff6dc; color: #8a5b00; }
.pill.redeemed { background: #eef2ff; color: #3730a3; }
.pill.disabled { background: #f2f4f7; color: #667085; }
.login-panel { width: min(420px, calc(100vw - 32px)); margin: 15vh auto 0; }
.hidden { display: none !important; }
.copy-line {
  display: flex;
  gap: 8px;
  align-items: center;
}
.copy-line code {
  background: #f2f4f7;
  border: 1px solid var(--line);
  padding: 5px 7px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}
label.check { display: flex; align-items: center; gap: 8px; color: var(--muted); }
label.check input { width: auto; }

@media (max-width: 780px) {
  .topbar {
    height: auto;
    min-height: 58px;
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .brand { min-width: 0; }
  .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav {
    width: 100%;
    justify-content: flex-start;
  }
  .nav a, .nav button {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
  }
  .page { width: min(100vw - 20px, 1180px); margin-top: 12px; }
  .input-row, .credential, .credential-item, .grid.two, .stats, .detect-box, .mode-box { grid-template-columns: 1fr; display: grid; }
  .input-row { gap: 10px; }
  .stats { gap: 10px; }
  .stat { padding: 13px; }
  .stat strong { font-size: 24px; }
  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .tab {
    padding: 10px 8px;
    font-size: 14px;
    white-space: nowrap;
  }
  .card { padding: 14px; }
  .card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .toolbar .btn,
  .toolbar input {
    width: 100%;
    max-width: none !important;
  }
  .refresh-status {
    grid-column: 1 / -1;
  }
  textarea { min-height: 132px; }
  table, thead, tbody, tr, th, td {
    display: block;
    width: 100%;
  }
  thead { display: none; }
  table {
    border-collapse: separate;
    border-spacing: 0;
  }
  tbody {
    display: grid;
    gap: 10px;
  }
  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }
  tr.empty-row {
    padding: 12px;
  }
  td {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    word-break: break-word;
  }
  td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.8;
  }
  tr.empty-row td {
    display: block;
    padding: 0;
    border-bottom: 0;
  }
  tr.empty-row td::before { content: ""; display: none; }
  td code {
    white-space: pre-wrap;
    word-break: break-all;
  }
  .copy-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }
  .copy-line .btn { width: 100%; }
}
