:root {
  --bg: #0c4a6e;
  --bg2: #0369a1;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --libre: #f1f5f9;
  --ok: #16a34a;
  --danger: #dc2626;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #f0f9ff;
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(5rem + var(--safe-b));
}

button,
input,
select {
  font: inherit;
}

.app-header {
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  color: #fff;
  padding: calc(1rem + var(--safe-t)) 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(12, 74, 110, 0.25);
}

.app-header h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
}

.app-header p {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #bae6fd;
}

.hint-hold {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: #7dd3fc;
}

#lista-reservas {
  list-style: none;
  margin: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.reserva-item {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.reserva-card {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--card);
  padding: 1rem 1.1rem;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  cursor: pointer;
}

.reserva-del {
  flex-shrink: 0;
  width: 3rem;
  border: 1px solid #fecaca;
  border-radius: 1rem;
  background: #fff5f5;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.reserva-del:active {
  background: #fee2e2;
}

.reserva-del svg {
  display: block;
}

.reserva-card:active {
  transform: scale(0.99);
}

.reserva-card h2 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.35;
}

.reserva-card .meta {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--bg2);
  font-weight: 700;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.input-touch {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  font-size: 16px;
  background: #fff;
}

.preview-label {
  margin: 1.1rem 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.titulo-preview {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 0.85rem;
  background: #e0f2fe;
  color: var(--bg-deep);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
}

.empty-list {
  margin: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + var(--safe-b));
  z-index: 20;
  border: none;
  border-radius: 999px;
  background: var(--ok);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.95rem 1.25rem;
  box-shadow: 0 8px 24px rgba(22, 163, 74, 0.45);
  touch-action: manipulation;
  cursor: pointer;
}

.fab:active {
  transform: scale(0.99);
}

body:has(.modal-backdrop) .fab {
  visibility: hidden;
  pointer-events: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-backdrop.crear {
  align-items: center;
  padding: 1rem;
}

.modal-sheet {
  width: 100%;
  max-width: 32rem;
  max-height: 92dvh;
  background: var(--card);
  border-radius: 1.25rem 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.22s ease-out;
}

.modal-backdrop.crear .modal-sheet {
  border-radius: 1.25rem;
  max-height: 85dvh;
}

@keyframes slideUp {
  from {
    transform: translateY(12%);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-head {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  padding-right: 2rem;
}

.modal-close {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: var(--libre);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted);
}

.modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 1rem calc(1rem + var(--safe-b));
  flex: 1;
}

.modal-head-wrap {
  position: relative;
}

.cupo-badge {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--bg2);
  background: #e0f2fe;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.slot-row {
  display: grid;
  grid-template-columns: 1.75rem 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
  min-height: 3rem;
}

.slot-row:last-child {
  border-bottom: none;
}

.slot-num {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--muted);
}

.slot-nombre {
  font-size: 0.95rem;
  font-weight: 600;
  word-break: break-word;
}

.slot-nombre.libre {
  color: var(--muted);
  font-weight: 500;
  font-style: italic;
}

.pago-select {
  font-size: 0.72rem;
  padding: 0.35rem 0.4rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: #fff;
  max-width: 6.5rem;
}

.btn-quitar {
  border: none;
  background: #fee2e2;
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.4rem 0.55rem;
  border-radius: 0.5rem;
  white-space: nowrap;
}

.join-box {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--libre);
  border-radius: 1rem;
  border: 1px dashed #cbd5e1;
}

.join-box-top {
  margin-top: 0;
  margin-bottom: 1rem;
  background: #f0f9ff;
  border-color: #7dd3fc;
}

.join-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.lista-titulo {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
}

.lista-vacia {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

.suplentes-block {
  margin-top: 0.75rem;
}

.suplentes-titulo {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 800;
  color: #c2410c;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.slot-row.suplente-row,
.suplentes-block .slot-row {
  background: #fff7ed;
  border-radius: 0.5rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.join-box h3 {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
}

.join-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.join-row input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  font-size: 16px;
}

.join-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.join-actions select {
  flex: 1;
  padding: 0.7rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  font-size: 16px;
}

.btn-primary {
  flex: 1;
  border: none;
  background: var(--bg2);
  color: #fff;
  font-weight: 700;
  padding: 0.75rem;
  border-radius: 0.75rem;
}

.btn-primary:disabled {
  opacity: 0.55;
}

.confirm-sheet {
  max-width: 22rem;
}

.confirm-msg {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
}

.btn-danger {
  flex: 1;
  border: none;
  background: #dc2626;
  color: #fff;
  font-weight: 700;
  padding: 0.75rem;
  border-radius: 0.75rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.field textarea {
  width: 100%;
  min-height: 5.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  font-size: 16px;
  resize: vertical;
}

.modal-foot {
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-b));
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.5rem;
}

.btn-secondary {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.75rem;
  border-radius: 0.75rem;
  font-weight: 600;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(5rem + var(--safe-b));
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 0.82rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: calc(100% - 2rem);
  text-align: center;
}

#toast.show {
  opacity: 1;
}

#err-config {
  margin: 1rem;
  padding: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.75rem;
  color: #991b1b;
  font-size: 0.88rem;
  display: none;
}

#err-config.visible {
  display: block;
}
