:root {
  --bg: #fff8ef;
  --surface: #ffffff;
  --surface-soft: #fff1df;
  --ink: #221810;
  --muted: #7f7065;
  --brand: #f47a2a;
  --brand-dark: #c84e0f;
  --brand-soft: #ffe1c3;
  --green: #159447;
  --green-soft: #eaf8ef;
  --red: #cf3b3b;
  --red-soft: #fff0f0;
  --yellow: #f4b63a;
  --line: #eadfd4;
  --shadow: 0 18px 50px rgba(69, 41, 19, .10);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.page-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 8% 0%, rgba(244,122,42,.16), transparent 28%),
    radial-gradient(circle at 100% 8%, rgba(244,182,58,.12), transparent 26%),
    var(--bg);
}
.shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 22px 18px 56px;
}
.customer-shell { width: min(100%, 760px); }

/* Shared brand */
.brandbar, .brand, .brand-actions { display: flex; align-items: center; }
.brandbar { justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.brand { gap: 12px; min-width: 0; }
.brand-actions { gap: 8px; min-width: 0; }
.brand-mark, .portal-footer-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 17px;
  color: #fff;
  font-weight: 900;
  font-size: 20px;
  background: linear-gradient(145deg, #ff8a35, #f46d1b);
  box-shadow: 0 12px 28px rgba(244,122,42,.24);
}
.brand-title { font-weight: 900; font-size: 20px; letter-spacing: -.025em; white-space: nowrap; }
.brand-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mini-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  background: #faf5ee;
  color: #6f6258;
  font-size: 12px;
  white-space: nowrap;
}
.refresh-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.86);
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(69,41,19,.06);
}
.refresh-btn.is-refreshing { animation: spin .75s linear infinite; }

/* Customer hero */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 7vw, 42px);
  border-radius: var(--radius-xl);
  color: #fff;
  background:
    radial-gradient(circle at 100% 0%, rgba(239,145,51,.34), transparent 38%),
    linear-gradient(145deg, #28170f 0%, #552811 100%);
  box-shadow: var(--shadow);
}
.eyebrow {
  margin-bottom: 12px;
  color: #ffd3b0;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0;
  max-width: 650px;
  font-size: clamp(30px, 8.4vw, 54px);
  line-height: .99;
  letter-spacing: -.055em;
}
.hero p {
  margin: 20px 0 0;
  max-width: 620px;
  color: rgba(255,255,255,.80);
  font-size: clamp(14px, 3.7vw, 18px);
  line-height: 1.65;
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 32px 0 14px;
}
.section-head h2 { margin: 0; font-size: clamp(24px, 6vw, 34px); letter-spacing: -.04em; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }

/* Promo cards */
.promo-grid { display: grid; gap: 15px; }
.card, .promo-card, .admin-promo, .stat-card, .redeem-card, .history-row {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(69,41,19,.065);
}
.card, .promo-card, .admin-promo { border-radius: var(--radius-lg); }
.card { padding: 20px; }
.card.empty { color: var(--muted); text-align: center; }
.promo-card { width: 100%; min-width: 0; padding: clamp(18px, 5vw, 26px); overflow: hidden; }
.promo-card.disabled { opacity: .72; }
.promo-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.promo-icon, .big-icon {
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: #fff3e4;
}
.promo-icon { width: 56px; height: 56px; font-size: 30px; }
.big-icon { width: 64px; height: 64px; font-size: 34px; }
.status-pill, .role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-pill.active { color: var(--green); background: var(--green-soft); }
.status-pill.coming { color: #95670c; background: #fff6db; }
.status-pill.sold { color: var(--red); background: var(--red-soft); }
.promo-card h3, .admin-promo h3 { margin: 20px 0 8px; font-size: clamp(22px, 5.5vw, 30px); letter-spacing: -.035em; }
.promo-card > p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 15px; }
.promo-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 15px;
  border: 0;
  border-radius: 14px;
  font-weight: 850;
  font-size: 14px;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:disabled { cursor: default; opacity: .55; }
