:root {
  --bg: #f4f5f7; --surface: #fff; --text: #1f2430; --muted: #6b7280;
  --primary: #2f6f4f; --primary-dark: #245a40; --border: #e3e6ea;
  --ok: #1a7f4b; --ok-bg: #e3f5ec; --no-bg: #eef0f3; --danger: #b42318; --danger-bg: #fdecea;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --surface: #1d2229; --text: #e8eaee; --muted: #9aa3af;
    --border: #2d343d; --ok: #5fd39a; --ok-bg: #173a2a; --no-bg: #2a3038; --danger-bg: #3a1c19; --danger: #ff8a80; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: .5rem 1rem;
  display: flex; align-items: center; gap: 1rem; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
.nav { display: flex; gap: .25rem; }
.nav a { color: var(--text); text-decoration: none; padding: .6rem .9rem; border-radius: 8px; }
.nav a:hover, .nav a.active { background: var(--no-bg); }
.nav a.active { font-weight: 600; }
.content { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
h1, h2 { margin: 0 0 1rem; line-height: 1.25; }
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.tile { display: block; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--primary); }
.tile strong { display: block; font-size: 1.15rem; margin-bottom: .25rem; }
.tile span { color: var(--muted); }
input[type=text], input[type=password] { width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; }
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
label { display: block; font-weight: 600; margin-bottom: .35rem; }
.btn { font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px;
  padding: .8rem 1.25rem; background: var(--primary); color: #fff; min-height: 44px; }
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--no-bg); color: var(--text); }
.search-row { display: flex; gap: .75rem; }
.search-row input { flex: 1; }
.error { background: var(--danger-bg); color: var(--danger); padding: .75rem 1rem;
  border-radius: 10px; margin-bottom: 1rem; }
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-wrap .card { width: 100%; max-width: 380px; }
.login-wrap .field { margin-bottom: 1rem; }
.login-wrap .btn { width: 100%; }
.results { margin-top: 1.25rem; }
.badge { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .85rem;
  font-weight: 600; background: var(--no-bg); color: var(--muted); }
.badge.yes { background: var(--ok-bg); color: var(--ok); }
table { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: 0; }
td.button-cell { text-align: right; }

@media (max-width: 640px) {
  .nav a { padding: .6rem .6rem; font-size: .95rem; }
  .search-row { flex-direction: column; }
  .search-row .btn { width: 100%; }
  table, thead, tbody, tr, td { display: block; }
  table { background: none; border: 0; }
  thead { display: none; }
  tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: .75rem; padding: .5rem 1rem; }
  td { border: 0; padding: .35rem 0; display: flex; justify-content: space-between; gap: 1rem; }
  td::before { content: attr(data-label); color: var(--muted); }
  td.button-cell { display: block; padding-top: .6rem; }
  td.button-cell::before { content: none; }
  td.button-cell .btn { width: 100%; }
}

.note { font-size: .8rem; color: var(--muted); font-weight: 400; }
.badge { margin-right: .25rem; }
.redeem { display: flex; gap: .5rem; justify-content: flex-end; }
.redeem input { width: 6.5rem; padding: .6rem .75rem; text-align: right; }
td[data-label="Code"] { font-weight: 600; word-break: break-all; }
@media (max-width: 640px) {
  td > .note { text-align: right; }
  .redeem input { flex: 1; width: auto; font-size: 16px; }
  .redeem .btn { flex: 1; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.success { background: var(--ok-bg); color: var(--ok); padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
a.btn { display: inline-block; text-decoration: none; text-align: center; line-height: 1.5; }
.form { max-width: 480px; }
.form .field { margin-bottom: 1rem; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.redeem form { margin: 0; }
@media (max-width: 640px) {
  .page-head .btn, .form-actions .btn { flex: 1; }
  .redeem form { flex: 1; }
  .redeem form .btn { width: 100%; }
}
input[type=text], input[type=password] { width: 100%; }
.redeem input[type=text] { width: 6.5rem; }
