:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-alt: #F4EDE3;
  --espresso: #2C1E16;
  --muted: #665245;
  --terracotta: #C85A32;
  --sage: #4A6B53;
  --border: #E5D9CA;
  --green: #1F7A4D;
  --green-bg: #EAF7F0;
  --red: #B8292F;
  --red-bg: #FDECEC;
  --amber: #B4690E;
  --amber-bg: #FEF5E7;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--espresso);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: var(--espresso);
  color: #FAF7F2;
  padding: 14px 16px;
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  color: #FAF7F2;
  text-decoration: none;
}

.brand-sub {
  font-size: 12px;
  color: #D8C9B8;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(250, 247, 242, 0.28);
  color: #FAF7F2;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 44px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(44, 30, 22, 0.06);
  margin-bottom: 18px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.banner-warn {
  background: var(--amber-bg);
  border: 1px solid #F2D3A0;
  color: #7D4908;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* PIN Login */
.pin-card {
  text-align: center;
}

.pin-input {
  width: 100%;
  max-width: 220px;
  height: 58px;
  margin: 12px auto;
  display: block;
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 10px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--espresso);
}

.pin-input:focus {
  outline: none;
  border-color: var(--terracotta);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--terracotta);
  color: #FFFFFF;
}

.btn-green {
  background: var(--green);
  color: #FFFFFF;
  width: 100%;
  min-height: 58px;
  font-size: 18px;
}

.btn-amber {
  background: var(--amber);
  color: #FFFFFF;
  width: 100%;
  min-height: 50px;
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--espresso);
  border: 1px solid var(--border);
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 9px;
}

/* Status cards on /redeem/:token */
.status-banner {
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
  border: 2px solid;
}

.status-banner.status-valid {
  background: var(--green-bg);
  border-color: var(--green);
  color: #124E31;
}

.status-banner.status-redeemed {
  background: var(--red-bg);
  border-color: var(--red);
  color: #7D1A1E;
}

.status-banner.status-expired {
  background: var(--amber-bg);
  border-color: var(--amber);
  color: #7A4607;
}

.status-kicker {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status-headline {
  margin: 6px 0 4px;
  font-size: 24px;
  font-weight: 900;
}

.detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}

.detail-label {
  color: var(--muted);
  font-weight: 600;
}

.detail-val {
  font-weight: 700;
  text-align: right;
  word-break: break-word;
}

/* Scanner & Forms */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.scanner-box {
  background: #1C130E;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FAF7F2;
  margin-bottom: 12px;
}

.scanner-box video {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

.scanner-status {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--espresso);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--espresso);
  font-size: 14.5px;
}

.input:focus {
  outline: none;
  border-color: var(--terracotta);
  background: #FFFFFF;
}

/* Analytics Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
}

.pill-active {
  background: var(--green-bg);
  color: var(--green);
}

.pill-paused {
  background: #EFEAE4;
  color: var(--muted);
}

.pill-redeemed {
  background: #E8F1FB;
  color: #1E5A9C;
}

.pill-expired {
  background: var(--amber-bg);
  color: var(--amber);
}

.offer-row-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg);
}

.offer-row-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 10px;
  display: none;
}

.alert.is-visible {
  display: block;
}

.alert-ok {
  background: var(--green-bg);
  color: var(--green);
}

.alert-err {
  background: var(--red-bg);
  color: var(--red);
}

.is-hidden {
  display: none !important;
}
