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

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar strong { display: block; font-size: 16px; }
.topbar-actions { display: flex; gap: 8px; }

.boot { padding: 48px 20px; text-align: center; color: var(--muted); }

/* --- 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; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.login-card input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.page { max-width: 1520px; margin: 0 auto; padding: 20px 20px 56px; }

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

/* --- Számlapok --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.tile dt {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.tile dd {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.tile-amount {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tile.is-active dd { color: var(--ok); }
.tile.is-redeemed dd { color: var(--warn); }

/* --- Vezérlők --- */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.controls .field { min-width: 0; }
.controls select { text-overflow: ellipsis; }

/* Asztali gépen egy sorban fér el mind a hat vezérlő. */
@media (min-width: 1000px) {
  .controls { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.controls .label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}
.controls select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.controls select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chart-sum { margin: 12px 0 0; }
.empty { padding: 40px 0; text-align: center; }

/* --- Panel és diagram --- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.panel-head { margin-bottom: 12px; }
.panel-head h2 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }
.panel-head p { margin: 0; }

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 520px; height: auto; }

.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-fill { fill: var(--accent); }
.chart-bar:hover .chart-fill { fill: var(--accent-dark); }

/* A feliratok szövegszínt viselnek, nem az oszlopét. */
.chart-value {
  fill: var(--text);
  font: 600 13px/1 system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}
.chart-value.is-zero { fill: var(--muted); font-weight: 400; }
.chart-label { fill: var(--muted); font: 400 12px/1 system-ui, -apple-system, sans-serif; }
.chart-year { fill: var(--muted); font: 600 10px/1 system-ui, -apple-system, sans-serif; letter-spacing: .06em; }

.footnote { margin: 24px 0 0; }

/* --- Voucher lista --- */
.list-search { margin-bottom: 14px; }
.list-search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.list-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#voucher-table { min-width: 1320px; }
#voucher-table td { vertical-align: top; }
/* A voucher kód egy sorban maradjon - a táblázat inkább gördüljön oldalra. */
.cell-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  white-space: nowrap;
}
.cell-muted { color: var(--muted); }
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.active { background: #e7f4ec; color: var(--ok); }
.pill.used { background: #fbf1de; color: var(--warn); }
.pill.pending { background: #eef1f7; color: #3c4a6b; }
.cell-note { font-size: 13px; white-space: nowrap; }

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

/* --- Kategóriatábla --- */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 560px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th {
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-total td { font-weight: 600; border-bottom: none; border-top: 2px solid var(--border); }

.btn.small { padding: 4px 10px; font-size: 13px; text-decoration: none; display: inline-block; }

/* --- Megerősítő ablak és visszajelzés --- */
dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-body { padding: 22px; display: grid; gap: 12px; }
.dialog-body h2 { margin: 0; font-size: 18px; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; word-break: break-word; }
.danger-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  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-error { background: var(--danger); }

#pending-table { min-width: 860px; }
#pending-table td { vertical-align: top; }