.btn-block { width: 100%; }
.btn-primary { color: #fff; background: linear-gradient(135deg, #ff842c, #f36d1d); box-shadow: 0 10px 22px rgba(244,122,42,.22); }
.btn-ghost { color: var(--ink); background: #f7f1eb; }
.btn-dark { color: #fff; background: #28170f; }
.btn-success { color: #fff; background: var(--green); }
.btn-danger { color: #fff; background: var(--red); }

/* Footer */
.portal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 150px;
  padding: 28px 8px 12px;
  color: var(--muted);
}
.portal-footer-mark { width: 48px; height: 48px; border-radius: 15px; font-size: 18px; }
.portal-footer-title { color: var(--ink); font-weight: 900; }
.portal-footer-sub { margin-top: 2px; font-size: 12px; }

/* Modal / forms */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(28,18,12,.58);
  backdrop-filter: blur(8px);
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(100%, 620px);
  max-height: min(88vh, 760px);
  overflow: auto;
  padding: 20px;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0,0,0,.22);
  overscroll-behavior: contain;
}
.modal-handle { width: 42px; height: 5px; margin: -4px auto 18px; border-radius: 999px; background: #e5ddd5; }
.modal-title { display: flex; align-items: center; gap: 14px; }
.modal-title h2 { margin: 5px 0 0; font-size: clamp(24px, 6vw, 34px); letter-spacing: -.04em; }
.form-group { margin-top: 15px; }
.form-group label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 850; }
.input, .textarea, .select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  color: var(--ink);
  background: #fffdfb;
  font-size: 16px;
  transition: border .15s ease, box-shadow .15s ease;
}
.input, .select { min-height: 48px; padding: 11px 13px; }
.textarea { min-height: 96px; resize: vertical; padding: 12px 13px; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(244,122,42,.13); }
.notice { padding: 13px 14px; border-radius: 14px; font-size: 13px; line-height: 1.55; }
.notice.info { color: #71491f; background: #fff2df; }
.notice.success { color: #136d36; background: var(--green-soft); }
.notice.error { color: #a82323; background: var(--red-soft); }
.redeem-box { padding: 22px; border: 1px dashed #f0b077; border-radius: 20px; text-align: center; background: #fff7ee; }
.redeem-code { margin: 8px 0 4px; font-size: clamp(42px, 13vw, 62px); font-weight: 950; letter-spacing: .08em; line-height: 1; }
.countdown { margin-top: 8px; color: var(--brand-dark); font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 11px 15px;
  border-radius: 999px;
  color: #fff;
  background: #24160f;
  box-shadow: 0 12px 38px rgba(0,0,0,.2);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Admin login */
.login-wrap {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 0 0, rgba(244,122,42,.18), transparent 30%),
    var(--bg);
}
.login-card { width: min(100%, 430px); padding: 28px; border: 1px solid var(--line); border-radius: 26px; background: #fff; box-shadow: var(--shadow); }
.pin-field-wrap { position: relative; }
.pin-field-wrap .input { padding-right: 52px; }
.pin-eye-btn {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  font-size: 17px;
}
.pin-eye-btn:hover { background: #fff2e5; }

/* Admin layout */
.admin-layout { display: grid; grid-template-columns: 225px minmax(0, 1fr); gap: 22px; align-items: start; }
.sidebar {
  position: sticky;
  top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 14px 40px rgba(69,41,19,.07);
}
.sidebar .brand-mark { width: 44px; height: 44px; border-radius: 14px; font-size: 17px; }
.sidebar .brand-title { font-size: 17px; }
.nav { display: grid; gap: 6px; margin-top: 20px; }
.nav button {
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 12px;
  text-align: left;
  color: #65574d;
  background: transparent;
  font-weight: 750;
}
.nav button:hover, .nav button.active { color: var(--ink); background: #fff1e2; }
.hidden { display: none !important; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.admin-top h1 { margin: 0; font-size: 32px; letter-spacing: -.045em; }
.role-pill { color: #8b4b14; background: #fff0df; }
.panel { display: none; }
.panel.active { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.stat-card { padding: 18px; border-radius: 18px; }
.stat-value { font-size: 30px; font-weight: 950; letter-spacing: -.04em; }
.stat-label { margin-top: 4px; color: var(--muted); font-size: 12px; }
.redeem-list, .history-list { display: grid; gap: 10px; }
.redeem-card {
  display: grid;
  grid-template-columns: 104px minmax(0,1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 15px;
  border-radius: 18px;
}
.redeem-card .code { font-size: 21px; font-weight: 950; letter-spacing: .06em; }
.redeem-card .info { min-width: 0; }
.redeem-card .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.redeem-card .sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.timer-chip { color: var(--brand-dark); font-weight: 900; font-variant-numeric: tabular-nums; }
.redeem-actions { display: flex; gap: 7px; }
.admin-promo-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.admin-promo { padding: 18px; min-width: 0; }
.admin-promo .actions { display: flex; gap: 8px; margin-top: 14px; }
.history-tools { margin-bottom: 12px; }
.history-row {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr .7fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border-radius: 15px;
  font-size: 13px;
}

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

@media (max-width: 900px) {
  .admin-layout { display: block; }
  .sidebar { position: static; margin-bottom: 16px; padding: 14px; }
  .nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
  .nav button { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .admin-promo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .shell { padding: 14px 12px 38px; }
  .customer-shell { width: 100%; }
  .brandbar { margin-bottom: 16px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 14px; font-size: 17px; }
  .brand-title { font-size: 17px; }
  .brand-subtitle { font-size: 12px; }
  .brand-actions .mini-chip { display: none; }
  .refresh-btn { width: 38px; height: 38px; flex-basis: 38px; }
  .hero { padding: 24px 20px; border-radius: 22px; }
  .hero h1 { font-size: clamp(29px, 8.3vw, 38px); }
  .hero p { margin-top: 15px; font-size: 14px; line-height: 1.58; }
  .section-head { margin: 25px 0 11px; }
  .section-head h2 { font-size: 25px; }
  .promo-card { padding: 18px; border-radius: 20px; }
  .promo-icon { width: 50px; height: 50px; font-size: 27px; }
  .promo-card h3 { margin-top: 17px; font-size: 23px; }
  .promo-card > p { font-size: 14px; }
  .mini-chip { font-size: 11px; padding: 6px 9px; }
  .btn { min-height: 43px; font-size: 14px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 90svh; border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .portal-footer { min-height: 125px; padding-top: 24px; }
  .redeem-card { grid-template-columns: 1fr; gap: 10px; }
  .redeem-actions { width: 100%; }
  .redeem-actions .btn { flex: 1; }
  .history-row { grid-template-columns: 1fr 1fr; }
  .admin-top h1 { font-size: 27px; }
}

@media (max-width: 380px) {
  .shell { padding-left: 10px; padding-right: 10px; }
  .hero { padding: 22px 17px; }
  .hero h1 { font-size: 28px; }
  .promo-card { padding: 16px; }
  .status-pill { padding: 7px 9px; font-size: 10px; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 26px; }
}
