:root {
  /* palette pulled from the pitch deck */
  --bg:        #0a0a0b;
  --surface:   #161618;
  --surface-2: #1f1f23;
  --line:      #2a2a30;
  --text:      #f5f5f7;
  --muted:     #8a8a92;
  --green:     #34d399;   /* primary accent */
  --green-dim: #0e2a1e;   /* active background */
  --green-line:#1f5c43;
  --danger:    #f87171;

  --radius:    14px;
  --radius-sm: 9px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

h2 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: 0 0 12px; color: var(--text); }

.panel-sub { color: var(--muted); margin: 6px 0 18px; font-size: 0.93rem; }

/* ---------------------------- header ---------------------------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0d0d0f 0%, var(--bg) 100%);
  padding: 26px 0;
}
.header-inner {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; gap: 4px; }
.wordmark {
  font-size: 2.1rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1;
}
.wordmark .dot { color: var(--green); }
.tagline { color: var(--muted); font-style: italic; font-size: 0.95rem; }

.stat-bar { display: flex; gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 18px; min-width: 120px; text-align: right;
}
.stat-value { display: block; font-size: 1.7rem; font-weight: 800; color: var(--green); letter-spacing: -0.02em; }
.stat-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* ---------------------------- panels ---------------------------- */
main { padding: 28px 0 8px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
}
.hero-panel { border-color: var(--green-line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.count-pill, .demo-tag {
  font-size: 0.7rem; background: var(--green-dim); color: var(--green);
  border: 1px solid var(--green-line); border-radius: 999px; padding: 2px 9px;
  vertical-align: middle; font-weight: 600;
}
.demo-tag { margin-left: 6px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* ------------------------ purchase form ------------------------- */
.purchase-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 110px; }

input, select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 0.95rem; font-family: inherit; min-width: 150px;
}
input:focus, select:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
input::placeholder { color: #5a5a62; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-error { color: var(--danger); font-size: 0.85rem; min-height: 1em; margin: 10px 0 0; width: 100%; }
.form-error:empty { margin: 0; }

/* ---------------------------- buttons --------------------------- */
.btn {
  font-family: inherit; font-size: 0.92rem; font-weight: 600;
  border-radius: var(--radius-sm); padding: 10px 18px; cursor: pointer;
  border: 1px solid transparent; transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 13px; font-size: 0.85rem; }
.btn-primary { background: var(--green); color: #04130c; }
.btn-primary:hover { background: #2bbd86; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--green-line); color: var(--green); }
.btn-danger { background: transparent; color: var(--danger); border-color: #4a2222; }
.btn-danger:hover { background: #2a1414; }

/* ------------------------ recommendation ------------------------ */
.recommendation { margin-top: 20px; }
.rec-empty {
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  padding: 22px; text-align: center; color: var(--muted);
}
.rec-result {
  border: 1px solid var(--green-line); background: var(--green-dim);
  border-radius: var(--radius); padding: 18px; animation: pop 0.18s ease;
}
.rec-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.rec-winner-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--green); }
.rec-card-name { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.rec-detail { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.rec-savings { text-align: right; }
.rec-savings .amt { font-size: 1.9rem; font-weight: 800; color: var(--green); letter-spacing: -0.02em; }
.rec-savings .lbl { font-size: 0.75rem; color: var(--muted); }
.rec-ranked { margin-top: 16px; border-top: 1px solid var(--green-line); padding-top: 12px; }
.rec-ranked ol { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: 0.86rem; }
.rec-ranked li { margin: 3px 0; }
.rec-ranked .rank-val { color: var(--text); font-variant-numeric: tabular-nums; }
.rec-log { margin-top: 14px; }

/* --------------------------- wallet ----------------------------- */
.wallet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card-tile {
  position: relative; border-radius: var(--radius); padding: 14px;
  min-height: 92px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35); overflow: hidden;
}
.card-tile .issuer { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; font-family: var(--font-mono); }
.card-tile .cardno { font-family: var(--font-mono); font-size: 0.78rem; opacity: 0.8; letter-spacing: 0.12em; }
.card-tile .name { font-weight: 700; font-size: 0.95rem; }
.card-remove {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; line-height: 1;
  border-radius: 50%; border: none; background: rgba(0,0,0,0.4); color: #fff;
  cursor: pointer; font-size: 1rem;
}
.card-remove:hover { background: rgba(0,0,0,0.7); }
.wallet-empty { color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 18px; text-align: center; }

/* add-card / presets */
.add-card { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.add-card summary { cursor: pointer; font-weight: 600; color: var(--green); }
.preset-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.preset {
  display: flex; align-items: center; gap: 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
.preset .swatch { width: 34px; height: 22px; border-radius: 4px; flex-shrink: 0; }
.preset .p-name { font-weight: 600; font-size: 0.9rem; }
.preset .p-rewards { color: var(--muted); font-size: 0.78rem; }
.preset .p-add { margin-left: auto; }
.preset .p-add[disabled] { opacity: 0.4; cursor: default; }
.custom-form { margin-top: 18px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; }

/* --------------------------- offers ----------------------------- */
.offers-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.offer {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.offer.active { border-color: var(--green-line); background: var(--green-dim); }
.offer .o-info { flex: 1; min-width: 0; }
.offer .o-merchant { font-weight: 600; font-size: 0.92rem; }
.offer .o-label { color: var(--muted); font-size: 0.8rem; }
.offer.active .o-label { color: var(--green); }

/* toggle switch */
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background 0.15s ease;
  pointer-events: none;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform 0.15s ease; pointer-events: none;
}
.switch input:checked ~ .track { background: var(--green); }
.switch input:checked ~ .thumb { transform: translateX(20px); }
.switch input:focus-visible ~ .track { outline: 2px solid var(--green); outline-offset: 2px; }

/* --------------------------- history ---------------------------- */
.reset-controls { display: flex; gap: 8px; }
.breakdown { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.breakdown .chip {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 0.8rem; color: var(--muted);
}
.breakdown .chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.history-list li:last-child { border-bottom: none; }
.h-merchant { font-weight: 600; font-size: 0.92rem; }
.h-meta { color: var(--muted); font-size: 0.8rem; }
.h-amount { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.h-amount .saved { color: var(--green); font-size: 0.82rem; display: block; }
.history-empty { color: var(--muted); padding: 16px 0; }

/* ---------------------------- footer ---------------------------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 20px; padding: 24px 0 40px; color: var(--muted); font-size: 0.85rem; }
.site-footer .fine { font-size: 0.78rem; opacity: 0.8; margin-top: 6px; }

/* --------------------------- motion ----------------------------- */
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, .btn, .switch .thumb, .switch .track { transition: none !important; animation: none !important; }
}

/* -------------------------- responsive -------------------------- */
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .stat-bar { width: 100%; }
  .stat { flex: 1; text-align: left; }
  .wordmark { font-size: 1.8rem; }
  .purchase-form { gap: 12px; }
  .field, input, select { width: 100%; min-width: 0; }
  .rec-savings { text-align: left; }
}
