:root {
  --honey: #f5b700;
  --honey-soft: #fff3c4;
  --ink: #1f1b12;
  --ink-2: #4a4434;
  --muted: #6f6853;
  --line: #e6dfcc;
  --bg: #fffbf0;
  --card: #ffffff;
  --green: #0f7a43;
  --green-soft: #e3f5ea;
  --red: #b3261e;
  --red-soft: #fde7e5;
  --blue: #1d5fa8;
  --blue-soft: #e5effa;
  --amber: #8a5a00;
  --amber-soft: #fff0cc;
  --gray-soft: #efece4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 27, 18, .06), 0 4px 14px rgba(31, 27, 18, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--blue); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 64px; outline: none; }
main.wide { max-width: 1100px; }

.test-banner {
  background: repeating-linear-gradient(-45deg, #1f1b12 0 12px, #2c2618 12px 24px);
  color: #fff3c4; font-size: .82rem; padding: 6px 16px; text-align: center;
}
.test-banner a { color: var(--honey); font-weight: 600; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand span { color: var(--amber); }
#nav { display: flex; gap: 4px; flex-wrap: wrap; }
#nav a, #nav button {
  font: inherit; font-size: .92rem; color: var(--ink-2); text-decoration: none; padding: 6px 10px;
  border-radius: 999px; border: 0; background: none; cursor: pointer;
}
#nav a.active { background: var(--honey-soft); color: var(--ink); font-weight: 600; }

/* Cards and badges */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.link-card { display: block; color: inherit; text-decoration: none; }
.card.link-card:hover { border-color: var(--honey); }
.card.dim { opacity: .75; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; }
.badge.test { background: #1f1b12; color: var(--honey); }
.badge.live { background: var(--green-soft); color: var(--green); }
.badge.not_started { background: var(--blue-soft); color: var(--blue); }
.badge.paused { background: var(--amber-soft); color: var(--amber); }
.badge.expired, .badge.business_inactive, .badge.used { background: var(--gray-soft); color: var(--muted); }
.badge.claimed { background: var(--honey-soft); color: var(--amber); }
.biz { color: var(--muted); font-size: .9rem; margin-bottom: 2px; }
.offer-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.meta { color: var(--muted); font-size: .9rem; }
.fine { color: var(--muted); font-size: .85rem; border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 12px; }

/* Notices */
.notice { border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-size: .95rem; }
.notice.info { background: var(--blue-soft); color: #123b69; }
.notice.warn { background: var(--amber-soft); color: #5c3c00; }
.notice.error { background: var(--red-soft); color: #7a1912; }
.notice.ok { background: var(--green-soft); color: #0b5530; }
.notice.used { background: var(--gray-soft); color: var(--ink-2); }
.notice.sim { background: #1f1b12; color: #fff3c4; }
.notice.sim a { color: var(--honey); }

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; border-radius: 12px; border: 1px solid transparent;
  padding: 12px 18px; cursor: pointer; text-decoration: none; min-height: 48px;
  background: var(--honey); color: var(--ink);
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.linkish { background: none; border: 0; color: var(--blue); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input[type=text], input[type=email], input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid #cfc6ad; border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid rgba(245, 183, 0, .5); outline-offset: 1px; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* Staff PIN pad */
.staff-screen { background: #1f1b12; color: #fff; border-radius: 20px; padding: 20px 16px; text-align: center; }
.staff-screen .staff-label { display: inline-block; background: var(--honey); color: var(--ink); font-weight: 800; letter-spacing: .1em; padding: 4px 12px; border-radius: 999px; font-size: .8rem; }
.staff-screen h1 { color: #fff; margin-top: 12px; }
.staff-screen .meta { color: #d8d0b8; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 18px 0; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--honey); }
.pin-dots span.on { background: var(--honey); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; }
.keypad button { font: inherit; font-size: 1.6rem; font-weight: 600; min-height: 64px; border-radius: 14px; border: 0; background: #3a3424; color: #fff; cursor: pointer; }
.keypad button:active { background: #57503a; }
.keypad button.fn { font-size: 1rem; background: #2a2519; }
.staff-screen .notice { text-align: left; }
.staff-screen a { color: var(--honey); }

/* Redeemed screen */
.redeemed { background: var(--green); color: #fff; border-radius: 22px; padding: 28px 18px; text-align: center; position: relative; overflow: hidden; }
.redeemed .check { width: 92px; height: 92px; margin: 0 auto 10px; border-radius: 50%; background: #fff; color: var(--green); display: grid; place-items: center; font-size: 3rem; font-weight: 900; animation: pulse 1.6s ease-in-out infinite; }
.redeemed h1 { color: #fff; font-size: 2.4rem; letter-spacing: .08em; }
.redeemed .big { font-size: 1.2rem; font-weight: 700; }
.redeemed .conf { font-size: 2rem; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; background: rgba(255, 255, 255, .15); border-radius: 12px; padding: 6px 12px; display: inline-block; margin: 8px 0; }
.redeemed .clock { font-size: 1.5rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.redeemed .sweep { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .18) 50%, transparent 70%); animation: sweep 2.4s linear infinite; pointer-events: none; }
.redeemed .small { font-size: .85rem; opacity: .9; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .redeemed .check, .redeemed .sweep { animation: none; } }

/* Admin */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 16px; }
.tabs a { padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); background: var(--gray-soft); font-size: .9rem; }
.tabs a.active { background: var(--ink); color: var(--honey); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .n { font-size: 1.8rem; font-weight: 800; }
.stat .l { color: var(--muted); font-size: .85rem; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #faf6ea; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .btn { margin: 2px 4px 2px 0; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 10px; align-items: end; margin-bottom: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* Test mailbox */
.mail { border-left: 4px solid var(--honey); }
.mail .code { font-size: 1.8rem; font-weight: 800; letter-spacing: .25em; font-variant-numeric: tabular-nums; }
.loading { color: var(--muted); padding: 24px 0; }

/* Offer images (optional). Offers without an image keep the plain card look. */
.link-card.has-image { display: flex; gap: 12px; align-items: flex-start; }
.card-body { flex: 1; min-width: 0; }
.card-thumb { flex: none; width: 88px; height: 88px; object-fit: cover; border-radius: 10px; background: var(--gray-soft); }
@media (max-width: 380px) { .card-thumb { width: 72px; height: 72px; } }
.offer-hero {
  display: block; width: calc(100% + 32px); max-width: none; margin: -16px -16px 14px;
  aspect-ratio: 16 / 10; object-fit: contain; background: #f6f1e3;
  border-radius: var(--radius) var(--radius) 0 0;
}
.admin-thumb { float: right; width: 48px; height: 48px; object-fit: cover; border-radius: 8px; margin-left: 8px; }
.image-editor { border-top: 1px dashed var(--line); margin-top: 18px; padding-top: 12px; }
.image-editor h4 { margin: 0 0 8px; }
.img-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.img-preview { width: 120px; height: 120px; border-radius: 10px; background: var(--gray-soft); display: grid; place-items: center; overflow: hidden; flex: none; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview span { color: var(--muted); font-size: .8rem; text-align: center; padding: 8px; }
.img-controls { flex: 1; min-width: 200px; }
.img-controls label { margin-top: 0; }
input[type=file] { font: inherit; max-width: 100%; }

/* Share links panel (admin) */
.links-panel .link-out { background: var(--gray-soft); border-radius: 10px; padding: 10px 12px; word-break: break-all; font-size: .9rem; margin-top: 8px; }
