:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e3e1dc;
  --text: #1c1b19;
  --muted: #6f6b64;
  --accent: #8a1c26;
  --accent-text: #ffffff;
  --ok: #1c6b3f;
  --ok-bg: #e7f4ec;
  --warn: #8a5a10;
  --warn-bg: #fbf1de;
  --danger: #a32020;
  --danger-bg: #fbeaea;
  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* A sajat display szabalyaink kulonben felulirnak a hidden attributumot. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.boot { padding: 48px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

/* --- Gombok, mezők --- */
button, input { font: inherit; }

input[type="password"], input[type="search"], input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 14px; }

.error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
}

/* --- Bejelentkezés --- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  display: grid;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; font-size: 14px; }

/* --- Fejléc, elrendezés --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app { max-width: 1080px; margin: 0 auto; padding: 16px 16px 48px; }
.search-block { margin-bottom: 14px; }
.search-row { display: flex; gap: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.chip.is-active { background: var(--text); border-color: var(--text); color: #fff; }

.status-line { margin: 0 0 12px; font-size: 14px; }

/* --- Legördülő szűrők --- */
.selects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.selects .field { min-width: 0; }

/* Asztali gépen egy sorban fér el mind az öt szűrő. */
@media (min-width: 900px) {
  .selects { grid-template-columns: repeat(5, minmax(0, 1fr)) auto; }
}
.selects select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.selects select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#filters-reset { align-self: end; }

.req {
  font-weight: 600;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
}

/* --- Találatok --- */
.results { display: grid; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.code { font: 600 18px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5px; word-break: break-all; }
.type { margin-top: 2px; font-size: 14px; color: var(--muted); }
.category {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.badges { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }

.badge {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.redeemed { background: var(--warn-bg); color: var(--warn); }
.badge.expired { background: var(--danger-bg); color: var(--danger); }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.card-actions { display: flex; justify-content: flex-end; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }

/* --- Párbeszédablak --- */
dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-body { padding: 22px; display: grid; gap: 10px; }
.dialog-body h2 { margin: 0; font-size: 18px; }
.dialog-code {
  margin: 0;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font: 600 21px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .5px;
  text-align: center;
  word-break: break-all;
}

.danger-note {
  margin: 2px 0 4px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
}

.summary { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 6px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  z-index: 20;
}
.toast.is-warn { background: var(--warn); }
.toast.is-error { background: var(--danger); }
