/* EventKassa — one stylesheet, no build step (same as egg-counter).
   Sized for a phone held one-handed at a market stand: big tap targets,
   high contrast, nothing that needs precision. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #667381;
  --line: #d9e0e7;
  --brand: #123c63;
  --brand-ink: #ffffff;
  --ok: #1c7a4a;
  --danger: #b3261e;
  --warn: #8a6100;
  --radius: 12px;
  --tap: 52px;
}

* { box-sizing: border-box; }

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

a { color: var(--brand); }

h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.inline { display: inline; }

/* --- chrome -------------------------------------------------------------- */

.env-banner {
  background: var(--warn);
  color: #fff;
  text-align: center;
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem .75rem;
  flex-wrap: wrap;
  padding: .6rem .9rem;
  background: var(--brand);
  color: var(--brand-ink);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar a { color: var(--brand-ink); text-decoration: none; }
.topbar-title { font-weight: 700; display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.topbar-title .event-name { font-weight: 400; font-size: .9rem; opacity: .85; }
.topbar-nav { display: flex; align-items: center; gap: .75rem; font-size: .9rem; flex-wrap: wrap; min-width: 0; }
.topbar-nav .whoami { opacity: .8; white-space: nowrap; }

.flash {
  padding: .6rem .9rem;
  font-size: .95rem;
}
.flash-error { background: #fde7e6; color: var(--danger); border-bottom: 1px solid #f3c9c7; }
.flash-ok { background: #e4f4ec; color: var(--ok); border-bottom: 1px solid #c6e6d5; }

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .5rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-quiet { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; min-height: 36px; }
.btn-small { min-height: 34px; padding: .2rem .55rem; font-size: .85rem; font-weight: 500; }
.btn-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* --- login --------------------------------------------------------------- */

.login-page { display: grid; place-items: center; min-height: 100dvh; }
.login-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: 0 2px 16px rgba(0,0,0,.08);
  width: min(380px, 92vw);
}
.login-card label { display: block; margin: .8rem 0 .25rem; font-weight: 600; font-size: .9rem; }
.login-card input {
  width: 100%;
  min-height: var(--tap);
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}
.login-card .btn { margin-top: 1.2rem; }

/* --- till ---------------------------------------------------------------- */

.till {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: .75rem .75rem 8.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: .2rem;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: .4rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .6rem;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .55rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.tile-name { font-weight: 700; line-height: 1.2; }
.tile-price { color: var(--muted); font-size: .85rem; }
.tile-pfand { color: var(--warn); font-size: .78rem; }
.tile-buttons { display: flex; gap: .3rem; }
.tile-buttons .btn {
  flex: 1;
  min-height: var(--tap);
  padding: 0;
  font-size: 1rem;
}
.tile-return {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  border-top: 1px dashed var(--line);
  padding-top: .35rem;
  font-size: .8rem;
  color: var(--muted);
}
.tile-return .btn { min-height: 36px; padding: .1rem .6rem; white-space: nowrap; }
.tile-voucher { border-color: var(--ok); }

/* --- cart ---------------------------------------------------------------- */

.cart-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem;
}
.cart { list-style: none; margin: 0 0 .5rem; padding: 0; }
.cart-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .5rem;
  align-items: center;
  padding: .45rem 0;
  border-bottom: 1px solid var(--line);
}
.cart-line:last-child { border-bottom: none; }
.cart-line-label { min-width: 0; }
.cart-line-name { font-weight: 600; overflow-wrap: anywhere; }
.cart-line-meta { font-size: .8rem; color: var(--muted); }
.cart-line-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.cart-line-negative .cart-line-amount { color: var(--ok); }
.cart-line-armed { background: #fff8e1; cursor: pointer; border-radius: 8px; }
.cart-line-armed .cart-line-name::after { content: " · gratis buchen"; color: var(--warn); font-weight: 400; }
.cart-empty { color: var(--muted); margin: .2rem 0 .6rem; }
.cart-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; }
.cart-actions .btn.armed { background: var(--warn); border-color: var(--warn); color: #fff; }
.cart-actions .btn.active { background: var(--ok); border-color: var(--ok); color: #fff; }
.hint { font-size: .85rem; color: var(--warn); margin: .5rem 0 0; }

.recent {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  font-size: .85rem;
}
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { padding: .25rem 0; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: none; }

.totalbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 15;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.total { display: flex; align-items: baseline; justify-content: space-between; }
.total-label { font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.total-amount { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.total-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: .5rem; }
.total-actions .btn { min-height: 56px; font-size: 1.05rem; }

.empty-state { padding: 2.5rem 1rem; text-align: center; }

/* --- dialogs ------------------------------------------------------------- */

.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1rem;
  width: min(360px, 92vw);
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-actions { display: flex; gap: .5rem; margin-top: .9rem; }
.dialog-actions .btn { flex: 1; }

.keypad-display {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: .3rem .5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .5rem;
}
#keypad-label {
  width: 100%;
  min-height: 44px;
  padding: .4rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  margin-bottom: .5rem;
}
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.keypad-key {
  min-height: 56px;
  font-size: 1.3rem;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.revoke-summary { background: var(--bg); border-radius: var(--radius); padding: .6rem; margin: .5rem 0; }
.revoke-summary ul { margin: .3rem 0 0; padding-left: 1.1rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 9.5rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 999px;
  z-index: 40;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  max-width: 90vw;
  text-align: center;
}
.toast-error { background: var(--danger); }

/* --- admin --------------------------------------------------------------- */

.admin { max-width: 1000px; margin: 0 auto; padding: 1rem .9rem 4rem; }
.breadcrumb { margin: 0 0 .5rem; font-size: .9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem;
  margin: 1rem 0;
}

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin: .8rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; text-align: center; }
.stat-value { display: block; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Wide tables scroll inside their own box; the page itself never scrolls
   sideways, which on a phone is the difference between usable and not. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .92rem; }
.table-wrap .table-items, .table-wrap .table-transactions { min-width: 640px; }
.table th, .table td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.row-inactive td { opacity: .55; }
.row-invalidated td { background: #fdf1f0; text-decoration: line-through; }
.row-invalidated .row-actions, .row-invalidated .badge { text-decoration: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.table-lines { font-size: .85rem; background: var(--bg); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge-draft { background: #e7ebef; color: var(--muted); }
.badge-active { background: #d7f0e2; color: var(--ok); }
.badge-closed { background: #e7ebef; color: var(--ink); }
.chip { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0 .45rem; font-size: .75rem; margin-right: .2rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; font-weight: 600; }
.form-grid input, .form-grid select, .form-inline select, .form-inline input {
  min-height: 44px;
  padding: .4rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 400;
}
.form-grid .checkboxes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .8rem; border: none; margin: 0; padding: 0; }
.checkboxes label { flex-direction: row; align-items: center; gap: .35rem; font-weight: 500; }
.checkboxes input { min-height: 22px; width: 22px; height: 22px; }
.form-grid .button-row { grid-column: 1 / -1; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row-actions input[type="password"] { min-height: 34px; padding: .2rem .4rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .85rem; width: 9rem; }

@media (max-width: 560px) {
  .table-transactions, .table-items { font-size: .85rem; }
  .total-amount { font-size: 1.7rem; }
  /* On a phone the account name is the first thing worth dropping: the
     cashier knows who they are, and "Abmelden" must stay reachable. */
  .topbar-nav .whoami { display: none; }
  .topbar { padding: .5rem .6rem; }
  .topbar-nav { gap: .55rem; font-size: .85rem; }
}
