/* Club Event Ticketing — touch-first design system */

:root {
  --t1200: #ffd54a;   /* yellow — front premium  */
  --t750:  #7ed492;   /* green — middle          */
  --t500:  #9fd3f2;   /* light blue — back block */
  --booked: #c7cbd6;  /* grey — sold             */
  --sponsor: #8fa7ff; /* blue — sponsor-reserved */

  --ink: #1c2333;
  --ink-soft: #55607a;
  --line: #dde3ee;
  --bg: #eef1f7;
  --card: #ffffff;
  --primary: #26324a;
  --primary-ink: #ffffff;
  --ok: #1f7a3d;
  --ok-bg: #e2f4e8;
  --warn: #9a6b00;
  --warn-bg: #fdf0d3;
  --bad: #b3261e;
  --bad-bg: #fde5e3;
  --zoom: 1;
  --seat-base: 34px;
  --seat: calc(var(--seat-base) * var(--zoom));
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.error { color: var(--bad); min-height: 1em; margin: 8px 0 0; }

/* ---------------- screens ---------------- */

.screen { min-height: 100dvh; }
.login-wrap {
  position: fixed; inset: 0; z-index: 40; overflow: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #26324a 0%, #3b4d75 100%);
}
.login-card {
  width: 100%; max-width: 380px; padding: 30px 28px;
  text-align: center;
}
.login-card h1 { font-size: 24px; margin: 10px 0 4px; }
.brand-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; font-size: 28px; border-radius: 16px;
  background: #ffffff22; color: #fff;
}
.login-card .brand-badge { background: #ffffff26; }
.appbar .brand-badge.sm {
  width: 34px; height: 34px; font-size: 18px; border-radius: 10px;
  background: var(--primary); color: #fff;
}

/* ---------------- topbar (ONE sticky unit: appbar + tabs) ---------------- */

.topbar { position: sticky; top: 0; z-index: 20; background: var(--card);
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 8px #1c233314; }
.appbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; min-height: 52px; flex-wrap: wrap;
}
.appbar-title { font-weight: 700; flex: 1; min-width: 120px; }
.appbar-user { display: flex; align-items: center; gap: 8px; font-weight: 600; }

.tabs { display: flex; gap: 4px; padding: 0 10px 8px; overflow-x: auto; }
.tab {
  border: 0; background: transparent; color: var(--ink-soft);
  padding: 10px 14px; min-height: 40px; border-radius: 10px;
  font-weight: 600; white-space: nowrap; cursor: pointer;
}
.tab:hover { background: #f0f3f9; }
.tab.active { background: var(--primary); color: #fff; }

/* ---------------- main / sections ---------------- */

.main { padding: 14px 14px 90px; max-width: 1100px; margin: 0 auto; }
.scr h2 { margin: 6px 0 4px; font-size: 20px; }
.scr h3 { margin: 22px 0 8px; font-size: 15px; color: var(--ink-soft); }

/* ---------------- legend ---------------- */

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.key { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.swatch { width: 20px; height: 20px; border-radius: 6px; border: 1px solid #1c233322; display: inline-block; }
.swatch.t1200 { background: var(--t1200); }
.swatch.t750  { background: var(--t750); }
.swatch.t500  { background: var(--t500); }
.swatch.booked  { background: var(--booked); }
.swatch.sponsor { background: repeating-linear-gradient(45deg, var(--sponsor) 0 5px, #5c86f0 5px 10px); }
.swatch.picked { background: #fff; box-shadow: 0 0 0 3px var(--primary); }

/* ---------------- hall / seat map ---------------- */

.hall-scroll {
  overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 8px 10px;
  -webkit-overflow-scrolling: touch;
  max-height: 62dvh;
  overscroll-behavior: contain;
}
.hall {
  display: flex; flex-direction: column; align-items: center;
  gap: max(5px, calc(9px * var(--zoom)));
  width: fit-content; min-width: max-content; margin: 0 auto; padding: 4px 6px;
}
.row { display: flex; align-items: center; gap: max(2px, calc(4px * var(--zoom))); }
.row-label {
  width: 22px; text-align: center; font-weight: 700; font-size: 13px;
  color: var(--ink-soft); flex: none;
}
.aisle { width: max(6px, calc(14px * var(--zoom))); flex: none; }

/* ---- compact "rows" view (phone-first) ---- */
.rows { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; width: 100%; }
.rrow { display: flex; align-items: center; gap: 6px; }
.rscroll {
  display: flex; align-items: center; gap: 4px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 3px 2px; flex: 1; min-width: 0;
}
.rows .seat { width: 28px; height: 28px; font-size: 11px; }
.rows .aisle { width: 12px; }
.aisle-gap.slim { padding: 4px 0; font-size: 11px; letter-spacing: 3px; }

/* ---- map toolbar (mode + zoom) ---- */
.map-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.mt-group {
  display: inline-flex; gap: 2px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px;
}
.zoom-pct { font-size: 12px; font-weight: 700; min-width: 44px; text-align: center; color: var(--ink-soft); }
.map-hint { font-size: 12px; color: var(--ink-soft); margin-left: auto; }

.aisle-gap {
  width: min(70%, 520px); margin: 4px auto;
  border-top: 2px dashed var(--line); border-bottom: 2px dashed var(--line);
  padding: 6px 0; text-align: center; color: var(--ink-soft);
  font-size: 12px; letter-spacing: 2px;
}

.seat {
  width: var(--seat); height: var(--seat); flex: none;
  border: 1px solid #1c233326; border-radius: 8px;
  font-size: max(8px, calc(var(--seat) * 0.34));
  font-weight: 600; color: var(--ink);
  padding: 0; cursor: pointer;
  touch-action: manipulation;        /* pan stays native; double-tap-zoom off */
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.seat:active { transform: scale(0.96); }
.seat.t1200 { background: var(--t1200); }
.seat.t750  { background: var(--t750); }
.seat.t500  { background: var(--t500); }
.seat.booked  { background: var(--booked); color: #8a90a0; cursor: not-allowed; }
.seat.sponsor { background: repeating-linear-gradient(45deg, var(--sponsor) 0 5px, #5c86f0 5px 10px); color: #fff; cursor: not-allowed; }
.seat.selected { box-shadow: 0 0 0 3px var(--primary); }
.seat:disabled { cursor: not-allowed; }

.stage {
  margin: 16px auto 4px; min-width: min(70%, 560px);
  text-align: center; letter-spacing: 10px; font-weight: 800;
  color: #fff; background: linear-gradient(90deg, #6c5ce7, #8e7bff);
  border-radius: 12px; padding: 8px 0;
}

/* ---------------- customer form + booking bar ---------------- */

.cust-form {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  margin-top: 12px;
}
.cust-form .field { min-width: 200px; }

.booking-bar {
  position: sticky; bottom: 8px; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin-top: 12px;
  box-shadow: 0 6px 24px #1c23331f;
}
.bb-count { font-weight: 700; }
.bb-seats { font-size: 13px; color: var(--ink-soft); word-break: break-word; }
.bb-tiers { font-size: 13px; color: var(--ink-soft); }
.bb-right { text-align: right; flex: none; }
.bb-total { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.booking-bar:not(.has) #btn-confirm { opacity: 0.55; }

/* ---------------- forms / fields ---------------- */

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select {
  min-height: 42px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; background: #fff; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid #8fa7ff; border-color: #8fa7ff; }
.grow { flex: 1; }
.sm-field { min-width: 130px; margin-bottom: 0; }
.sm-field input, .sm-field select { min-height: 40px; }

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  margin: 10px 0 14px;
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad-bg); border-color: #f2b8b4; color: var(--bad); }
.btn.sm { min-height: 36px; padding: 5px 10px; }
.btn.xs { min-height: 30px; padding: 3px 9px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; margin-top: 6px; }

/* ---------------- cards / stats ---------------- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 6px; }
.stat { padding: 12px 14px; }
.stat-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); }
.stat-value { font-size: 24px; font-weight: 800; margin: 2px 0; }
.stat-sub { font-size: 12px; }

/* ---------------- tables ---------------- */

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin: 8px 0 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.table th {
  text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--ink-soft); border-bottom: 1px solid var(--line);
  background: #f7f9fc; white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #edf0f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { white-space: nowrap; }
.table .actions .btn { margin-right: 4px; }

/* ---------------- pills ---------------- */

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: #eef1f7; color: var(--ink-soft);
}
.pill.ok   { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad  { background: var(--bad-bg); color: var(--bad); }
.pill.dim  { background: #eef1f7; color: var(--ink-soft); }

/* ---------------- volunteer form ---------------- */

.vol-form {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
}
.vol-form .btn { flex: none; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  max-width: min(92vw, 560px); padding: 12px 18px; border-radius: 12px;
  background: var(--primary); color: #fff; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s;
  z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------------- responsive ---------------- */

@media (max-width: 640px) {
  :root { --seat-base: 30px; }
  .appbar-title { font-size: 14px; }
  .map-hint { display: none; }
  .hall-scroll { max-height: 66dvh; }
  .main { padding-bottom: 130px; }
  .booking-bar { flex-direction: column; align-items: stretch; }
  .bb-right { text-align: left; display: flex; align-items: center; justify-content: space-between; }
  .bb-total { margin: 0; }
}
