* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --coal: #0b0c0f;
  --surface: #14161c;
  --surface-2: #1a1d25;
  --surface-3: #22262f;
  --border: rgba(206, 211, 220, 0.09);
  --border-strong: rgba(206, 211, 220, 0.18);
  --text: #e8eaee;
  --text-2: #a2a9b6;
  --text-3: #6b7280;
  --purple: #a78bfa;
  --purple-strong: #8b5cf6;
  --purple-deep: #6d3fd1;
  --silver: #c8cdd6;
  --green: #6ee7a0;
  --amber: #f5c76b;
  --red: #f4a3a3;
  --gold: #d8bb6b;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

html { color-scheme: dark; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--coal);
  color: var(--text);
  max-width: 860px;
  margin: 0 auto;
  padding: 0 14px 120px;
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(700px 380px at 85% -10%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(500px 320px at -10% 0%, rgba(139, 92, 246, 0.08), transparent 60%);
  pointer-events: none;
  z-index: -1;
}

.topbar {
  height: 3px;
  background: linear-gradient(90deg, var(--purple-strong), #b9a5ff 55%, var(--silver));
  border-radius: 0 0 4px 4px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 2px 20px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 13px; }

.logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple-strong), var(--purple-deep));
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
  letter-spacing: 0.5px;
}

header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.subtitle { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

/* ---------- Botones ---------- */
.btn-primary, .btn-ghost {
  border: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: 10px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, filter 0.15s;
}
.btn-primary:active, .btn-ghost:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--purple-strong), var(--purple-deep));
  color: #fff;
  padding: 13px 22px;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 10px 16px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-ghost:hover { background: var(--surface-3); border-color: rgba(167, 139, 250, 0.4); }
.btn-ghost .ico { color: var(--purple); font-size: 13px; }

/* ---------- Tarjetas resumen ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--purple);
  opacity: 0.5;
}
.card.ok::before { background: var(--green); }
.card.wait::before { background: var(--amber); }
.card.no::before { background: var(--red); }
.card.star::before { background: linear-gradient(90deg, var(--purple), var(--silver)); }

.card .label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}
.card .value {
  display: block;
  font-size: 30px;
  font-weight: 800;
  margin-top: 6px;
  color: #fff;
  letter-spacing: -0.5px;
}
.card.ok .value { color: var(--green); }
.card.wait .value { color: var(--amber); }
.card.no .value { color: var(--red); }
.card.star .value { color: var(--purple); }

/* ---------- Panel lista ---------- */
.panel {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
.ta-right { text-align: right !important; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

tbody td {
  padding: 13px 12px;
  font-size: 14.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.row-priority td { background: rgba(139, 92, 246, 0.08); }
.row-priority:hover td { background: rgba(139, 92, 246, 0.12); }

.row-confirmed td { background: rgba(214, 178, 92, 0.06); }
.row-confirmed:hover td { background: rgba(214, 178, 92, 0.11); }
.row-confirmed td:first-child { color: var(--gold); }
.row-confirmed.row-priority:hover td { background: rgba(139, 92, 246, 0.10); }

.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.state.pendiente { background: rgba(245, 199, 107, 0.12); color: var(--amber); }
.state.confirmado { background: rgba(110, 231, 160, 0.12); color: var(--green); }
.state.rechazado { background: rgba(244, 163, 163, 0.12); color: var(--red); }

.prio-yes { color: var(--purple); font-weight: 700; font-size: 14px; }

/* ---------- Botones de fila ---------- */
td button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.12);
  color: var(--purple);
  margin-right: 6px;
  transition: background 0.12s;
}
td button:hover { background: rgba(139, 92, 246, 0.24); }
td button.danger { background: rgba(244, 163, 163, 0.12); color: var(--red); }
td button.danger:hover { background: rgba(244, 163, 163, 0.24); }

.empty { text-align: center; color: var(--text-3); padding: 26px 0 8px; }

/* ---------- Botón flotante + ---------- */
.fab {
  position: fixed;
  bottom: 22px;
  right: 20px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--purple-strong), var(--purple-deep));
  color: #fff;
  font-size: 34px;
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 10px 28px rgba(139, 92, 246, 0.5);
  display: grid;
  place-items: center;
  z-index: 50;
  transition: transform 0.12s, filter 0.15s;
}
.fab:hover { filter: brightness(1.1); }
.fab:active { transform: scale(0.92); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 12, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 18px;
  animation: fadeIn 0.15s ease;
}
.modal-overlay[hidden] { display: none; }

