:root {
  --bg: #0d0f1a;
  --bg-soft: #161a2b;
  --card: #1c2136;
  --card-2: #232a44;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7c5cff;
  --accent-2: #a78bff;
  --green: #2ecc8f;
  --red: #ff5c72;
  --gold: #f2c14e;
  --purple: #c084fc;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #131728 0%, #0d0f1a 100%);
  border-bottom: 1px solid #232a44;
}

.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-club { font-size: 12px; letter-spacing: 3px; color: var(--muted); font-weight: 700; }
.brand-app { font-size: 18px; font-weight: 800; letter-spacing: 1px; color: var(--accent-2); }

.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-email {
  font-size: 11px; color: var(--muted); max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  background: var(--card); color: var(--text); border: 1px solid #2b3355;
  border-radius: 10px; font-size: 16px; padding: 6px 9px; cursor: pointer;
}
.icon-btn:hover { background: var(--card-2); }

/* ---------- Main ---------- */
main { max-width: 720px; margin: 0 auto; padding: 14px 14px 110px; }

.toolbar { margin-bottom: 10px; }
#searchInput {
  width: 100%; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid #2b3355; background: var(--bg-soft); color: var(--text);
  font-size: 15px; outline: none;
}
#searchInput:focus { border-color: var(--accent); }

.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip-filter {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid #2b3355; background: var(--bg-soft); color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.chip-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.bulk-bar { margin: 10px 0 0; }
.summary { margin: 10px 2px; color: var(--muted); font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 12px; padding: 11px 16px; font-size: 14px;
  font-weight: 700; cursor: pointer; transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--red); color: #fff; width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid #2b3355; }
.btn-small { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Ticket cards ---------- */
.ticket-list { display: flex; flex-direction: column; gap: 12px; }

.ticket {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  border: 1px solid #262e4d; box-shadow: var(--shadow); position: relative;
}
.ticket.expired { border-color: #5a2b38; background: #22161f; }

.ticket-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ticket-name { font-size: 16px; font-weight: 800; margin: 0; }
.ticket-dni { font-size: 12px; color: var(--muted); margin-top: 2px; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.4px; }
.badge-plan { background: #2b3355; color: var(--accent-2); }
.badge-vip { background: linear-gradient(135deg, #f2c14e, #b8860b); color: #241a02; }
.badge-active { background: rgba(46, 204, 143, 0.15); color: var(--green); border: 1px solid rgba(46, 204, 143, 0.4); }
.badge-expired { background: rgba(255, 92, 114, 0.15); color: var(--red); border: 1px solid rgba(255, 92, 114, 0.4); }
.badge-drinks-done { background: rgba(192, 132, 252, 0.15); color: var(--purple); border: 1px solid rgba(192, 132, 252, 0.4); }
.badge-couple { background: rgba(238, 241, 255, 0.08); color: var(--muted); border: 1px solid #2b3355; }

.ticket-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.ticket-meta b { color: var(--text); font-weight: 700; }

.drinks-row {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed #2b3355;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.drinks-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.drinks { display: flex; gap: 5px; font-size: 20px; }
.drink { filter: grayscale(1) opacity(0.35); }
.drink.used { filter: none; }

.drinks-actions { display: flex; gap: 8px; }

.card-delete {
  position: absolute; top: 8px; right: 8px; background: transparent; border: none;
  color: var(--muted); font-size: 14px; cursor: pointer; opacity: 0.6; padding: 4px;
}
.card-delete:hover { opacity: 1; color: var(--red); }

/* ---------- Empty / loading ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px;
  background: var(--bg-soft); border-radius: var(--radius); border: 1px dashed #2b3355;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: 18px; width: 60px; height: 60px;
  border-radius: 50%; border: none; background: var(--accent); color: #fff;
  font-size: 30px; line-height: 1; cursor: pointer; box-shadow: 0 10px 25px rgba(124, 92, 255, 0.45);
  z-index: 30;
}
.fab:hover { filter: brightness(1.1); }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(5, 6, 12, 0.72);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
@media (min-width: 560px) { .modal { align-items: center; } }

.modal-card {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: 18px 18px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow);
}
@media (min-width: 560px) { .modal-card { border-radius: 18px; } }
.modal-small { max-width: 380px; }
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }

.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.modal-card input {
  padding: 11px 12px; border-radius: 10px; border: 1px solid #2b3355;
  background: var(--bg-soft); color: var(--text); font-size: 15px; outline: none;
}
.modal-card input:focus { border-color: var(--accent); }

.plan-options { border: none; padding: 0; margin: 0; }
.plan-options legend { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.plan-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.plan-card {
  border: 1px solid #2b3355; background: var(--bg-soft); border-radius: 12px;
  padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.plan-card.selected { border-color: var(--accent); background: rgba(124, 92, 255, 0.12); }
.plan-card input { display: none; }
.plan-name { font-weight: 700; font-size: 14px; }
.plan-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.plan-price { font-weight: 800; font-size: 14px; color: var(--accent-2); white-space: nowrap; }

.expiry-preview {
  margin: 0; font-size: 13px; color: var(--green); font-weight: 700;
  background: rgba(46, 204, 143, 0.1); border: 1px solid rgba(46, 204, 143, 0.3);
  border-radius: 10px; padding: 9px 12px;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px;
  background: #05060c; color: var(--text); border: 1px solid #2b3355;
  padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  z-index: 60; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
  transition: opacity 0.25s;
}
.toast.error { border-color: var(--red); color: #ffb3bd; }

/* ---------- Vista pública (consulta por DNI) ---------- */
.lookup {
  background: linear-gradient(160deg, #1c2136 0%, #141828 100%);
  border: 1px solid #262e4d; border-radius: 18px;
  padding: 26px 20px; margin-top: 8px; box-shadow: var(--shadow); text-align: center;
}
.lookup-title { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.lookup-sub { margin: 0 auto 18px; max-width: 420px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.lookup-form {
  display: flex; gap: 8px; max-width: 420px; margin: 0 auto;
}
.lookup-form input {
  flex: 1; min-width: 0; padding: 13px 14px; border-radius: var(--radius);
  border: 1px solid #2b3355; background: var(--bg-soft); color: var(--text);
  font-size: 16px; outline: none; text-align: center; letter-spacing: 2px;
}
.lookup-form input:focus { border-color: var(--accent); }
.lookup-form .btn { flex: 0 0 auto; }
.lookup-note { margin: 16px 0 0; color: var(--muted); font-size: 12.5px; }
.lookup-note b { color: var(--accent-2); }
#lookupResults { margin-top: 16px; }

/* ---------- Modal PIN / ajustes ---------- */
.pin-hint { margin: -6px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
#formPin input, #formChangePin input { letter-spacing: 4px; text-align: center; font-size: 18px; }
.settings-divider { border: none; border-top: 1px dashed #2b3355; margin: 18px 0 14px; }

.hidden { display: none !important; }
