.afi-wrap {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #222;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.afi-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 16px;
  margin: 0 0 16px;
}

.afi-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 12px;
}

.afi-grid input,
.afi-grid textarea,
.afi-inline input,
.afi-inline select,
.afi-card select {
  width: 100%;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  padding: 8px;
}

.afi-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

.afi-btn {
  border: 0;
  border-radius: 10px;
  background: #7bc47f;
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
}

.afi-machine-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 8px;
  margin: 8px 0;
}

.afi-machine-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.afi-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: #dbeafe;
  color: #1e40af;
  cursor: pointer;
}

.afi-edit:hover {
  background: #bfdbfe;
}

.afi-icon-edit {
  display: block;
}

.afi-delete {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: #f4d1d8;
  cursor: pointer;
}

.afi-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.afi-modal-overlay[hidden] {
  display: none;
}

.afi-modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.afi-modal h3 {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

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

.afi-btn-secondary {
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #fff;
  color: #333;
  padding: 10px 14px;
  cursor: pointer;
}

.afi-btn-secondary:hover {
  background: #f5f5f5;
}

.afi-week-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  margin: 8px 0;
}

.afi-msg {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 10px;
}

/* Vista reservas / res_date: usa todo el ancho del contenedor (tema + móvil), sin tope fijo 480px */
.afi-mobile {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  background: #f7f7f7;
  min-height: 100vh;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

.afi-user {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.afi-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: #ddd;
}

.afi-user h2 {
  margin: 0;
  font-size: 40px;
  line-height: 1;
  font-weight: 600;
}

.afi-days {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 8px;
}

.afi-day-pill {
  border: 0;
  border-radius: 10px;
  background: transparent;
  min-width: 54px;
  padding: 8px;
  color: #666;
}

.afi-day-pill strong {
  display: block;
}

.afi-day-pill.active {
  background: #b30d61;
  color: #fff;
}

.afi-machine-card {
  background: #f2f2f2;
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
  border-left: 8px solid var(--afi-machine-color, #ff6f00);
}

.afi-machine-card h3 {
  margin: 0 0 10px;
  font-size: 22px;
}

.afi-slot-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.afi-slot {
  border: 0;
  border-radius: 20px;
  width: 78px;
  height: 78px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: #333;
}

.afi-slot.available {
  background: #c7d7b7;
}

.afi-slot.reserved {
  background: #e9c9d5;
}

.afi-slot.disabled {
  background: #d1d1d4;
}

.afi-slot.mine {
  background: #fd9643;
}

.afi-slot:disabled {
  cursor: not-allowed;
  opacity: 0.85;
}

.afi-empty {
  color: #777;
}

.afi-time-card {
  background: #f2f2f2;
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
  border-left: 8px solid #ff6f00;
}

.afi-time-card h3 {
  margin: 0 0 10px;
  font-size: 22px;
}

.afi-equip-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.afi-equip-pill {
  border: 0;
  border-radius: 18px;
  min-width: 80px;
  height: 80px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 20px;
  color: #333;
  background: #d1d1d4;
}

.afi-equip-pill.available {
  background: #c7d7b7;
}

.afi-equip-pill.reserved {
  background: #e9c9d5;
}

.afi-equip-pill.mine {
  background: #fd9643;
}

.afi-equip-pill.disabled {
  background: #d1d1d4;
}

.afi-equip-pill:disabled {
  cursor: not-allowed;
  opacity: 0.9;
}

@media (max-width: 540px) {
  .afi-user h2 {
    font-size: 24px;
  }
}

/* Diálogos táctiles: reservar / cancelar en móvil */
.afi-touch-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
}

.afi-touch-dialog {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  box-sizing: border-box;
}

.afi-touch-dialog-msg {
  margin: 0 0 20px;
  font-size: 1.1rem;
  line-height: 1.45;
  color: #222;
  text-align: center;
}

.afi-touch-dialog-actions {
  display: flex;
  flex-direction: row;
  gap: 12px;
  justify-content: stretch;
}

.afi-touch-dialog-actions-single {
  justify-content: center;
}

.afi-touch-dialog-btn {
  flex: 1;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}

.afi-touch-dialog-btn-primary {
  background: #7bc47f;
  color: #fff;
}

.afi-touch-dialog-btn-primary:active {
  filter: brightness(0.95);
}

.afi-touch-dialog-btn-secondary {
  background: #eee;
  color: #333;
}

.afi-touch-dialog-actions-single .afi-touch-dialog-btn {
  flex: 0 1 auto;
  min-width: 160px;
}