.modal {
  width: min(440px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
  padding: 20px;
  animation: modalUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 { font-size: 19px; letter-spacing: -0.2px; }
.modal-close {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: #fff; background: #2a2e38; }

#guest-form .field {
  display: block;
  margin-bottom: 13px;
}
.field span {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.field input, .select-wrap select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 16px;
  background: var(--coal);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .select-wrap select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}
.field input::placeholder { color: var(--text-3); }

.select-wrap { position: relative; }
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--silver);
  border-bottom: 2px solid var(--silver);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  margin: 4px 0 18px;
}
.check input { width: 18px; height: 18px; accent-color: var(--purple-strong); cursor: pointer; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal-actions .btn-primary { flex: 1.4; }
.modal-actions .btn-ghost { flex: 1; justify-content: center; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalUp { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- Nombre clickeable ---------- */
.name-cell { cursor: pointer; transition: color 0.12s; }
.name-cell:hover { color: var(--purple); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Resaltado al llegar por QR / código ---------- */
.row-highlight td { background: rgba(167, 139, 250, 0.22) !important; }
@keyframes pulseHighlight {
  0% { background: rgba(167, 139, 250, 0.4) !important; }
  100% { background: rgba(167, 139, 250, 0.22) !important; }
}
.row-highlight td { animation: pulseHighlight 1.6s ease; }

/* ---------- Modal de detalle (QR + código) ---------- */
.detail-modal { width: min(360px, 100%); }
.detail-tags { display: flex; justify-content: center; gap: 8px; margin: 2px 0 18px; flex-wrap: wrap; }
.prio-tag {
  background: rgba(167, 139, 250, 0.14);
  color: var(--purple);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.prio-tag::before { content: "★"; font-size: 12px; }
.detail-qr {
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  display: inline-block;
  margin: 0 auto 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  line-height: 0;
}
.detail-qr img { display: block; width: 220px; height: 220px; max-width: 100%; }
.code-box { text-align: left; }
.code-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-3); font-weight: 600; }
.code-row { display: flex; gap: 8px; margin-top: 6px; }
.code-row code {
  flex: 1;
  background: var(--coal);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--silver);
  word-break: break-all;
}
.btn-copy {
  background: rgba(139, 92, 246, 0.12);
  color: var(--purple);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
.btn-copy:hover { background: rgba(139, 92, 246, 0.24); }

/* ---------- Pantalla de bloqueo (PIN) ---------- */
#lock-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background:
    radial-gradient(700px 380px at 50% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
    var(--coal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#lock-screen[hidden] { display: none; }

.lock-card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  padding: 28px 24px;
  width: min(340px, 100%);
  text-align: center;
  animation: modalUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.lock-logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple-strong), var(--purple-deep));
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}
.lock-card h2 { font-size: 20px; margin-bottom: 4px; }
.lock-sub { color: var(--text-3); font-size: 13px; margin-bottom: 18px; }

#pin-input {
  width: 100%;
  text-align: center;
  letter-spacing: 14px;
  font-size: 26px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--coal);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#pin-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}
.lock-card .btn-primary { width: 100%; margin-top: 14px; }
.pin-error { color: var(--red); font-size: 13px; margin-top: 12px; }

@media (max-width: 600px) {
  body { padding: 0 12px 120px; }
  header { gap: 12px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card .value { font-size: 26px; }

  thead th { padding: 10px 8px; }
  tbody td { padding: 14px 8px; }

  td button { padding: 8px 11px; margin-right: 4px; }

  .fab { bottom: 18px; right: 18px; width: 60px; height: 60px; }
  .detail-qr img { width: 190px; height: 190px; }
}