:root {
  --ink: #17201c;
  --muted: #68716c;
  --line: #dce3de;
  --paper: #f5f7f4;
  --surface: #ffffff;
  --green: #1f6a49;
  --green-dark: #174c37;
  --green-soft: #dcefe5;
  --amber: #b87320;
  --red: #a4413a;
  --shadow: 0 18px 50px rgba(24, 48, 36, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input { font: inherit; }
a { color: inherit; }

.redeem-body {
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(31,106,73,.055) 50%, transparent 50.1%),
    linear-gradient(rgba(31,106,73,.04) 1px, transparent 1px),
    #f3f6f2;
  background-size: 100% 100%, 100% 48px, auto;
}

.redeem-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 48px; display: grid; grid-template-columns: 1fr 330px; gap: 76px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 14px; font-weight: 720; }
.brand-mark { width: 32px; height: 32px; border-radius: 7px; display: inline-grid; place-items: center; color: white; background: var(--green); font-family: Georgia, serif; font-size: 19px; }
.redeem-shell > .brand { grid-column: 1 / -1; }
.redeem-panel { align-self: center; max-width: 690px; padding: 56px 0 40px; }
.eyebrow { margin: 0 0 18px; color: var(--green); font-size: 12px; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.eyebrow.muted { color: var(--muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2ca568; box-shadow: 0 0 0 4px rgba(44,165,104,.12); }
.redeem-panel h1, .result-panel h1 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(45px, 6vw, 76px); font-weight: 500; line-height: 1.04; letter-spacing: -.045em; }
.lead { max-width: 610px; color: var(--muted); font-size: 17px; line-height: 1.8; margin: 26px 0 32px; }
.redeem-form { display: grid; gap: 10px; max-width: 660px; }
.redeem-form label, .stack-form > label:not(.file-drop), .field-grid label { font-size: 13px; font-weight: 680; }
.code-field { position: relative; }
input { width: 100%; min-height: 48px; border: 1px solid #cbd5ce; background: white; border-radius: 6px; color: var(--ink); padding: 0 14px; outline: none; transition: border-color .16s, box-shadow .16s; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,106,73,.12); }
.code-field input { height: 64px; padding: 0 90px 0 18px; font: 650 17px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .035em; }
.paste-button { position: absolute; right: 10px; top: 10px; height: 44px; border: 0; border-radius: 5px; padding: 0 16px; color: var(--green); background: var(--green-soft); cursor: pointer; font-weight: 650; }
.primary-button, .secondary-button { min-height: 52px; border-radius: 6px; padding: 0 19px; display: inline-flex; align-items: center; justify-content: space-between; gap: 22px; text-decoration: none; border: 1px solid transparent; cursor: pointer; font-weight: 720; }
.primary-button { color: white; background: var(--green); box-shadow: 0 8px 22px rgba(31,106,73,.18); }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.redeem-form > .primary-button { margin-top: 4px; height: 58px; }
.secondary-button { color: var(--green); background: white; border-color: #bfccc4; }
.secondary-button.compact { min-height: 42px; padding: 0 15px; }
.trust-row { display: flex; gap: 26px; margin-top: 19px; color: #7a847e; font-size: 12px; }
.trust-row span::before { content: "✓"; color: var(--green); font-weight: 800; margin-right: 6px; }
.steps { align-self: center; border-left: 1px solid #cfd8d2; padding-left: 40px; }
.steps ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 34px; }
.steps li { display: grid; grid-template-columns: 32px 1fr; gap: 14px; }
.steps li > span { color: var(--green); font: 700 12px ui-monospace, monospace; padding-top: 3px; }
.steps strong, .steps small { display: block; }
.steps strong { font-size: 15px; margin-bottom: 7px; }
.steps small { color: var(--muted); line-height: 1.55; }
.site-footer { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 18px 0 30px; border-top: 1px solid var(--line); color: #7a837e; font-size: 12px; }

.notice { border: 1px solid; border-radius: 6px; padding: 12px 14px; margin: 14px 0; font-size: 14px; line-height: 1.5; }
.notice-error { color: #823b36; background: #fff3f1; border-color: #edcbc7; }
.notice-success { color: #205f43; background: #eff9f3; border-color: #c8e5d4; }

.result-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px; }
.result-panel { width: min(620px, 100%); background: white; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 54px; border-radius: 8px; }
.result-panel h1 { font-size: clamp(36px, 6vw, 58px); }
.result-panel > p { color: var(--muted); line-height: 1.7; margin: 20px 0 28px; }
.success-icon, .error-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 28px; font-size: 25px; font-weight: 800; }
.success-icon { color: var(--green); background: var(--green-soft); }
.error-icon { color: var(--red); background: #f9e7e5; }
.download-button { width: 100%; height: 60px; }
.security-note { display: grid; gap: 6px; margin-top: 26px; border-top: 1px solid var(--line); padding-top: 20px; font-size: 13px; }
.security-note span { color: var(--muted); line-height: 1.6; }

.admin-login-body { background: #edf1ed; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-panel { width: min(430px, 100%); background: white; border: 1px solid var(--line); border-radius: 8px; padding: 38px; box-shadow: var(--shadow); display: grid; gap: 30px; }
.login-panel h1 { margin: 0; font: 500 38px Georgia, serif; }
.muted-copy { color: var(--muted); line-height: 1.6; }
.stack-form { display: grid; gap: 12px; }
.text-link { color: var(--green); font-size: 13px; text-decoration: none; }

.admin-body { background: #f4f6f3; }
.admin-topbar { height: 64px; padding: 0 max(24px, calc((100% - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; background: white; border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 22px; font-size: 13px; }
.topbar-actions form { margin: 0; }
.quiet-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.admin-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 70px; }
.admin-heading, .section-heading-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.admin-heading form { margin: 0; }
.admin-heading h1 { margin: 0; font: 500 42px Georgia, serif; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 30px 0; border: 1px solid var(--line); background: white; border-radius: 7px; overflow: hidden; }
.metric-grid article { padding: 22px; display: grid; gap: 8px; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border-right: 0; }
.metric-grid span, .metric-grid small { color: var(--muted); font-size: 12px; }
.metric-grid strong { font: 500 34px Georgia, serif; }
.admin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.tool-section, .table-section { background: white; border: 1px solid var(--line); border-radius: 7px; }
.tool-section { padding: 26px; }
.section-title { display: grid; grid-template-columns: 32px 1fr; gap: 12px; margin-bottom: 24px; }
.section-title > span { font: 700 12px ui-monospace, monospace; color: var(--green); padding-top: 6px; }
.section-title h2, .table-section h2 { font-size: 18px; margin: 0 0 6px; }
.section-title p, .table-section p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.file-drop { min-height: 145px; border: 1px dashed #aebdb3; border-radius: 6px; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; cursor: pointer; background: #fafcf9; }
.file-drop:hover { border-color: var(--green); background: #f4faf6; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop small { color: var(--muted); }
.file-icon { color: var(--green); font-size: 25px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid label { display: grid; gap: 8px; }
.table-section { margin-top: 22px; overflow: hidden; }
.batch-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin: -8px 0 22px; padding: 12px 0; color: var(--muted); font-size: 12px; }
.batch-strip strong { color: var(--ink); }
.batch-strip a { color: var(--green); text-decoration: none; }
.section-heading-row { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid #e7ece8; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: #fafbf9; }
td:nth-child(3) { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.status { display: inline-block; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; }
.status-available { color: #216246; background: var(--green-soft); }
.status-redeemed { color: #6a552c; background: #f5ecd6; }
.status-disabled { color: #6b6f6c; background: #ecefed; }
.empty-cell { text-align: center; color: var(--muted); padding: 42px; }

@media (max-width: 820px) {
  .redeem-shell { width: min(100% - 32px, 620px); display: block; padding-top: 22px; }
  .redeem-panel { padding: 64px 0 40px; }
  .redeem-panel h1 { font-size: clamp(42px, 13vw, 62px); }
  .steps { border-left: 0; border-top: 1px solid var(--line); padding: 30px 0 0; }
  .site-footer { width: calc(100% - 32px); }
  .admin-shell { width: calc(100% - 28px); padding-top: 26px; }
  .admin-heading { align-items: center; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article:nth-child(2) { border-right: 0; }
  .metric-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .admin-columns { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .redeem-panel { padding-top: 48px; }
  .lead { font-size: 15px; }
  .trust-row { gap: 13px; flex-wrap: wrap; }
  .result-panel, .login-panel { padding: 28px 22px; }
  .admin-topbar { padding: 0 14px; }
  .topbar-actions > a { display: none; }
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-grid article:last-child { border-bottom: 0; }
  .field-grid { grid-template-columns: 1fr; }
}
