:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #eef2ed;
  --ink: #17201a;
  --muted: #637068;
  --line: #d8ded8;
  --primary: #176b45;
  --primary-dark: #0f5234;
  --danger: #a33333;
  --danger-soft: #fff0ef;
  --success: #11623d;
  --success-soft: #eaf7ef;
  --warning: #8a5d0c;
  --shadow: 0 14px 40px rgba(27, 42, 32, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 0; overflow-x: hidden; scroll-behavior: smooth; }
body { margin: 0; min-width: 0; min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--ink); }
a { color: var(--primary-dark); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; }
button, input, select { min-height: 44px; }
button { cursor: pointer; }
img, svg { max-width: 100%; }

.shell { width: min(1180px, 100%); margin: 0 auto; padding-inline: 24px; }
.site-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(216, 222, 216, .9); background: rgba(244, 246, 243, .94); backdrop-filter: blur(12px); }
.header-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 760; text-decoration: none; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px; color: white; background: var(--primary); }
.top-nav { display: flex; align-items: center; gap: 8px; }
.top-nav a, .section-nav a { display: inline-flex; min-height: 44px; align-items: center; padding: 8px 12px; border-radius: 10px; text-decoration: none; }
.top-nav a:hover, .section-nav a:hover { background: var(--surface-soft); }
.page-shell { padding-block: 42px 80px; }

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.03; letter-spacing: -.045em; }
h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.8rem); line-height: 1.15; letter-spacing: -.025em; }
h3 { margin: 0 0 12px; }
.eyebrow { margin: 0 0 10px; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.lede { max-width: 700px; margin: 18px 0 0; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.subtle, .fine-print { color: var(--muted); font-size: .9rem; line-height: 1.6; }

.redeem-layout { display: grid; width: min(720px, 100%); margin: 0 auto; gap: 20px; min-width: 0; }
.hero-card { padding: 28px 4px 16px; }
.card, .metric-card { min-width: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.card { padding: 26px; }
.card > h2 { margin-bottom: 22px; }
.login-layout { display: grid; min-height: min(620px, calc(100vh - 190px)); place-items: center; }
.login-card { width: min(470px, 100%); padding: 34px; }
.login-card h1 { font-size: clamp(2rem, 6vw, 2.8rem); }

.stack-form { display: grid; gap: 12px; min-width: 0; }
label { font-weight: 700; }
input, textarea, select { width: 100%; min-width: 0; border: 1px solid #bdc8bf; border-radius: 11px; background: white; color: var(--ink); padding: 10px 12px; outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible, summary:focus-visible { border-color: var(--primary); outline: 3px solid rgba(23, 107, 69, .17); outline-offset: 2px; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 22px; accent-color: var(--primary); }
input[type="file"] { padding-block: 8px; }

.button { display: inline-flex; min-height: 44px; max-width: 100%; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 11px; padding: 10px 16px; font-weight: 750; text-align: center; text-decoration: none; white-space: normal; }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border-color: #abc0b1; color: var(--primary-dark); background: #f6faf7; }
.button-danger { border-color: #d9a4a0; color: var(--danger); background: var(--danger-soft); }
.button-quiet { border-color: var(--line); color: var(--ink); background: var(--surface); }
.button-small { min-height: 38px; padding: 7px 11px; font-size: .86rem; }
.button-row, .compact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.button-row form, .compact-actions form { margin: 0; }

.alert { border: 1px solid; border-radius: 13px; padding: 13px 15px; line-height: 1.55; overflow-wrap: anywhere; }
.alert-error { border-color: #e4b7b2; color: #7e2828; background: var(--danger-soft); }
.alert-success { border-color: #a9d3ba; color: var(--success); background: var(--success-soft); }
.error-text { color: var(--danger); }
.success-text { color: var(--success); font-weight: 700; }
.empty-state, .empty-cell { color: var(--muted); text-align: center; }

.section-heading { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-heading > * { min-width: 0; }
.status-pill { display: inline-flex; min-height: 28px; flex: 0 0 auto; align-items: center; border-radius: 999px; padding: 4px 10px; color: #455149; background: #e9eeea; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.status-success, .status-available, .status-active, .status-executed { color: #0a623a; background: #e5f5eb; }
.status-failed, .status-disabled, .status-released { color: #922f2f; background: #fdebea; }
.status-processing, .status-running, .status-queued, .status-assigned, .status-reserved, .status-cdk_assigned, .status-manual_reserved, .status-confirmed, .status-redeemed { color: #70500f; background: #fff4d6; }
.status-warning { color: var(--warning); background: #fff0c5; }

.email-list { display: grid; gap: 8px; margin: 16px 0; padding: 0; list-style: none; }
.email-list li { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #f8faf8; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.claim-account-row { display: grid; gap: 7px; font-family: inherit !important; }
.claim-account-main { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.claim-account-email { min-width: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.claim-account-error { color: var(--danger); font-size: .8rem; font-weight: 700; }
.confirmation-box { display: grid; gap: 14px; margin-top: 24px; border-top: 1px solid var(--line); padding-top: 20px; }
.confirmation-box p { margin: 0; line-height: 1.65; }

.admin-heading { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.admin-heading h1 { font-size: clamp(2rem, 5vw, 3rem); }
.section-nav { display: flex; max-width: 100%; flex-wrap: wrap; gap: 4px; margin-bottom: 22px; border-block: 1px solid var(--line); padding-block: 7px; }
.dashboard-section { min-width: 0; margin-top: 24px; scroll-margin-top: 90px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; }
.metric-card { display: grid; gap: 10px; padding: 18px; box-shadow: none; }
.metric-card span { color: var(--muted); font-size: .88rem; }
.metric-card strong { font-size: 2rem; letter-spacing: -.04em; }
.generated-card { border-color: #d9bc70; background: #fffdf7; }
.code-output { min-height: 120px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; }
.or-divider::before, .or-divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }

.inline-form { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(130px, .6fr) auto; align-items: end; gap: 12px; margin-bottom: 22px; }
.inline-form label { display: grid; gap: 7px; }
.selected-batch { margin: 22px 0; border: 1px solid #b5cbbd; border-radius: 14px; padding: 18px; background: #f5faf6; }
.history-details { margin-top: 20px; }
.history-details summary { min-height: 44px; cursor: pointer; font-weight: 750; padding-block: 10px; }

.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 680px; border-collapse: collapse; background: white; font-size: .9rem; }
th, td { max-width: 340px; border-bottom: 1px solid #e5e9e5; padding: 12px; text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
th { color: #536057; background: #f4f7f4; font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.check-cell { width: 74px; text-align: center; }
.email-cell { min-width: 220px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
td form { margin: 0; }

@media (max-width: 720px) {
  .shell { padding-inline: 14px; }
  .page-shell { padding-block: 24px 60px; }
  .site-header { position: static; }
  .header-inner { min-height: 62px; }
  .brand > span:last-child { display: none; }
  .hero-card { padding-top: 14px; }
  .card, .login-card { border-radius: 15px; padding: 18px; }
  .section-heading, .admin-heading { align-items: flex-start; flex-wrap: wrap; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form .button { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-nav { flex-wrap: nowrap; overflow-x: auto; }
  .section-nav a { flex: 0 0 auto; }
  table { min-width: 650px; }
}

@media (max-width: 390px) {
  .shell { padding-inline: 12px; }
  .top-nav a { padding-inline: 9px; }
  .metric-card { padding: 14px; }
  .button-row > .button, .button-row > form { width: 100%; }
  .button-row form .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
